-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe.py
50 lines (39 loc) · 1.22 KB
/
frame.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
import pygame
import sys
from main import map,hero
M = map(10,10)
hero = hero(M)
WIN_WIDTH = 200
WIN_HEIGHT = 100
pygame.init()
pygame.display.set_mode((600, 400))
clock = pygame.time.Clock()
sc = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
while not hero.win:
p = hero.print()
if p[0] == 0:
pygame.draw.rect(sc, (255, 255, 255), (0, 0, 100, 100))
elif p[0] == 1:
pygame.draw.rect(sc, (0, 0, 0), (0, 0, 100, 100))
elif p[0] == 2:
pygame.draw.rect(sc, (255,20,147), (0, 0, 100, 100))
elif p[0] == 3:
pygame.draw.rect(sc, (p[1], 0, 0), (0, 0, 100, 100))
elif p[0] == 4:
pygame.draw.rect(sc, (255, 255, 0), (0, 0, 100, 100))
if p[2] == 1:
pygame.draw.rect(sc, (0, p[3], 0), (100, 0, 200, 100))
else:
pygame.draw.rect(sc, (p[3], p[3], 0), (100, 0, 200, 100))
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
hero.command(0)
elif event.key == pygame.K_RIGHT:
hero.command(1)
pygame.display.update()
clock.tick(60)