-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
52 lines (44 loc) · 1.22 KB
/
run.py
File metadata and controls
52 lines (44 loc) · 1.22 KB
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
from configurations import *
from color import *
import pygame
import sys
all_sprites = pygame.sprite.Group()
# this function handle game initlization stuff
def initGame():
x = pygame.init()
print x
screen = pygame.display.set_mode((window_width,window_hight))
pygame.display.set_caption("pool game")
# it handles game speed
clock = pygame.time.Clock()
# Game loop
count = 0 #delete
x,y = 0,0
game_running_flag = True
while game_running_flag:
# keep loop running at right speed
clock.tick(fps)
# process input (events)
for event in pygame.event.get():
# check for closing window (event)
if event.type == pygame.QUIT:
game_running_flag = False
# Update
pygame.draw.rect(screen,randomColors[count],[x,y,200,200])
all_sprites.update(screen)
count += 1
x += 5
y += 5
if x > 1300:
x = 0
y = 0
if count > len(randomColors):
count = 0
# Draw / Render
# after drowing everything flip the display
pygame.display.flip()
# closing window
pygame.display.quit()
pygame.quit()
sys.exit()
initGame()