Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- # Define some colors
- BLACK = (0, 0, 0)
- WHITE = (255, 255, 255)
- GREEN = (0, 255, 0)
- RED = (255, 0, 0)
- def drow_background(screen):
- screen.fill(WHITE)
- def drow_item(screen,x,y):
- pygame.draw.rect(screen, GREEN, [0+x,0+y,30,10],0)
- pygame.draw.circle(screen, BLACK, [15+x,5+y],7,0)
- pygame.init()
- # Set the width and height of the screen [width, height]
- 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
- # Used to manage how fast the screen updates
- clock = pygame.time.Clock()
- # Main Program Loop
- while not done:
- # Main event loop
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- done = True
- drow_background(screen)
- # get the current mouse position
- pos = pygame.mouse.get_pos()
- x = pos[0]
- y = pos[1]
- # drow item
- drow_item(screen,x,y)
- # go ahead and update the screen with what we've drawn
- pygame.display.flip()
- # limit to 60 frames per second
- clock.tick(60)
- # Close the window and quit
- pygame.quit()
Add Comment
Please, Sign In to add comment