HOW TO MAKE PONG IN PYTHON AND PYGAME! (15 Min)

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024

Комментарии •

  • @tracy1944
    @tracy1944 2 года назад +3

    i don't even code but this is actually surprisingly engaging and i can tell every second of it has effort put in. nice job :)

    • @tracy1944
      @tracy1944 2 года назад

      nobody asked but actually i did a coding class in elementary

    • @baraltech
      @baraltech  2 года назад +1

      This made my -day-
      This made my -week-
      This made my -month-
      This made my life

  • @mohammadsaleem4956
    @mohammadsaleem4956 Год назад +1

    Great Job, Young Programmer!!!

  • @krishpurani7809
    @krishpurani7809 2 года назад +1

    Proud of you lil dawg!

  • @TheDefilerAzog
    @TheDefilerAzog 3 месяца назад

    u need more subs this is actually so good.

  • @OrangeDied
    @OrangeDied 2 года назад

    impressive explanations and editing, surprised you don't have more subs!

  • @TUFF-TJ
    @TUFF-TJ Год назад +1

    Thank you, this helped me out a lot

  • @juliansolanobotina7983
    @juliansolanobotina7983 8 месяцев назад +2

    hey, i've got a problem, in the minute 10:49 when the ball must come back to the center after a point, i can't use ball.CENTER, it says "Cannot assign member "center" for type "Rect"
    "float" is incompatible with "int"
    "float" is incompatible with "int"

  • @dgofficial-r5f
    @dgofficial-r5f 3 месяца назад

    I need help. When I finish creating the paddles, the game screen shows nothing but a black screen. Is there anyway to fix it?

  • @ludvig7749
    @ludvig7749 3 месяца назад

    btw if you want the ai a bit faster just chance the value to 2 it moves faster :)

  • @NoobContent
    @NoobContent 10 месяцев назад

    It turns out if you create a variable called opponent_speed = (any number you want)
    and then put it here like this:
    if opponent.y < ball.y:
    opponent.top += opponent_speed
    if opponent.bottom > ball.y:
    opponent.bottom -= opponent_speed
    You can set how good the opponent can be!

    • @NoobContent
      @NoobContent 10 месяцев назад

      Note: I don't know why the opponent turned into a link

  • @hri613
    @hri613 2 года назад

    what code editor did you use for python in this video? Atom?

  • @gamelad1235
    @gamelad1235 7 дней назад

    whenever i run it opens a widow with a green backround ad loads of lillte balls

  • @TheDefilerAzog
    @TheDefilerAzog 3 месяца назад

    thank you

  • @andrewsodyssey5753
    @andrewsodyssey5753 2 года назад

    Yo this is fantastic but for the score part I get an issue message in pycharm that says "End of statement expected" if you know how to fix that then it would be greatly appreciated

    • @baraltech
      @baraltech  2 года назад

      Thanks for the comment! Could you please send your code so I can take a look at it and fix your error? Thank you!

    • @andrewsodyssey5753
      @andrewsodyssey5753 2 года назад

      @@baraltech
      import pygame, sys, random
      pygame.init()
      WIDTH,HEIGHT = 1200, 720
      FONT = pygame.font.SysFont("Consolas",int(WIDTH/20))
      SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
      pygame.display.set_caption("Ponk")
      CLOCK = pygame.time.Clock()
      player = pygame.Rect(WIDTH-110, HEIGHT/2-50, 10, 100)
      opponent = pygame.Rect(110, HEIGHT/2-50, 10, 100)
      player_score, opponent_score = 0,0
      ball = pygame.Rect(WIDTH/2-10, HEIGHT/2-10, 20, 20)
      x_speed, y_speed = 1,1
      while True:
      keys_pressed = pygame.key.get_pressed()
      if keys_pressed[pygame.K_UP]:
      if player.top > 0:
      player.top -= 2
      if keys_pressed[pygame.K_DOWN]:
      if player.bottom < HEIGHT:
      player.bottom += 2
      for event in pygame.event.get():
      if event.type == pygame.QUIT:
      pygame.quit()
      sys.exit()
      if ball.y >= HEIGHT:
      y_speed = -1
      if ball.y

    • @andrewsodyssey5753
      @andrewsodyssey5753 2 года назад

      @@baraltech it could just be Pycharm being picky but I'm not sure

    • @baraltech
      @baraltech  2 года назад

      @@andrewsodyssey5753 I tried running your exact code and the scoreboard shows up for me.. strange

    • @andrewsodyssey5753
      @andrewsodyssey5753 2 года назад

      @@baraltech Huh, how strange it must just be Pycharm being picky but thanks anyways

  • @aks_ctrl3798
    @aks_ctrl3798 2 года назад

    what app is that

    • @baraltech
      @baraltech  2 года назад

      Python?

    • @aks_ctrl3798
      @aks_ctrl3798 2 года назад

      @@baraltech it doesn't show me the numbers

    • @baraltech
      @baraltech  2 года назад

      @@aks_ctrl3798 You mean the score? That's strange. Can you send your code?

    • @ludvig7749
      @ludvig7749 3 месяца назад

      visual studio code

    • @canadian..chaser
      @canadian..chaser 3 месяца назад

      I think he meant the code shown in the video like the scripts not the software you used