-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevice.py
115 lines (96 loc) · 3.71 KB
/
device.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
print('Loading Sound and Video')
import pygame
import var
import datetime
import defaults as df
import os
version = df.version
print('version:',version)
class AddWin():
def _init_(self):
pygame.init()
pygame.display.set_caption('Zombie Pan '+ version)
class AddSound(AddWin):
def __init__(self):
AddWin._init_(self)
pygame.mixer.pre_init(frequency=44100, size=-32, channels=2, buffer=4096)
pygame.init()
assetsDir = var.assetsDir
if not os.path.isfile(assetsDir + 'comical_liquid_gel_splat.ogg'):
print('ERROR No Sound exist in ', assetsDir + 'comical_liquid_gel_splat.ogg')
else:
print('file exists')
# self.sound_col = pygame.mixer.Sound(file=assetsDir + 'comical_liquid_gel_splat.ogg')
# self.sound_col.set_volume(0.5)
self.sound_err = pygame.mixer.Sound(file=assetsDir + 'sounds/327736__distillerystudio__error-03.ogg')
self.sound_err.set_volume(0.5)
self.sound_loser = pygame.mixer.Sound(file=assetsDir + '113988__kastenfrosch__verloren.ogg')
self.sound_loser.set_volume(0.5)
self.sound_winer = pygame.mixer.Sound(file=assetsDir + '270528littlerobotsoundfactoryjingle-win-00.ogg')
self.sound_winer.set_volume(0.5)
# self.sound_bullet = pygame.mixer.Sound(file=self.sound_bullet_file)
# self.sound_bullet.set_volume(0.5)
self.music_enabled = True
self.sound_enabled = True
self.music_theme = var.assetsDir + ""
# self.sound_attack = pygame.mixer.Sound(file=assetsDir + 'Zombie Gets Attacked-SoundBible.com-20348330.wav')
self.sound_glass_break = pygame.mixer.Sound(file=assetsDir + 'sounds/338692__natemarler__glass-break-small_short.wav')
print('sound created')
# def play_music(self):
#
# if self.music_enabled:
# print('device:music enabled')
# if pygame.mixer.music.get_busy():
# pygame.mixer.stop()
#
# pygame.mixer.music.load(self.music_theme)
# pygame.mixer.music.play(-1)
# pygame.mixer.music.set_volume(0.5)
#
# else:
# print('device:music disabled')
# pygame.mixer.music.pause()
# pygame.mixer.music.stop()
class Ranking():
def __init__(self):
self.experience = 0
self.respawn = 0
self.killed = 0
self.shelter = 100
self.damage = 0
self.level = 0
self.life = 100
self.damage = 0
print('instance of Ranking')
self.map_name = ''
self.map = ''
self.total = 0
self.winner = False
self.maps = []
self.default_bullets_avaiable = 100
self.bullet_available = self.default_bullets_avaiable
self.dead_player = False
def add_damage(self, damage_rate):
self.damage += damage_rate
self.life -= damage_rate
# print('Damage', round(self.damage, 0), int(self.life))
def add_kill(self):
self.killed += 1
self.experience += 1
def new_level(self):
self.killed = 0
self.damage = 0
if self.life <= 0:
self.life = 100
def end_level(self):
if self.dead_player:
print('End Level', round(self.damage, 1), int(self.life))
self.dead_player = False #to start gaing as a alive player
return True
if self.killed == self.total:
if datetime.datetime.now() - df.dead_time > datetime.timedelta(seconds=df.delay):
return True
return False
return False
stats = Ranking()
audio = AddSound()