-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontroles.py
167 lines (157 loc) · 6.84 KB
/
controles.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#controles player 1
controle_1 = #escolha 1 kenpachi(300, 475, 64,64)
controle_2 = #escolha 2 ichigo(600, 475, 64,64)
run = True
while run:
clock.tick(24)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
keys = pygame.key.get_pressed()
if keys[pygame.K_a] and controle_1.x > controle_1.vel:
controle_1.x -= controle_1.vel
controle_1.left = True
controle_1.right = False
elif keys[pygame.K_d] and controle_1.x < 1000 - controle_1.width - controle_1.vel:
controle_1.x += controle_1.vel
controle_1.right = True
controle_1.left = False
elif keys[pygame.K_s] and controle_1.x < 1000 - controle_1.width - controle_1.vel:
controle_1.x += controle_1.vel
controle_1.right = False
controle_1.left = False
controle_1.down = True
elif keys[pygame.K_j]:
controle_1.right = False
controle_1.left = False
controle_1.weakAttack = True
controle_1.strongAttack = False
controle_1.normalAttack = True
if controle_1.hitbox[1] < ichigo.hitbox[1] + ichigo.hitbox[3] and controle_1.hitbox[1] + controle_1.hitbox[3] > ichigo.hitbox[1]:
if controle_1.hitbox[0] + controle_1.hitbox[2] > ichigo.hitbox[0] and controle_1.hitbox[0] < ichigo.hitbox[0] + ichigo.hitbox[2]:
ichigo.hit()
elif keys[pygame.K_l]:
controle_1.right = False
controle_1.left = False
controle_1.weakAttack = False
controle_1.strongAttack = False
controle_1.normalAttack = True
if controle_1.hitbox[1] < ichigo.hitbox[1] + ichigo.hitbox[3] and controle_1.hitbox[1] + controle_1.hitbox[3] > ichigo.hitbox[1]:
if controle_1.hitbox[0] + controle_1.hitbox[2] > ichigo.hitbox[0] and controle_1.hitbox[0] < ichigo.hitbox[0] + ichigo.hitbox[2]:
ichigo.hit()
elif keys[pygame.K_l]:
controle_1.right = False
controle_1.left = False
controle_1.weakAttack = False
controle_1.strongAttack = True
controle_1.normalAttack = False
if controle_1.hitbox[1] < ichigo.hitbox[1] + ichigo.hitbox[3] and controle_1.hitbox[1] + controle_1.hitbox[3] > ichigo.hitbox[1]:
if controle_1.hitbox[0] + controle_1.hitbox[2] > ichigo.hitbox[0] and controle_1.hitbox[0] < ichigo.hitbox[0] + ichigo.hitbox[2]:
ichigo.hit()
else:
if controle_1.jumpCount >= -10:
neg = 1
if controle_1.jumpCount < 0:
neg = -1
controle_1.y -= (controle_1.jumpCount ** 2) * 0.5 * neg
controle_1.jumpCount -= 1
else:
controle_1.isJump = False
controle_1.jumpCount = 10
if not(controle_1.isJump):
if keys[pygame.K_SPACE]:
controle_1.isJump = True
controle_1.right = False
controle_1.left = False
controle_1.walkCount = 0
#controle 2
keys = pygame.key.get_pressed()
if keys[pygame.K_a] and controle_1.x > controle_1.vel:
controle_1.x -= controle_1.vel
controle_1.left = True
controle_1.right = False
elif keys[pygame.K_d] and controle_1.x < 1000 - controle_1.width - controle_1.vel:
controle_1.x += controle_1.vel
controle_1.right = True
controle_1.left = False
elif keys[pygame.K_s] and controle_1.x < 1000 - controle_1.width - controle_1.vel:
controle_1.x += controle_1.vel
controle_1.right = False
controle_1.left = False
controle_1.down = True
elif keys[pygame.K_j]:
controle_2.right = False
controle_2.left = False
controle_2.weakAttack = True
controle_2.strongAttack = False
controle_2.normalAttack = True
if controle_1.hitbox[1] < ichigo.hitbox[1] + ichigo.hitbox[3] and controle_1.hitbox[1] + controle_1.hitbox[3] > ichigo.hitbox[1]:
if controle_1.hitbox[0] + controle_1.hitbox[2] > ichigo.hitbox[0] and controle_1.hitbox[0] < ichigo.hitbox[0] + ichigo.hitbox[2]:
ichigo.hit()
elif keys[pygame.K_l]:
controle_2.right = False
controle_2.left = False
controle_2.weakAttack = False
controle_2.strongAttack = False
controle_2.normalAttack = True
if controle_2.hitbox[1] < ichigo.hitbox[1] + ichigo.hitbox[3] and controle_2.hitbox[1] + controle_2.hitbox[3] > ichigo.hitbox[1]:
if controle_2.hitbox[0] + controle_2.hitbox[2] > ichigo.hitbox[0] and controle_2.hitbox[0] < ichigo.hitbox[0] + ichigo.hitbox[2]:
ichigo.hit()
elif keys[pygame.K_l]:
controle_2.right = False
controle_2.left = False
controle_2.weakAttack = False
controle_2.strongAttack = True
controle_2.normalAttack = False
if controle_2.hitbox[1] < ichigo.hitbox[1] + ichigo.hitbox[3] and controle_2.hitbox[1] + controle_2.hitbox[3] > ichigo.hitbox[1]:
if controle_2.hitbox[0] + controle_2.hitbox[2] > ichigo.hitbox[0] and controle_2.hitbox[0] < ichigo.hitbox[0] + ichigo.hitbox[2]:
ichigo.hit()
else:
if controle_2.jumpCount >= -10:
neg = 1
if controle_2.jumpCount < 0:
neg = -1
controle_2.y -= (controle_2.jumpCount ** 2) * 0.5 * neg
controle_2.jumpCount -= 1
else:
controle_2.isJump = False
controle_2.jumpCount = 10
if not(controle_2.isJump):
if keys[pygame.K_SPACE]:
controle_2.isJump = True
controle_2.right = False
controle_2.left = False
controle_2.walkCount = 0
elif keys[pygame.K_j] and controle_2.x > controle_2.vel:
controle_2.x -= controle_2.vel
controle_2.left = True
controle_2.right = False
elif keys[pygame.K_l] and ichigo.x < 1000 - ichigo.width - ichigo.vel:
controle_2.x += controle_2.vel
controle_2.right = True
controle_2.left = False
elif keys[pygame.K_w]:
controle_2.right = False
controle_2.left = False
controle_2.weakAttack = True
else:
kenpachi.right = False
kenpachi.left = False
kenpachi.weakAttack = False
kenpachi.walkCount = 0
ichigo.right = False
controle_2.left = False
controle_2.weakAttack = False
controle_2.walkCount = 0
else:
if kenpachi.jumpCount >= -10:
neg = 1
if kenpachi.jumpCount < 0:
neg = -1
kenpachi.y -= (kenpachi.jumpCount ** 2) * 0.5 * neg
kenpachi.jumpCount -= 1
else:
kenpachi.isJump = False
kenpachi.jumpCount = 10
redrawGameWindow()
pygame.quit()