Reputation: 1
I am just learning how to use pygame. But whenever I run the code, it doesn't run but a python rocket appears and starts bouncing. The only thing I can do on the rocket is force quit. My python is 3.8.2 and pygame is 1.9.6, on my mac, if it helps. This is the code I'm trying to run, just a basic set up 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.event.get():
if event.type == pygame.QUIT:
run = False
pygame.draw.rect(win, (255, 0, 0), (x, y, width, height))
pygame.display.update()
pygame.quit()
Upvotes: 0
Views: 506
Reputation: 11913
Jubin- I just ran your code on Mac and it works. I think the trouble is that IDLE won't allow it to run for some reason.
Try running it from the command line using Terminal app. It runs fine for me doing that, but will not run from IDLE.
Upvotes: 0
Reputation: 4373
I just ran your code using python 3.7 on a macbook Mojave and I just got a red rectangle (like your code specifies) in one position. Possibly try restarting your computer, checking you version of python, or renaming the file (originally I named the file pygame and it was giving me a bunch of issues) to make it run the correct thing.
Upvotes: 0