-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoolrpg.py
More file actions
70 lines (56 loc) · 1.82 KB
/
coolrpg.py
File metadata and controls
70 lines (56 loc) · 1.82 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import pygame
pygame.init()
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
mode = "overworld"
x = 50
y = 50
speedX = 0
speedY = 0
lx = 50
screen = pygame.display.set_mode((700, 500))
pygame.display.set_caption("Rpg prototype")
done = False
clock = pygame.time.Clock()
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if(mode == "overworld"):
if event.type == pygame.KEYDOWN:
# key is pressed down
if event.key == pygame.K_DOWN:
speedY = 6
if event.key == pygame.K_UP:
speedY = -6
if event.key == pygame.K_RIGHT:
speedX = 6
if event.key == pygame.K_LEFT:
speedX = -6
elif event.type == pygame.KEYUP:
# key is let up
# "and speedX == 6" is to prevent stopping movement while another key is pressed
if event.key == pygame.K_DOWN and speedY == 6:
speedY = 0
elif event.key == pygame.K_UP and speedY == -6:
speedY = 0
elif event.key == pygame.K_RIGHT and speedX == 6:
speedX = 0
elif event.key == pygame.K_LEFT and speedX == -6:
speedX = 0
screen.fill((0, 0, 0))
x += speedX
y += speedY
# Beginning of Drawing
pygame.draw.rect(screen, WHITE, [x, y, 50, 50])
f = open("test.txt")
for line in f:
# print(repr(line))
if line == "hs\n":
lx += 1
pygame.draw.rect(screen, RED, [lx, 50, 10, 10])
# End of Drawing
pygame.display.flip()
clock.tick(60)
pygame.quit()