Skip to content

Commit 2cfe571

Browse files
committed
Steal game from ACS
1 parent b46279a commit 2cfe571

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

game.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# http://ocw.cs.pub.ro/courses/programare/laboratoare/python#exercitii
2+
3+
import pygame
4+
from pygame.locals import *
5+
6+
w_size = 400
7+
h_size = 400
8+
screen = pygame.display.set_mode((w_size, h_size), DOUBLEBUF)
9+
10+
blue_color = (0, 0, 255)
11+
black_color = (0, 0, 0)
12+
p_x = 10
13+
p_y = 200
14+
radius = 20
15+
16+
running = True
17+
increment = False
18+
while running:
19+
for event in pygame.event.get():
20+
if event.type == pygame.QUIT:
21+
running = False
22+
if event.type == KEYDOWN:
23+
if event.key == K_RIGHT:
24+
increment = True
25+
26+
if increment:
27+
p_x = p_x + 1
28+
29+
position = [p_x, p_y]
30+
31+
screen.fill(black_color)
32+
pygame.draw.circle(screen, blue_color, position, radius)
33+
pygame.display.flip()
34+
35+
pygame.quit()

0 commit comments

Comments
 (0)