repl.it
@DanielDoucette/

PyGameFunctions1.py

Pygame

No description

fork
loading
Files
  • main.py
  • nohup.out
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
 Sample Python/Pygame Programs
 Simpson College Computer Science
 http://programarcadegames.com/
 http://simpson.edu/computer-science/
 
 Explanation video: http://youtu.be/_XdrKSDmzqA
 
"""
 
# Import a library of functions called 'pygame'
import pygame

PI = 3.141592653
 
 
def draw_happy(screen, x, y):
    """ --- Function for a snowman ---
    Define a function that will draw a snowman at a certain location.
    """
    #Head
    pygame.draw.ellipse(screen, yellow, [0 + x, 0 + y, 120, 120])
    #eyes
    pygame.draw.ellipse(screen, BLACK, [25 + x, 25 + y, 25, 15])
    pygame.draw.ellipse(screen, BLACK, [70 + x, 25 + y, 25, 15])
    #smile
    pygame.draw.arc(screen, BLACK,   [15 + x,50 + y,90,50],PI,   2*PI, 5)
   
    
 
# Initialize the game engine
pygame.init()
 
# Define the colors we will use in RGB format
BLACK = [0, 0, 0]
WHITE = [255, 255, 255]
orange = [255,165,0]
brown = [139,69,19]
yellow = [255,255,0]

# Set the height and width of the screen
size = [500, 500]
screen = pygame.display.set_mode(size)
 
# Loop until the user clicks the close button.
done = False
clock = pygame.time.Clock()
 
while not done:
 
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
 
    # Clear the screen and set the screen background
    screen.fill(BLACK)
 
    # Happy in upper left
    draw_happy(screen, 10, 10)
 
    # Happy in upper right
    draw_happy(screen, 370, 10)
 
    # happy in lower left
    draw_happy(screen, 10, 370)

    # Happy in lower right
    draw_happy(screen,370, 370)

 
    # Go ahead and update the screen with what we've drawn.
    # This MUST happen after all the other drawing commands.
    pygame.display.flip()
 
    # This limits the while loop to a max of 60 times per second.
    # Leave this out and we will use all CPU we can.
    clock.tick(60)
 
 
# Be IDLE friendly
pygame.quit()