-
Notifications
You must be signed in to change notification settings - Fork 0
/
Keyboard_Controls.py
152 lines (137 loc) · 5.63 KB
/
Keyboard_Controls.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import pygame
from utils
pressed = pygame.key.get_pressed() #If something is pressed...
if IDO.get_key(pygame.K_RIGHT): #If the right arrow key is pressed down...
if PhaseFocus == 0 or PhaseFocus == 2: #and If the current Phase is 0 or 2
Reticlex +=1 # Move the reticle to the right by 1 square value
#Character.animation_dir =
if Currently_Selected != 0 and Currently_Selected.Phase == 2: #If you're already moving something...
#Char_Animation()
#Currently_Selected.animation_dir = RunRightAnimation
if Currently_Selected.x != Reticlex: #And if the reticle's x position and character's x position isn't the same...
Currently_Selected.x = Reticlex #Make it the same
if Currently_Selected.x != Reticley: # And if the reticle's y position and the chatacter's y position isn't the same...
Currently_Selected.y = Reticley #Make it the same
if IDO.get_key(pygame.K_LEFT): # if the left key is pressed...
if PhaseFocus == 0 or PhaseFocus == 2:
Reticlex -=1
if Currently_Selected != 0 and Currently_Selected.Phase == 2:
#Char_Animation()
#Currently_Selected.animation_dir = RunLeftAnimation
if Currently_Selected.x != Reticlex:
Currently_Selected.x = Reticlex
if Currently_Selected.x != Reticley:
Currently_Selected.y = Reticley
if IDO.get_key(pygame.K_UP):
if PhaseFocus == 0 or PhaseFocus == 2:
Reticley -=1
if Currently_Selected != 0 and Currently_Selected.Phase == 2:
if Currently_Selected.x != Reticlex:
Currently_Selected.x = Reticlex
if Currently_Selected.x != Reticley:
Currently_Selected.y = Reticley
if PhaseFocus == 1 and Currently_Focused_Menu != 0:
Currently_Focused_Menu.move_cursor_up()
if IDO.get_key(pygame.K_DOWN):
if PhaseFocus == 0 or PhaseFocus == 2:
Reticley +=1
if Currently_Selected != 0 and Currently_Selected.Phase == 2:
#Char_Animation()
#Currently_Selected.animation_dir = RunDownAnimation
if Currently_Selected.x != Reticlex:
Currently_Selected.x = Reticlex
if Currently_Selected.x != Reticley:
Currently_Selected.y = Reticley
if PhaseFocus == 1 and Currently_Focused_Menu != 0 and Currently_Focused_Menu != None:
Currently_Focused_Menu.move_cursor_down()
if IBO.get_key(pygame.K_z):
for c in chars:
if Reticlex == c.x and Reticley == c.y and c.Phase == 1 and c.team == "Ally" and Currently_Selected == 0 and c.Activity == c.Maxact:
Currently_Selected = c
Currently_Selected.StoredPositionx = Currently_Selected.x
Currently_Selected.StoredPositiony = Currently_Selected.y
c.StoredActivity = c.Activity
c.Phase = 2
if PhaseFocus == 1 and c.Phase == 3:
ret = Currently_Focused_Menu.select(c)
if ret != -1 and not isinstance(ret, Weapon) and not isinstance(ret, Item) and not isinstance(ret, AOEItem) and not isinstance(ret, EndTurn):# and ret != -3:
Currently_Focused_Menu = ret
if isinstance(ret, Weapon) or isinstance(ret, Item) or isinstance(ret, AOEItem):
if isinstance(ret, Weapon):
Currently_Selected.Weapon = ret
if isinstance(ret, Item):
ret.offset = utils.get_offset_of_all_units(chars, c)
selectable_positions = get_positions_around_reticle((c.x, c.y), ret.offsets)
c.Phase = 4
selected_usable = ret
PhaseFocus = 2
if isinstance(ret, EndTurn):
ret.use(Currently_Selected)
PhaseFocus = 0
Currently_Selected = 0
Currently_Focused_Menu = Actions
if c.Phase == 4:
tile = (Reticlex, Reticley)
if tile in selectable_positions:
if isinstance(ret, AOEItem):
# [PLANT USE ITEMS]
newentity = selected_usable.use((Reticlex, Reticley))
entities.append(newentity)
Currently_Focused_Menu = Actions
if Currently_Selected.Phase == 4:
Currently_Selected.Phase = 1
Currently_Selected = 0
selected_usable = None
selectable_positions = []
else:
# [SINGLE USE ITEMS]
for char in chars:
if char.x == Reticlex and char.y == Reticley:
if isinstance(ret, Weapon) and char.team == "Enemy":
if selected_usable.ActivityDrain <= Currently_Selected.Activity:
selected_usable.use(char, Currently_Selected)
if isinstance(ret, Item) and char.team == "Ally":
selected_usable.use(char)
Currently_Focused_Menu = Actions
if Currently_Selected.Phase == 4:
Currently_Selected.Phase = 1
Currently_Selected = 0
selected_usable = None
selectable_positions = []
PhaseFocus = 0
if IBO.get_key(pygame.K_x) and not IBO.get_key(pygame.K_z):
if Currently_Selected != 0:
selectable_positions = []
if Currently_Selected.Phase == 3 and Currently_Focused_Menu == Actions:
Currently_Selected.Phase = 1
Currently_Selected.x = Currently_Selected.StoredPositionx
Currently_Selected.y = Currently_Selected.StoredPositiony
Currently_Selected = 0
PhaseFocus = 0
for c in chars:
c.Activity = c.StoredActivity
elif Currently_Selected.Phase == 4 or Currently_Selected.Phase == 2:
PhaseFocus = 1
Currently_Selected.Phase = 3
else:
Currently_Selected.Phase = 3
if PhaseFocus == 1 and isinstance(Currently_Selected, Character) and Currently_Selected.Phase == 3:
Currently_Focused_Menu = Currently_Focused_Menu.above
if Currently_Focused_Menu == None:
Currently_Focused_Menu = Actions
if IBO.get_key(pygame.K_ESCAPE):
pygame.mixer.Sound.play(QuitSound)
pygame.mixer.Sound.set_volume(Volume)
pygame.mixer.music.stop()
screen.blit(SaveText, (200,200))
pygame.display.flip()
pygame.time.wait(420)
for i in range(10, 210, 10):
blit_alpha(screen, bLaCksCrEEn, (0,0), i)
pygame.display.flip()
pygame.time.wait(20)
exit()
if IBO.get_key(pygame.K_a):
Pause(Paused, PhaseFocus, Pause_Screen, screen, True)
if IBO.get_key(pygame.K_s):
Pause(Paused, PhaseFocus, Pause_Screen, screen, False)