pygame

pygame.error: Failed loading libmpg123.dll: Attempt to access invalid address

我是研究僧i 提交于 2020-12-26 07:58:37
问题 music = pygame.mixer.music.load('not.mp3') pygame.mixer.music.play(loops=-1) when executing this i got this error Traceback (most recent call last): File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\Escape it!.py", line 15, in <module> music = pygame.mixer.music.load('not.mp3') pygame.error: Failed loading libmpg123.dll: Attempt to access invalid address. i has tried everything from giving full path to only the name but everytime this shows uo 回答1: Restart your IDE if that doesn

How to scale the font size in pygame based on display resolution?

时光怂恿深爱的人放手 提交于 2020-12-26 07:26:53
问题 largeText = pygame.font.Font('digifaw.ttf',450) Font size is 450 and is suitable for the displaying the text in a full screen display of resolution 1366x768 . How do I change the font size such that it is compatible with other display resolutions ? I looked up the pydocs for font and couldn't find anything related to auto scaling. Update: Here's a snippet of the code def text_objects(text, font): textSurface = font.render(text, True, black) return textSurface, textSurface.get_rect() def

Pygame collision with masks is not working

做~自己de王妃 提交于 2020-12-26 04:39:44
问题 I have made a putt-putt game and now I want to add a slanted wall type. Because of this, I need to use masks for the collision (until now I have just used rects). I have spent hours learning about masks and trying to figure out why my code won't work. There are no errors, the collision just isn't detected. I have simplified my code down to something much smaller just as a way for me to test it efficiently. From everything I've seen this seems like it should work, but it doesnt. Here it is:

Pygame collision with masks is not working

杀马特。学长 韩版系。学妹 提交于 2020-12-26 04:39:05
问题 I have made a putt-putt game and now I want to add a slanted wall type. Because of this, I need to use masks for the collision (until now I have just used rects). I have spent hours learning about masks and trying to figure out why my code won't work. There are no errors, the collision just isn't detected. I have simplified my code down to something much smaller just as a way for me to test it efficiently. From everything I've seen this seems like it should work, but it doesnt. Here it is:

Difference between rect.move() and rect.move_ip in pygame

霸气de小男生 提交于 2020-12-25 18:24:22
问题 I was just going through the .rect method of pygame in the official docs. We have 2 cases , pygame.rect.move(arg1,arg2) which is used to move a .rect object on the screen and pygame.rect.move_ip(arg1,arg2) which is , according to the docs, also used to move a .rect object on the screen but it moves it in place I didnt quite get what it means. Can anyone explain what move in place means? 回答1: "In place" means the object self . While rect.move_ip changes the pygame.Rect object itself, rect.move

Difference between rect.move() and rect.move_ip in pygame

血红的双手。 提交于 2020-12-25 18:24:19
问题 I was just going through the .rect method of pygame in the official docs. We have 2 cases , pygame.rect.move(arg1,arg2) which is used to move a .rect object on the screen and pygame.rect.move_ip(arg1,arg2) which is , according to the docs, also used to move a .rect object on the screen but it moves it in place I didnt quite get what it means. Can anyone explain what move in place means? 回答1: "In place" means the object self . While rect.move_ip changes the pygame.Rect object itself, rect.move

Difference between rect.move() and rect.move_ip in pygame

霸气de小男生 提交于 2020-12-25 18:23:53
问题 I was just going through the .rect method of pygame in the official docs. We have 2 cases , pygame.rect.move(arg1,arg2) which is used to move a .rect object on the screen and pygame.rect.move_ip(arg1,arg2) which is , according to the docs, also used to move a .rect object on the screen but it moves it in place I didnt quite get what it means. Can anyone explain what move in place means? 回答1: "In place" means the object self . While rect.move_ip changes the pygame.Rect object itself, rect.move

Difference between rect.move() and rect.move_ip in pygame

笑着哭i 提交于 2020-12-25 18:23:51
问题 I was just going through the .rect method of pygame in the official docs. We have 2 cases , pygame.rect.move(arg1,arg2) which is used to move a .rect object on the screen and pygame.rect.move_ip(arg1,arg2) which is , according to the docs, also used to move a .rect object on the screen but it moves it in place I didnt quite get what it means. Can anyone explain what move in place means? 回答1: "In place" means the object self . While rect.move_ip changes the pygame.Rect object itself, rect.move

Difference between rect.move() and rect.move_ip in pygame

社会主义新天地 提交于 2020-12-25 18:21:54
问题 I was just going through the .rect method of pygame in the official docs. We have 2 cases , pygame.rect.move(arg1,arg2) which is used to move a .rect object on the screen and pygame.rect.move_ip(arg1,arg2) which is , according to the docs, also used to move a .rect object on the screen but it moves it in place I didnt quite get what it means. Can anyone explain what move in place means? 回答1: "In place" means the object self . While rect.move_ip changes the pygame.Rect object itself, rect.move

How to turn the sprite in pygame while moving with the keys

拟墨画扇 提交于 2020-12-23 12:17:13
问题 So basically ive been hoping it would be possible to effectively turn your sprite while moving it around with W A S D . Any ideas because im certainly stumped, thanks! 回答1: See How do I rotate an image around its center using PyGame? for rotating a surface. If you want to rotate an image around a center point ( cx , cy ) you can just do that: rotated_car = pygame.transform.rotate(car, angle) window.blit(rotated_car, rotated_car.get_rect(center = (cx, cy)) Use pygame.math.Vector2 to store the