clocks
This commit is contained in:
parent
80d7ebf7eb
commit
cedb02e77e
5 changed files with 110 additions and 90 deletions
37
cave_survival/daylightcycle.py
Normal file
37
cave_survival/daylightcycle.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import pygame
|
||||
|
||||
from cave_survival.config import config
|
||||
from cave_survival.console import console
|
||||
|
||||
|
||||
class DayLightCycle:
|
||||
def __init__(self, game):
|
||||
self.game = game
|
||||
self.console = console
|
||||
self.day_length = config.day_length
|
||||
self.day_timer = 0
|
||||
|
||||
@property
|
||||
def game_time(self):
|
||||
return pygame.time.get_ticks() / self.day_length
|
||||
|
||||
@property
|
||||
def days(self):
|
||||
return int(self.game_time)
|
||||
|
||||
@property
|
||||
def time(self):
|
||||
return self.game_time - self.days
|
||||
|
||||
def draw(self):
|
||||
|
||||
pygame.draw.rect(
|
||||
self.game.screen,
|
||||
config.GREY,
|
||||
(
|
||||
0,
|
||||
0,
|
||||
self.time * config.screen_width,
|
||||
10,
|
||||
),
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue