-
Notifications
You must be signed in to change notification settings - Fork 1
/
coins.py
51 lines (35 loc) · 803 Bytes
/
coins.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sound
import config
__credit = 0
__life_to_credit_ratio = 3
__lives = 0
def consume_coin():
"""resets credit and returns amount of lives to add in-game"""
global __credit
global __lives
if __credit > 0:
__lives = __life_to_credit_ratio
__credit -= 1
def get_credit():
"""returns credit amount without resetting"""
return __credit
def add_coin():
global __credit
__credit += 1
sound.sfx_lib.get('coin').play()
def get_lives():
return __lives
def add_life(add=1):
global __lives
__lives += add
def lose_life():
global __lives
__lives -= 1
if __lives < 0:
__lives = 0
def handle_free_mode():
global __credit
if not config.FREE_MODE:
return
if __credit <= 0:
__credit = 1