pygame

pygame.event.get() not returning any events when inside a thread

…衆ロ難τιáo~ 提交于 2021-01-29 22:56:19
问题 So I have this code that looks after the user inputs for a pac-man style game. def receiving_inputs(self): while True: events = pg.event.get() for event in events: if event.type == pg.KEYDOWN: if event.key == pg.K_UP: self.move = 'n' elif event.key == pg.K_RIGHT: self.move = 'e' elif event.key == pg.K_DOWN: self.move = 's' elif event.key == pg.K_LEFT: self.move = 'w' time.sleep(1/60) threading.Thread(target=self.receiving_inputs).start() When I press any keys on my keyboard I do not get any

pygame.event.get() not returning any events when inside a thread

青春壹個敷衍的年華 提交于 2021-01-29 22:53:46
问题 So I have this code that looks after the user inputs for a pac-man style game. def receiving_inputs(self): while True: events = pg.event.get() for event in events: if event.type == pg.KEYDOWN: if event.key == pg.K_UP: self.move = 'n' elif event.key == pg.K_RIGHT: self.move = 'e' elif event.key == pg.K_DOWN: self.move = 's' elif event.key == pg.K_LEFT: self.move = 'w' time.sleep(1/60) threading.Thread(target=self.receiving_inputs).start() When I press any keys on my keyboard I do not get any

pygame.event.get() not returning any events when inside a thread

∥☆過路亽.° 提交于 2021-01-29 22:53:12
问题 So I have this code that looks after the user inputs for a pac-man style game. def receiving_inputs(self): while True: events = pg.event.get() for event in events: if event.type == pg.KEYDOWN: if event.key == pg.K_UP: self.move = 'n' elif event.key == pg.K_RIGHT: self.move = 'e' elif event.key == pg.K_DOWN: self.move = 's' elif event.key == pg.K_LEFT: self.move = 'w' time.sleep(1/60) threading.Thread(target=self.receiving_inputs).start() When I press any keys on my keyboard I do not get any

pygame.event.get() not returning any events when inside a thread

放肆的年华 提交于 2021-01-29 22:51:58
问题 So I have this code that looks after the user inputs for a pac-man style game. def receiving_inputs(self): while True: events = pg.event.get() for event in events: if event.type == pg.KEYDOWN: if event.key == pg.K_UP: self.move = 'n' elif event.key == pg.K_RIGHT: self.move = 'e' elif event.key == pg.K_DOWN: self.move = 's' elif event.key == pg.K_LEFT: self.move = 'w' time.sleep(1/60) threading.Thread(target=self.receiving_inputs).start() When I press any keys on my keyboard I do not get any

How to make a circular object jump using pygame?

两盒软妹~` 提交于 2021-01-29 22:45:32
问题 I have just started using pygame, and I'm stuck. I'm not getting any syntax errors, but I'm sure there is some problem with the below code. import pygame import sys pygame.init() pygame.display.set_caption('Jumper Game') display_width = 500 display_height = 500 the_game_is_on = True ball_pos_x = 200 ball_pos_y = 500 ball_radius = 20 ball_color = [0,0,255] speed = 1 is_jump = False m = 1 v = 5 dis = pygame.display.set_mode((display_width,display_height)) #screen while the_game_is_on: for event

how to make image/images disappear in pygame?

自作多情 提交于 2021-01-29 22:31:05
问题 Hi i want to ask a question which has been answered a lot of times on this site but i never found an appreciable answer.How to remove the images in Pygame if there is already a background image in game window. In most of the answers,they say to use screen.fill(color) but it makes the area black.It works fine if there is no background image but with background image,it looks odd when only a certain region is colored black.How can i get rid of it?Is there an alternative way to remove the image

Is there any other way to load a resource like an image, sound, or font into Pygame? [closed]

大城市里の小女人 提交于 2021-01-29 22:30:24
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 months ago . Improve this question I am working on a game in pygame and I published some of my previous games on itch.io. When I am loading image I used to do it like this: player = pygame.image.load(r"C:\Users\user\folder\folder1\player.png") But when I publish the game, other people can't run the game. How

Pygame already installed; however, python terminal says “No module named 'pygame' ” (Ubuntu 20.04.1)

前提是你 提交于 2021-01-29 22:20:29
问题 I'm using Ubuntu 20.04.1 LTS. I have installed pygame with sudo apt-get install python-pygame . However, when I run my code using VS code, the python terminal gives the output below: Traceback (most recent call last): File "path", line 1, in <module> import pygame ModuleNotFoundError: No module named 'pygame' I tried to reinstall Pygame using the same command. Here is the output: Reading package lists... Done Building dependency tree Reading state information... Done python-pygame is already

How to make a circular object jump using pygame?

空扰寡人 提交于 2021-01-29 22:18:34
问题 I have just started using pygame, and I'm stuck. I'm not getting any syntax errors, but I'm sure there is some problem with the below code. import pygame import sys pygame.init() pygame.display.set_caption('Jumper Game') display_width = 500 display_height = 500 the_game_is_on = True ball_pos_x = 200 ball_pos_y = 500 ball_radius = 20 ball_color = [0,0,255] speed = 1 is_jump = False m = 1 v = 5 dis = pygame.display.set_mode((display_width,display_height)) #screen while the_game_is_on: for event

Is there any other way to load a resource like an image, sound, or font into Pygame? [closed]

孤街醉人 提交于 2021-01-29 22:16:14
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 months ago . Improve this question I am working on a game in pygame and I published some of my previous games on itch.io. When I am loading image I used to do it like this: player = pygame.image.load(r"C:\Users\user\folder\folder1\player.png") But when I publish the game, other people can't run the game. How