View difference between Paste ID: 3UA06FmP and
SHOW:
|
|
- or go back to the newest paste.
| 1 | - | |
| 1 | + | import pygame |
| 2 | ||
| 3 | # Define colors | |
| 4 | white=[255,255,255] | |
| 5 | black=[0,0,0] | |
| 6 | blue = [0, 0, 255] | |
| 7 | ||
| 8 | # Call this function so the Pygame library can initialize itself | |
| 9 | pygame.init() | |
| 10 | ||
| 11 | # Create screen | |
| 12 | screen = pygame.display.set_mode([384, 326]) | |
| 13 | ||
| 14 | # This sets the name of the window | |
| 15 | pygame.display.set_caption('Ironing Maiden')
| |
| 16 | ||
| 17 | # Create a surface we can draw on, and one to count pixels | |
| 18 | background = pygame.Surface(screen.get_size()) | |
| 19 | drawing_surface = pygame.Surface(screen.get_size()) | |
| 20 | ||
| 21 | # Fill the screen with a black background | |
| 22 | background.fill(black) | |
| 23 | ||
| 24 | clock = pygame.time.Clock() | |
| 25 | ||
| 26 | # Before the loop, load the sounds | |
| 27 | pygame.mixer.music.load('C:\Users\Ian\Music\ironing_maiden.wav')
| |
| 28 | #pygame.mixer.music.play(-1, 0.0) | |
| 29 | ||
| 30 | # Set positions of graphics | |
| 31 | background_position=[0,0] | |
| 32 | ||
| 33 | # Load and set up graphics | |
| 34 | background_image = pygame.image.load("C:\Users\Ian\Pictures\ironingmaiden.jpg").convert()
| |
| 35 | player_image = pygame.image.load("C:\Users\Ian\Pictures\iron.png").convert()
| |
| 36 | ||
| 37 | done = False | |
| 38 | ||
| 39 | mousedown = False | |
| 40 | ||
| 41 | # Copy image to screen for background | |
| 42 | screen.blit(background_image, background_position) | |
| 43 | ||
| 44 | def win(): | |
| 45 | #Count the number of colored pixels in the drawing surface. If this number is over a threshold, | |
| 46 | #the player wins | |
| 47 | pygame.transform(drawing_surface, change_return=0) | |
| 48 | return num_threshold_pixels | |
| 49 | ||
| 50 | while done==False: | |
| 51 | clock.tick(24) | |
| 52 | ||
| 53 | for event in pygame.event.get(): | |
| 54 | if event.type == pygame.QUIT: | |
| 55 | done=True | |
| 56 | elif event.type == pygame.MOUSEBUTTONDOWN: | |
| 57 | mousedown = True | |
| 58 | elif event.type == pygame.MOUSEBUTTONUP: | |
| 59 | mousedown = False | |
| 60 | #pygame.transform.threshold(drawing_surface, blue, threshold = (0,0,0,0), diff_color = (0,0,0,255), change_return = 0, Surface = None, inverse = False) | |
| 61 | #print num_threshold_pixels | |
| 62 | ||
| 63 | if mousedown == True: | |
| 64 | pygame.draw.circle(drawing_surface,blue,((x+50),(y+50)),20) | |
| 65 | pygame.draw.circle(screen,blue,((x+50),(y+50)),20) | |
| 66 | ||
| 67 | win(); | |
| 68 | ||
| 69 | # Get the current mouse position. | |
| 70 | player_position = pygame.mouse.get_pos() | |
| 71 | x=(player_position[0]-50) | |
| 72 | y=(player_position[1]-50) | |
| 73 | ||
| 74 | # Copy cusor overlay image to screen: | |
| 75 | #screen.blit(player_image, [x,y]) | |
| 76 | #This does not work yet | |
| 77 | ||
| 78 | pygame.display.flip() | |
| 79 | ||
| 80 | pygame.quit () |