generated from mwc/project_game
23 lines
527 B
Python
23 lines
527 B
Python
(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 |