-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_2.py
More file actions
113 lines (111 loc) · 3.67 KB
/
game_2.py
File metadata and controls
113 lines (111 loc) · 3.67 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from glfw import KEY_SPACE, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_ESCAPE
from pyray import *
import time
init_window(900, 900, "Ejemplo de movimiento")
x = 400
y = 225
condition = -1
while not window_should_close():
begin_drawing()
draw_rectangle(x, y, 50, 50, GREEN)
if is_key_pressed(KEY_UP) or condition == 0:
condition = 0
while condition == 0:
clear_background(BLACK)
y -= 4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
if is_key_pressed(KEY_UP):
condition = 0
if is_key_pressed(KEY_DOWN):
condition = 1
if is_key_pressed(KEY_LEFT):
condition = 2
if is_key_pressed(KEY_RIGHT):
condition = 3
if is_key_pressed(KEY_SPACE):
condition = 4
if is_key_pressed(KEY_ESCAPE):
close_window()
if is_key_pressed(KEY_DOWN) or condition == 1:
condition = 1
while condition == 1:
clear_background(BLACK)
y += 4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
if is_key_pressed(KEY_UP):
condition = 0
if is_key_pressed(KEY_DOWN):
condition = 1
if is_key_pressed(KEY_LEFT):
condition = 2
if is_key_pressed(KEY_RIGHT):
condition = 3
if is_key_pressed(KEY_SPACE):
condition = 4
if is_key_pressed(KEY_ESCAPE):
close_window()
if is_key_pressed(KEY_LEFT) or condition == 2:
condition = 2
while condition == 2:
clear_background(BLACK)
x -= 4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
if is_key_pressed(KEY_UP):
condition = 0
if is_key_pressed(KEY_DOWN):
condition = 1
if is_key_pressed(KEY_LEFT):
condition = 2
if is_key_pressed(KEY_RIGHT):
condition = 3
if is_key_pressed(KEY_SPACE):
condition = 4
if is_key_pressed(KEY_ESCAPE):
close_window()
if is_key_pressed(KEY_RIGHT) or condition == 3:
condition = 3
while condition == 3:
clear_background(BLACK)
x += 4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
if is_key_pressed(KEY_UP):
condition = 0
if is_key_pressed(KEY_DOWN):
condition = 1
if is_key_pressed(KEY_LEFT):
condition = 2
if is_key_pressed(KEY_RIGHT):
condition = 3
if is_key_pressed(KEY_SPACE):
condition = 4
if is_key_pressed(KEY_ESCAPE):
close_window()
if is_key_pressed(KEY_SPACE) or condition == 4:
condition = 4
while condition == 4:
clear_background(BLACK)
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
if is_key_pressed(KEY_UP):
condition = 0
if is_key_pressed(KEY_DOWN):
condition = 1
if is_key_pressed(KEY_LEFT):
condition = 2
if is_key_pressed(KEY_RIGHT):
condition = 3
if is_key_pressed(KEY_SPACE):
condition = 4
if is_key_pressed(KEY_ESCAPE):
close_window()
end_drawing()
close_window()