rect

How can I make the ball move instead of stretch in pygame?

雨燕双飞 提交于 2021-02-13 05:42:25
问题 I'm building a pong game trying to get better at programming but Im having trouble moving the ball. When the move_right method is called the ellipse stretches to the right instead of moving to the right. I've tried putting the ball variable in the init method but that just makes it not move at all even though the variables should be changing on account of the move_right method. I have also tried setting the x and y positions as parameters in the Ball class,but that just stretches it also. I

rect collision with list of rects

喜欢而已 提交于 2021-01-30 09:12:55
问题 I have the code player_rect.colliderect(tile_rects): where player_rect is a single Rect , and tile_rects is a list of Rect s. I get the error `builtins.TypeError: Argument must be rect style object when I try to run my code (presumably as the code doesn't like having a list of rects over a single rect). I also just found out than when I switch the positions of tile_rects and player_rect I instead get the error builtins.AttributeError: 'list' object has no attribute 'colliderect' My question

rect collision with list of rects

走远了吗. 提交于 2021-01-30 09:05:24
问题 I have the code player_rect.colliderect(tile_rects): where player_rect is a single Rect , and tile_rects is a list of Rect s. I get the error `builtins.TypeError: Argument must be rect style object when I try to run my code (presumably as the code doesn't like having a list of rects over a single rect). I also just found out than when I switch the positions of tile_rects and player_rect I instead get the error builtins.AttributeError: 'list' object has no attribute 'colliderect' My question

How do I scale a PyGame image (Surface) with respect to its center?

≯℡__Kan透↙ 提交于 2021-01-13 09:32:28
问题 I am fairly new to pygame and am working on my first game. (So sorry if I'm asking a stupid question) I am trying to get the title of the game to slowly increase and decrease in size like a sort of breathing effect in order to make the home screen more visually appealing. Here's what I've got to import the image: name = self.dir_path + "pixeltitle.png" self.pixeltitle = pg.image.load(name) self.pixeltitlerect = self.pixeltitle.get_rect() self.pixeltitlerect.center = (250,120) self.screen.blit

Python: rect argument is invalid [duplicate]

核能气质少年 提交于 2021-01-11 03:13:45
问题 This question already has an answer here : My pygame rects are giving a rect argument is invalid error (1 answer) Closed 3 months ago . Hi I'm trying to learn python and but i'm stuck with this problem, when i run my program it says rect argument is invalid, this is my code: import pygame pygame.init() win = pygame.display.set_mode((500,500)) pygame.display.set_caption("First game") x = 50 y = 50 width = 40 height = 60 vel = 5 run = True while run: pygame.time.delay(100) for event in pygame

Python: rect argument is invalid [duplicate]

前提是你 提交于 2021-01-11 02:59:37
问题 This question already has an answer here : My pygame rects are giving a rect argument is invalid error (1 answer) Closed 3 months ago . Hi I'm trying to learn python and but i'm stuck with this problem, when i run my program it says rect argument is invalid, this is my code: import pygame pygame.init() win = pygame.display.set_mode((500,500)) pygame.display.set_caption("First game") x = 50 y = 50 width = 40 height = 60 vel = 5 run = True while run: pygame.time.delay(100) for event in pygame

Python: rect argument is invalid [duplicate]

雨燕双飞 提交于 2021-01-11 02:57:46
问题 This question already has an answer here : My pygame rects are giving a rect argument is invalid error (1 answer) Closed 3 months ago . Hi I'm trying to learn python and but i'm stuck with this problem, when i run my program it says rect argument is invalid, this is my code: import pygame pygame.init() win = pygame.display.set_mode((500,500)) pygame.display.set_caption("First game") x = 50 y = 50 width = 40 height = 60 vel = 5 run = True while run: pygame.time.delay(100) for event in pygame

Why are my rects not working and making the player interact with the door as it is supposed to in pygame [closed]

只愿长相守 提交于 2020-11-29 03:07:23
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 26 days ago . Improve this question I am trying to make the player sprite act when he touches the door but it is not working. I am trying to make it print the word collision but it is not appearing.Most of the code comes from: https://pythonprogramming.altervista.org/platform-game-in-detail-part-1/?doing_wp_cron

Why are my rects not working and making the player interact with the door as it is supposed to in pygame [closed]

☆樱花仙子☆ 提交于 2020-11-29 03:06:31
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 26 days ago . Improve this question I am trying to make the player sprite act when he touches the door but it is not working. I am trying to make it print the word collision but it is not appearing.Most of the code comes from: https://pythonprogramming.altervista.org/platform-game-in-detail-part-1/?doing_wp_cron