-
Notifications
You must be signed in to change notification settings - Fork 22
/
game.py
35 lines (27 loc) · 740 Bytes
/
game.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
# http://ocw.cs.pub.ro/courses/programare/laboratoare/python#exercitii
import pygame
from pygame.locals import *
w_size = 400
h_size = 400
screen = pygame.display.set_mode((w_size, h_size), DOUBLEBUF)
blue_color = (0, 0, 255)
black_color = (0, 0, 0)
p_x = 10
p_y = 200
radius = 20
running = True
increment = False
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == KEYDOWN:
if event.key == K_RIGHT:
increment = True
if increment:
p_x = p_x + 1
position = [p_x, p_y]
screen.fill(black_color)
pygame.draw.circle(screen, blue_color, position, radius)
pygame.display.flip()
pygame.quit()