-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path05_gameten_moving.py
63 lines (44 loc) · 1.04 KB
/
05_gameten_moving.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
# Gameten-Simulation
# MBS Digitalwerkstatt
#import random
import pygame, sys
from pygame.locals import *
pygame.init()
fps = pygame.time.Clock()
#colors
WHITE = (255,255,255)
RED = (255,0,0)
GREEN = (0,255,0)
BLACK = (0,0,0)
#globals
WIDTH = 800
HEIGHT = 600
GAMET_RADIUS = 20
gamet_pos = [0,0]
#canvas declaration
window = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
pygame.display.set_caption('Gameten Simulation')
gamet_pos = [WIDTH/4, HEIGHT/4]
#update positions
def update_pos():
global gamet_pos
#update gamet pos
gamet_pos[0] += 0.5
gamet_pos[1] += 0.5
#draw function of canvas
def draw(canvas):
global gamet_pos, gamet_vel
canvas.fill(BLACK)
#draw gamet
pygame.draw.circle(canvas, RED,
[int(gamet_pos[0]), int(gamet_pos[1])], 20, 0)
#main game loop
while True:
update_pos()
draw(window)
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fps.tick(60)