- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_2.py
More file actions
Latest commit
113 lines (111 loc) · 3.67 KB
/
Copy pathgame_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
fromglfwimportKEY_SPACE, KEY_RIGHT, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_ESCAPE
frompyrayimport*
importtime
init_window(900, 900, "Ejemplo de movimiento")
x=400
y=225
condition=-1
whilenotwindow_should_close():
begin_drawing()
draw_rectangle(x, y, 50, 50, GREEN)
ifis_key_pressed(KEY_UP) orcondition==0:
condition=0
whilecondition==0:
clear_background(BLACK)
y-=4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
ifis_key_pressed(KEY_UP):
condition=0
ifis_key_pressed(KEY_DOWN):
condition=1
ifis_key_pressed(KEY_LEFT):
condition=2
ifis_key_pressed(KEY_RIGHT):
condition=3
ifis_key_pressed(KEY_SPACE):
condition=4
ifis_key_pressed(KEY_ESCAPE):
close_window()
ifis_key_pressed(KEY_DOWN) orcondition==1:
condition=1
whilecondition==1:
clear_background(BLACK)
y+=4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
ifis_key_pressed(KEY_UP):
condition=0
ifis_key_pressed(KEY_DOWN):
condition=1
ifis_key_pressed(KEY_LEFT):
condition=2
ifis_key_pressed(KEY_RIGHT):
condition=3
ifis_key_pressed(KEY_SPACE):
condition=4
ifis_key_pressed(KEY_ESCAPE):
close_window()
ifis_key_pressed(KEY_LEFT) orcondition==2:
condition=2
whilecondition==2:
clear_background(BLACK)
x-=4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
ifis_key_pressed(KEY_UP):
condition=0
ifis_key_pressed(KEY_DOWN):
condition=1
ifis_key_pressed(KEY_LEFT):
condition=2
ifis_key_pressed(KEY_RIGHT):
condition=3
ifis_key_pressed(KEY_SPACE):
condition=4
ifis_key_pressed(KEY_ESCAPE):
close_window()
ifis_key_pressed(KEY_RIGHT) orcondition==3:
condition=3
whilecondition==3:
clear_background(BLACK)
x+=4
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
ifis_key_pressed(KEY_UP):
condition=0
ifis_key_pressed(KEY_DOWN):
condition=1
ifis_key_pressed(KEY_LEFT):
condition=2
ifis_key_pressed(KEY_RIGHT):
condition=3
ifis_key_pressed(KEY_SPACE):
condition=4
ifis_key_pressed(KEY_ESCAPE):
close_window()
ifis_key_pressed(KEY_SPACE) orcondition==4:
condition=4
whilecondition==4:
clear_background(BLACK)
draw_rectangle(x, y, 50, 50, GREEN)
end_drawing()
time.sleep(0.045)
ifis_key_pressed(KEY_UP):
condition=0
ifis_key_pressed(KEY_DOWN):
condition=1
ifis_key_pressed(KEY_LEFT):
condition=2
ifis_key_pressed(KEY_RIGHT):
condition=3
ifis_key_pressed(KEY_SPACE):
condition=4
ifis_key_pressed(KEY_ESCAPE):
close_window()
end_drawing()
close_window()