Merge branch 'feat/ects' into 'main'
feature: ECTS basic mechanic See merge request swd25-bootcamp/silent-fh!11
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
import pygame
|
||||
|
||||
from src.settings import START_ECTS_VALUE, ECTS_UPDATE_INTERVAL
|
||||
|
||||
class ECTS:
|
||||
def __init__(self):
|
||||
# total amount of ECTS the player has at the beginning
|
||||
self.ects_balance = 0
|
||||
# start amount of ECTS player gains ber interval at the beginning
|
||||
self.ects_per_second = START_ECTS_VALUE
|
||||
# timer when last ECTS was given to player
|
||||
self.last_update_time = pygame.time.get_ticks()
|
||||
|
||||
# check if ECTS should be added
|
||||
def update(self, is_at_desk):
|
||||
current_time = pygame.time.get_ticks()
|
||||
|
||||
# if player is at desk and interval passed
|
||||
if is_at_desk and ((current_time - self.last_update_time) >= ECTS_UPDATE_INTERVAL):
|
||||
self.ects_balance += self.ects_per_second
|
||||
# reset timer
|
||||
self.last_update_time = current_time
|
||||
|
||||
# beer increases amount of how much ECTS are earned per second
|
||||
def upgrade_rate(self, extra_ects):
|
||||
self.ects_per_second += extra_ects
|
||||
+9
-1
@@ -11,4 +11,12 @@ DOOR_BORDER_WIDTH = 3
|
||||
COLOR_DOOR_BEIGE = (245, 245, 220)
|
||||
COLOR_DOOR_BORDER = (100, 90, 80)
|
||||
COLOR_HP_BAR_GREEN = (0, 255, 0)
|
||||
COLOR_HP_BAR_BG = (50, 50, 50)
|
||||
COLOR_HP_BAR_BG = (50, 50, 50)
|
||||
|
||||
|
||||
# --- ECTS ---
|
||||
START_ECTS_VALUE = 1 # how many ECTS are generated at the beginning
|
||||
ECTS_UPDATE_INTERVAL = 1000 # time in ms = 1 sec
|
||||
|
||||
BEER_BOTTLE_ECTS_VALUE = 2
|
||||
BEER_COST = 50
|
||||
Reference in New Issue
Block a user