Compare commits
2 Commits
48c083d3ff
...
03b22cc3af
Author | SHA1 | Date |
---|---|---|
theo@manjaro | 03b22cc3af | |
theo@manjaro | 9fcefe7030 |
|
@ -20,7 +20,6 @@ class Game():
|
|||
self.logs = []
|
||||
|
||||
self.running = True
|
||||
self.init_inputs()
|
||||
self.gameloop = gameloop.GameLoop() # Je crée une boucle de jeu
|
||||
def load_image(filename):
|
||||
return pygame.image.load(filename).convert_alpha()
|
||||
|
@ -90,12 +89,13 @@ class Game():
|
|||
self.globals["scamerax"] = 0
|
||||
self.globals["scameray"] = 0
|
||||
self.globals["players"] = []
|
||||
self.globals["hitpose"] = False
|
||||
self.globals["AZERTY"] = True
|
||||
self.globals["pause"] = False
|
||||
self.globals["finishedlevels"] = [] # Levels where the player went to the end
|
||||
self.globals["completedlevels"] = [] # Levels where the player kicked all non-respawnable ennemies
|
||||
self.globals["speedrunlevels"] = [] # Levels where the player finished fast enough
|
||||
self.globals["allunlocked"] = True
|
||||
self.init_inputs()
|
||||
self.scaleCamera()
|
||||
|
||||
settings = {"sfx":1,"bgm":0.2}
|
||||
|
@ -150,42 +150,38 @@ class Game():
|
|||
self.inputs = {}
|
||||
self.inputs["keys"] = {
|
||||
"escape":{
|
||||
"timer" : 0, # Timer de la touche
|
||||
"realtime" : 0, # Temps réel préssé
|
||||
"pressed" : False,
|
||||
"counted" : False,
|
||||
"keycode" : pygame.K_ESCAPE # Code pygame de la touche en question
|
||||
"keycode" : [pygame.K_ESCAPE,pygame.K_RETURN] # Code pygame de la touche en question
|
||||
},
|
||||
"left":{
|
||||
"timer" : 0, # Timer de la touche
|
||||
"realtime" : 0, # Temps réel préssé
|
||||
"pressed" : False,
|
||||
"counted" : False,
|
||||
"keycode" : pygame.K_q # Code pygame de la touche en question
|
||||
"keycode" : [pygame.K_LEFT] # Code pygame de la touche en question
|
||||
},
|
||||
"right":{
|
||||
"timer" : 0, # Timer de la touche
|
||||
"realtime" : 0, # Temps réel préssé
|
||||
"pressed" : False,
|
||||
"counted" : False,
|
||||
"keycode" : pygame.K_d # Code pygame de la touche en question
|
||||
"keycode" : [pygame.K_RIGHT] # Code pygame de la touche en question
|
||||
},
|
||||
"up":{
|
||||
"timer" : 0, # Timer de la touche
|
||||
"realtime" : 0, # Temps réel préssé
|
||||
"pressed" : False,
|
||||
"counted" : False,
|
||||
"keycode" : pygame.K_z # Code pygame de la touche en question
|
||||
"keycode" : [pygame.K_SPACE,pygame.K_UP] # Code pygame de la touche en question
|
||||
},
|
||||
"down":{
|
||||
"timer" : 0, # Timer de la touche
|
||||
"realtime" : 0, # Temps réel préssé
|
||||
"pressed" : False,
|
||||
"counted" : False,
|
||||
"keycode" : pygame.K_s # Code pygame de la touche en question
|
||||
"keycode" : [pygame.K_DOWN] # Code pygame de la touche en question
|
||||
}
|
||||
|
||||
}
|
||||
if self.globals["AZERTY"]: # Azerty controls
|
||||
self.inputs["keys"]["left"]["keycode"].append(pygame.K_q)
|
||||
self.inputs["keys"]["right"]["keycode"].append(pygame.K_d)
|
||||
self.inputs["keys"]["up"]["keycode"].append(pygame.K_z)
|
||||
self.inputs["keys"]["down"]["keycode"].append(pygame.K_s)
|
||||
else: # Qwerty controls
|
||||
self.inputs["keys"]["left"]["keycode"].append(pygame.K_a)
|
||||
self.inputs["keys"]["right"]["keycode"].append(pygame.K_d)
|
||||
self.inputs["keys"]["up"]["keycode"].append(pygame.K_w)
|
||||
self.inputs["keys"]["down"]["keycode"].append(pygame.K_s)
|
||||
|
||||
|
||||
for key in self.inputs["keys"].keys():
|
||||
self.inputs["keys"][key]["timer"] = 0
|
||||
self.inputs["keys"][key]["realtime"] = 0
|
||||
self.inputs["keys"][key]["pressed"] = False
|
||||
self.inputs["keys"][key]["counted"] = False
|
||||
|
||||
self.inputs["joysticks"] = {}
|
||||
|
||||
|
@ -195,11 +191,12 @@ class Game():
|
|||
self.running = False
|
||||
if event.type == pygame.KEYDOWN:
|
||||
for i in self.inputs["keys"].keys():
|
||||
if event.key == self.inputs["keys"][i]["keycode"]: # Vérifie si une des touches du dico est préssée
|
||||
if event.key in self.inputs["keys"][i]["keycode"]: # Vérifie si une des touches du dico est préssée
|
||||
self.inputs["keys"][i]["pressed"] = True
|
||||
if event.type == pygame.KEYUP:
|
||||
for i in self.inputs["keys"].keys():
|
||||
self.inputs["keys"][i]["pressed"] = False
|
||||
if event.key in self.inputs["keys"][i]["keycode"]: # Vérifie si une des touches du dico est préssée
|
||||
self.inputs["keys"][i]["pressed"] = False
|
||||
if event.type == pygame.JOYDEVICEADDED:
|
||||
index = event.device_index
|
||||
self.inputs["joysticks"][index] = pygame.joystick.Joystick(index)
|
||||
|
|
|
@ -13,6 +13,14 @@ class Pause(BaseObject):
|
|||
self.fill.fill([62,33,55])
|
||||
self.fill.set_alpha(100)
|
||||
|
||||
self.sfx = self.game.sound_lib["sfx/mapmove.wav"]
|
||||
self.resumesfx = self.game.sound_lib["sfx/select.wav"]
|
||||
self.backsfx = self.game.sound_lib["sfx/return.wav"]
|
||||
|
||||
self.trash = game.sprite_lib["trash.png"]
|
||||
txt = "Cleared : "+str(self.game.globals["trashes"])+" / "+str(self.game.globals["totaltrashes"])
|
||||
self.trashcounter = self.game.getchars(txt)
|
||||
|
||||
self.cursor = 0
|
||||
self.cursorsprite = self.game.sprite_lib["cursor.png"]
|
||||
|
||||
|
@ -35,10 +43,12 @@ class Pause(BaseObject):
|
|||
def resume(self):
|
||||
self.game.globals["pause"] = False
|
||||
self.game.gameloop.delid(self.id)
|
||||
self.resumesfx.play()
|
||||
|
||||
def quit(self):
|
||||
tileset = self.game.gameloop.findname("TilesetRenderer")[0]
|
||||
tileset.bgm.stop()
|
||||
self.backsfx.play()
|
||||
t = Transition(self.game,time=0.5)
|
||||
self.game.gameloop.summon(t)
|
||||
self.ispaused = True
|
||||
|
@ -46,8 +56,10 @@ class Pause(BaseObject):
|
|||
def step(self):
|
||||
if self.game.inputs["keys"]["right"]["timer"]==1:
|
||||
self.cursor+=1
|
||||
self.sfx.play()
|
||||
if self.game.inputs["keys"]["left"]["timer"]==1:
|
||||
self.cursor-=1
|
||||
self.sfx.play()
|
||||
self.cursor = self.cursor%len(self.optionsorder)
|
||||
if self.game.inputs["keys"]["up"]["timer"]==1:
|
||||
self.game.inputs["keys"]["up"]["timer"]=10
|
||||
|
@ -58,9 +70,14 @@ class Pause(BaseObject):
|
|||
def draw(self):
|
||||
self.game.window.blit(self.fill,[0,0])
|
||||
|
||||
# Draw clear counter
|
||||
x = self.game.globals["cameraw"]/2
|
||||
self.game.lib.drawcenter(self.game,self.trashcounter,x,50)
|
||||
self.game.lib.drawcenter(self.game,self.trash,x-100,50)
|
||||
self.game.lib.drawcenter(self.game,self.trash,x+100,50)
|
||||
|
||||
# Draw options
|
||||
for i,v in enumerate(self.optionsorder):
|
||||
x = self.game.globals["cameraw"]/2
|
||||
y = self.offset+i*(9+self.padding)
|
||||
self.game.lib.drawcenter(self.game,self.sprites[v],x,y)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from gamedata.objects.ingame.movable import Movable
|
||||
from gamedata.objects.transition import Transition
|
||||
from gamedata.objects.ingame.pause import Pause
|
||||
from gamedata.objects.ingame.pause import Pause
|
||||
|
||||
class Player(Movable):
|
||||
|
||||
|
@ -312,7 +312,7 @@ class Player(Movable):
|
|||
self.game.gameloop.summon(t)
|
||||
|
||||
self.game.addParticle([self.spritehurt],self.rect.center[0],self.rect.center[1],fps=0.6,vely=-1.5,modvely=0.15) # Die sprite
|
||||
|
||||
|
||||
if self.tileset.bgm:
|
||||
self.tileset.bgm.stop()
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ class Levels(BaseObject):
|
|||
self.bgm = self.game.sound_lib["bgm/overworld.mp3"]
|
||||
self.bgm.play(-1)
|
||||
|
||||
self.sfx = self.game.sound_lib["sfx/mapmove.wav"]
|
||||
self.launchsfx = self.game.sound_lib["sfx/select.wav"]
|
||||
|
||||
self.launched = False
|
||||
|
||||
self.blueflags = self.game.getSpriteDir("flags/blue/")
|
||||
|
@ -69,14 +72,17 @@ class Levels(BaseObject):
|
|||
if self.game.inputs["keys"]["right"]["timer"]>0:
|
||||
if "Level "+str(self.cursor+1) in self.game.globals["finishedlevels"] or self.game.globals["allunlocked"]:
|
||||
self.cursor+=1
|
||||
self.sfx.play()
|
||||
self.flip = False
|
||||
if self.game.inputs["keys"]["left"]["timer"]>0:
|
||||
self.cursor-=1
|
||||
self.flip = True
|
||||
self.sfx.play()
|
||||
if self.game.inputs["keys"]["up"]["timer"]==1:
|
||||
# Launch the level
|
||||
t = Transition(self.game,level = "Level "+str(self.cursor+1))
|
||||
self.launched = True
|
||||
self.launchsfx.play()
|
||||
self.game.globals["levelname"] = self.cursor
|
||||
if str(self.cursor) in self.customvalues.keys():
|
||||
props = self.customvalues[str(self.cursor)].split(";")
|
||||
|
|
|
@ -16,6 +16,8 @@ class Results(BaseObject):
|
|||
self.time = min(99,self.game.globals["timer"])
|
||||
|
||||
self.sparkles = game.getSpriteDir("particles/dust/")
|
||||
self.medalsfx = self.game.sound_lib["sfx/select.wav"]
|
||||
self.backsfx = self.game.sound_lib["sfx/return.wav"]
|
||||
|
||||
self.text = self.game.getchars("Cleared : 0 / "+str(self.maxcount))
|
||||
self.levelname = self.game.getchars("Level "+str(self.game.globals["levelname"]+1))
|
||||
|
@ -58,6 +60,7 @@ class Results(BaseObject):
|
|||
self.text = self.game.getchars("Cleared : "+str(int(self.currentcount))+" / "+str(self.maxcount))
|
||||
if self.currentcount == self.maxcount: # Spawn sparkles
|
||||
self.game.addParticle(self.sparkles,self.centerx+150+self.game.globals["camerax"],self.centery+self.game.globals["cameray"],fps=6,depth=4)
|
||||
self.medalsfx.play()
|
||||
|
||||
past = int(self.currenttime)
|
||||
self.currenttime-=self.game.dt
|
||||
|
@ -71,6 +74,7 @@ class Results(BaseObject):
|
|||
self.seconds = self.game.getchars(txt)
|
||||
if int(self.time)==int(self.currenttime) and int(self.game.globals["timetobeat"]) >= int(self.currenttime): # Spawn sparkles
|
||||
self.game.addParticle(self.sparkles,self.centerx+150+self.game.globals["camerax"],self.centery+20+self.game.globals["cameray"],fps=6,depth = 4)
|
||||
self.medalsfx.play()
|
||||
|
||||
if not self.transition:
|
||||
keys = ["up","down","left","right"]
|
||||
|
@ -79,6 +83,7 @@ class Results(BaseObject):
|
|||
if self.transition:
|
||||
t = Transition(self.game)
|
||||
self.game.gameloop.summon(t)
|
||||
self.backsfx.play()
|
||||
|
||||
if not self.faded:
|
||||
self.alpha = (1-self.fadetimer.getratio())*self.alphamax
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue