-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpygame_tutorial_0.py
50 lines (31 loc) · 968 Bytes
/
pygame_tutorial_0.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
'''
Draws a rectangle to the screen
'''
# IMPORTS
import sys
import pygame
# INITIALIZE PYGAME
pygame.init()
# CREATE THE SCREEN -------------------------------
# width, height
screen = pygame.display.set_mode((400, 300))
# red, green, blue
screen.fill( (100, 100, 200) )
# ADD A RECTANGLE ---------------------------------
# width, height
my_shape = pygame.Surface((100, 50))
# red, green, blue
my_shape.fill( (0, 0, 255) )
my_shape_rect = my_shape.get_rect()
# x, y
my_shape_rect.topleft = (200,150)
# DISPLAY IT ALL ----------------------------------
# what? , where?
screen.blit(my_shape, my_shape_rect)
pygame.display.update()
# RUN THE GAME ------------------------------------
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()