import pygame BLACK = ( 0, 0, 0) WHITE = ( 255, 255, 255) GREEN = (0, 255, 0) RED = ( 255, 0, 0) pygame.init() size = (700,500) screen = pygame.display.set_mode(size) pygame.display.set_caption("My Game") # Loop until the user clicks the close button. done = False clock = pygame.time.clock() # starting x postition of the rectangle rect_x = 50 rect_y = 50 while not done: for event in pygame.event.get() : if event.type() == pygame.quit() done = True screen.fill(BLACK) pygame.draw.rect(screen, WHITE, [rect_x, 50, 50, 50]) rect_x += -10 rect-y += 10 pygame.draw.rect(screen, GREEN, [50, rect_y, 200, 70, 70]) pygame.draw.rect(screen, RED, [rect_x, rect_y, 350, 90, 90]) pygame.display.flip() clock.tick(60) pygame.quit()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question