File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,8 @@ def draw(self, win):
86
86
87
87
def hit (self ):
88
88
# this is resetting the char after a hit and shows it as standing
89
+ self .isJump = False
90
+ self .jumpCount = 10
89
91
self .x = 60
90
92
self .y = 410
91
93
self .walkCount = 0
@@ -228,14 +230,8 @@ def redrawGameWindow():
228
230
playSeconds = 20
229
231
230
232
while running :
231
-
232
233
clock .tick (27 )
233
234
234
- if shootLoop > 0 :
235
- shootLoop += 1
236
- if shootLoop > 3 :
237
- shootLoop = 0
238
-
239
235
for event in pygame .event .get ():
240
236
if event .type == pygame .QUIT :
241
237
running = False
@@ -245,12 +241,20 @@ def redrawGameWindow():
245
241
if playSeconds == 0 :
246
242
print ("Time's up!" )
247
243
running = False
248
- # the char collides with the goblin, calculated via the hitboxes, 5 hitnumber is deducted for every collision
249
- if small_guy .hitbox [1 ] < goblin .hitbox [1 ] + goblin .hitbox [3 ] and small_guy .hitbox [1 ] + small_guy .hitbox [3 ] > goblin .hitbox [1 ]:
250
- if small_guy .hitbox [0 ] + small_guy .hitbox [2 ] > goblin .hitbox [0 ] and small_guy .hitbox [0 ] < goblin .hitbox [0 ] + goblin .hitbox [2 ]:
251
- small_guy .hit ()
252
- hitNumber -= 5
253
244
245
+ # the goblin collides with little guy ONLY when it is visible (= not destroyed yet)
246
+ if goblin .visible == True :
247
+ # the char collides with the goblin, calculated via the hitboxes, 5 hitnumber is deducted for every collision
248
+ if small_guy .hitbox [1 ] < goblin .hitbox [1 ] + goblin .hitbox [3 ] and small_guy .hitbox [1 ] + small_guy .hitbox [3 ] > goblin .hitbox [1 ]:
249
+ if small_guy .hitbox [0 ] + small_guy .hitbox [2 ] > goblin .hitbox [0 ] and small_guy .hitbox [0 ] < goblin .hitbox [0 ] + goblin .hitbox [2 ]:
250
+ small_guy .hit ()
251
+ hitNumber -= 5
252
+
253
+ if shootLoop > 0 :
254
+ shootLoop += 1
255
+ if shootLoop > 3 :
256
+ shootLoop = 0
257
+
254
258
for bullet in bullets :
255
259
# check if bullet is in hitbox: check top and bottom of hitbox rectangle
256
260
if bullet .y - bullet .radius < goblin .hitbox [1 ] + goblin .hitbox [3 ] and bullet .y + bullet .radius > goblin .hitbox [1 ]:
You can’t perform that action at this time.
0 commit comments