generated from mwc/project_game
@chris need helo wuth health
This commit is contained in:
23
point_system.py
Normal file
23
point_system.py
Normal file
@@ -0,0 +1,23 @@
|
||||
(update)
|
||||
|
||||
score = 100
|
||||
|
||||
player_rect = pygame.Rect(50, 50, 40, 40)
|
||||
obstacle_rect = pygame.Rect(200, 50, 40, 40)
|
||||
|
||||
if player_rect.colliderect(obstacle_rect):
|
||||
score -= 10
|
||||
|
||||
can_lose_points = True
|
||||
cooldowm_time = 1000 #miliseconds
|
||||
last_hit_time = 0
|
||||
|
||||
current_time = pygame.time.get.ticks()
|
||||
|
||||
if player_rect.colliderect(obstacle_rect) and can_lose_points:
|
||||
score -= 10
|
||||
can_lose_points = False
|
||||
last_hit_time = current_time
|
||||
|
||||
if not can_lose_points and current_time - last_hit_time > cooldown_time:
|
||||
can_lose_points = True
|
||||
Reference in New Issue
Block a user