Added result screen, and medals

This commit is contained in:
theo@manjaro 2021-11-24 15:47:52 +01:00
parent 5ac48ac733
commit 31a1cf70fd
20 changed files with 172 additions and 19 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

BIN
gamedata/assets/trash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

View File

@ -95,6 +95,7 @@ class Game():
self.globals["hitpose"] = False self.globals["hitpose"] = False
self.globals["finishedlevels"] = [] # Levels where the player went to the end 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["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.globals["allunlocked"] = True
self.scaleCamera() self.scaleCamera()
@ -289,7 +290,7 @@ class Game():
self.globals["tempsubsurface"] = pygame.Surface((neww,newh)) self.globals["tempsubsurface"] = pygame.Surface((neww,newh))
def getchar(self,char,width=9,height=9): def getchar(self,char,width=9,height=9):
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@\"#&()*:;?!abcdefghijklmnopqrstuvwxyz" chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@\"#&()*:;?!abcdefghijklmnopqrstuvwxyz/"
charsperline = self.fontmap.get_width()//width charsperline = self.fontmap.get_width()//width
result = None result = None
if char in chars: if char in chars:

View File

@ -1704,6 +1704,7 @@
[1, 0], [1, 0],
[1, 0], [1, 0],
[1, 0], [1, 0],
[1, 0],
[2, 0], [2, 0],
[-1], [-1],
[-1], [-1],
@ -1734,7 +1735,6 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1],
[10, 6], [10, 6],
[9, 6], [9, 6],
[10, 6], [10, 6],
@ -1881,6 +1881,7 @@
[1, 1], [1, 1],
[3, 0], [3, 0],
[1, 2], [1, 2],
[1, 2],
[2, 2], [2, 2],
[-1], [-1],
[-1], [-1],
@ -1911,7 +1912,6 @@
[-1], [-1],
[-1], [-1],
[-1], [-1],
[-1],
[10, 7], [10, 7],
[9, 7], [9, 7],
[10, 7], [10, 7],
@ -6095,7 +6095,7 @@
{"name": "Solid", "id": 31, "_eid": "17026310", "x": 1056, "y": 208, "width": 80, "height": 64, "originX": 0, "originY": 0}, {"name": "Solid", "id": 31, "_eid": "17026310", "x": 1056, "y": 208, "width": 80, "height": 64, "originX": 0, "originY": 0},
{"name": "Solid", "id": 32, "_eid": "17026310", "x": 1136, "y": 192, "width": 64, "height": 80, "originX": 0, "originY": 0}, {"name": "Solid", "id": 32, "_eid": "17026310", "x": 1136, "y": 192, "width": 64, "height": 80, "originX": 0, "originY": 0},
{"name": "Solid", "id": 33, "_eid": "17026310", "x": 1232, "y": 176, "width": 96, "height": 16, "originX": 0, "originY": 0}, {"name": "Solid", "id": 33, "_eid": "17026310", "x": 1232, "y": 176, "width": 96, "height": 16, "originX": 0, "originY": 0},
{"name": "Solid", "id": 34, "_eid": "17026310", "x": 1360, "y": 144, "width": 160, "height": 32, "originX": 0, "originY": 0}, {"name": "Solid", "id": 34, "_eid": "17026310", "x": 1360, "y": 144, "width": 176, "height": 32, "originX": 0, "originY": 0},
{"name": "Solid", "id": 35, "_eid": "17026310", "x": 1392, "y": 176, "width": 96, "height": 16, "originX": 0, "originY": 0}, {"name": "Solid", "id": 35, "_eid": "17026310", "x": 1392, "y": 176, "width": 96, "height": 16, "originX": 0, "originY": 0},
{"name": "Solid", "id": 36, "_eid": "17026310", "x": 1584, "y": 224, "width": 80, "height": 48, "originX": 0, "originY": 0}, {"name": "Solid", "id": 36, "_eid": "17026310", "x": 1584, "y": 224, "width": 80, "height": 48, "originX": 0, "originY": 0},
{"name": "Solid", "id": 37, "_eid": "17026310", "x": 1664, "y": 208, "width": 48, "height": 64, "originX": 0, "originY": 0}, {"name": "Solid", "id": 37, "_eid": "17026310", "x": 1664, "y": 208, "width": 48, "height": 64, "originX": 0, "originY": 0},
@ -6335,7 +6335,10 @@
{"x": 2448, "y": 288} {"x": 2448, "y": 288}
], ],
"values": {"Speed": 3} "values": {"Speed": 3}
} },
{"name": "TrashBag", "id": 30, "_eid": "74601465", "x": 1680, "y": 192, "originX": 0, "originY": 0},
{"name": "TrashBag", "id": 31, "_eid": "74601465", "x": 1456, "y": 224, "originX": 0, "originY": 0},
{"name": "TrashBag", "id": 32, "_eid": "74601465", "x": 1088, "y": 192, "originX": 0, "originY": 0}
] ]
} }
] ]

View File

@ -1583,7 +1583,7 @@
{"x": 512, "y": 96}, {"x": 512, "y": 96},
{"x": 640, "y": 144} {"x": 640, "y": 144}
], ],
"values": {"0": "Beginning", "1": "The Docks"} "values": {"0": "Beginning;20", "1": "The Docks;40"}
} }
] ]
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -1,5 +1,5 @@
from gamedata.objects.ingame.ennemies.ennemy import Ennemy from gamedata.objects.ingame.ennemies.ennemy import Ennemy
from gamedata.objects.transition import Transition from gamedata.objects.results import Results
class EndFlag(Ennemy): class EndFlag(Ennemy):
@ -54,12 +54,18 @@ class EndFlag(Ennemy):
self.game.addParticle(sprites,self.rect.center[0]+offsetx,self.rect.center[1]+offsety,velx=velx,vely=vely,modvely=0.1,fps=2) self.game.addParticle(sprites,self.rect.center[0]+offsetx,self.rect.center[1]+offsety,velx=velx,vely=vely,modvely=0.1,fps=2)
if not self.game.globals["levelname"] in self.game.globals["finishedlevels"]: if not self.game.globals["levelname"] in self.game.globals["finishedlevels"]:
self.game.globals["finishedlevels"].append(self.game.globals["levelname"]) self.game.globals["finishedlevels"].append(self.game.globals["levelname"])
if self.game.globals["totaltrashes"]==self.game.globals["trashes"]:
if not self.game.globals["levelname"] in self.game.globals["completedlevels"]:
self.game.globals["completedlevels"].append(self.game.globals["levelname"])
if int(self.game.globals["timetobeat"])>=int(self.game.globals["timer"]):
if not self.game.globals["levelname"] in self.game.globals["speedrunlevels"]:
self.game.globals["speedrunlevels"].append(self.game.globals["levelname"])
self.sfx.play() self.sfx.play()
if self.ended: if self.ended:
if self.endtimer.tick(self.game.dt): if self.endtimer.tick(self.game.dt) and self.endtimer.getloops()<2:
t = Transition(self.game) r = Results(self.game)
self.game.gameloop.summon(t) self.game.gameloop.summon(r)
def draw(self): def draw(self):
sprite = self.sprites[int(self.spriteindex)%len(self.sprites)] sprite = self.sprites[int(self.spriteindex)%len(self.sprites)]

View File

@ -25,6 +25,9 @@ class Ennemy(Movable):
self.dustparticles = game.getSpriteDir("particles/dust/") self.dustparticles = game.getSpriteDir("particles/dust/")
def deadtrigger(self):
pass
def step(self): def step(self):
if not self.dead: if not self.dead:
@ -45,6 +48,7 @@ class Ennemy(Movable):
if self.rect.colliderect(self.player.hitrect): if self.rect.colliderect(self.player.hitrect):
# Die # Die
self.dead = True self.dead = True
self.deadtrigger()
# Add particles # Add particles
self.game.addParticle(self.dustparticles,self.rect.center[0]+self.particleoffsetx,self.rect.center[1]+self.particleoffsety) # Dust self.game.addParticle(self.dustparticles,self.rect.center[0]+self.particleoffsetx,self.rect.center[1]+self.particleoffsety) # Dust
self.game.addParticle([self.deadsprite],self.rect.center[0]+self.particleoffsetx,self.rect.center[1]+self.particleoffsety,fps=0.6,vely=-1.5,modvely=0.15) # Die sprite self.game.addParticle([self.deadsprite],self.rect.center[0]+self.particleoffsetx,self.rect.center[1]+self.particleoffsety,fps=0.6,vely=-1.5,modvely=0.15) # Die sprite

View File

@ -16,6 +16,8 @@ class Robot(Ennemy):
self.falling = 20 self.falling = 20
self.spriteindex = 0 self.spriteindex = 0
self.respawn = False
self.gravityway = 1 # Vertical flip self.gravityway = 1 # Vertical flip
self.walkingway = 1 # Horizontal flip self.walkingway = 1 # Horizontal flip
@ -29,6 +31,11 @@ class Robot(Ennemy):
else: else:
self.endpoints = None self.endpoints = None
self.game.globals["totaltrashes"]+=1
def deadtrigger(self):
self.game.globals["trashes"]+=1
def step(self): def step(self):
if not self.dead: if not self.dead:

View File

@ -0,0 +1,20 @@
from gamedata.objects.ingame.ennemies.ennemy import Ennemy
class TrashBag(Ennemy):
def __init__(self,*args):
super().__init__(*args)
self.sprite = self.game.sprite_lib["trash.png"]
self.deadsprite = self.sprite
self.rect[2],self.rect[3] = self.sprite.get_size()
self.respawn = False
self.canhit = False
self.game.globals["totaltrashes"]+=1
def deadtrigger(self):
self.game.globals["trashes"]+=1

View File

@ -132,6 +132,7 @@ class Player(Movable):
if canmove: if canmove:
if self.canmove: if self.canmove:
self.horspd=(keys["right"]["pressed"]-keys["left"]["pressed"])*self.game.dt*self.speed self.horspd=(keys["right"]["pressed"]-keys["left"]["pressed"])*self.game.dt*self.speed
self.game.globals["timer"]+=self.game.dt
if self.landingtimer<=0: if self.landingtimer<=0:
self.sprite = self.spritestill self.sprite = self.spritestill
@ -293,9 +294,9 @@ class Player(Movable):
self.horkb = hor self.horkb = hor
self.verkb = ver self.verkb = ver
self.canfastfall = True self.canfastfall = True
if resetcombo:
self.game.globals["scamerax"] = 4 self.game.globals["scamerax"] = 4
self.game.globals["scameray"] = 4 self.game.globals["scameray"] = 4
if resetcombo:
self.combo = 0 self.combo = 0
self.hurtsfx.play() self.hurtsfx.play()
self.hp-=1 self.hp-=1
@ -309,7 +310,7 @@ class Player(Movable):
self.rect[2],self.rect[3] = 0,0 self.rect[2],self.rect[3] = 0,0
self.dead = True self.dead = True
t = Transition(self.game,time=1,holdtime=0.5,level=self.game.globals["levelname"]) t = Transition(self.game,time=1,holdtime=0.5,level="Level "+str(self.game.globals["levelname"]+1))
self.game.gameloop.summon(t) 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 self.game.addParticle([self.spritehurt],self.rect.center[0],self.rect.center[1],fps=0.6,vely=-1.5,modvely=0.15) # Die sprite

View File

@ -4,6 +4,7 @@ from gamedata.objects.ingame.ennemies.crate import Crate
from gamedata.objects.ingame.ennemies.balloon import Balloon from gamedata.objects.ingame.ennemies.balloon import Balloon
from gamedata.objects.ingame.ennemies.spring import Spring from gamedata.objects.ingame.ennemies.spring import Spring
from gamedata.objects.ingame.ennemies.waterchange import WaterChange from gamedata.objects.ingame.ennemies.waterchange import WaterChange
from gamedata.objects.ingame.ennemies.trashbag import TrashBag
from gamedata.objects.ingame.endflag import EndFlag from gamedata.objects.ingame.endflag import EndFlag
from gamedata.objects.levels import Levels from gamedata.objects.levels import Levels
@ -20,6 +21,10 @@ class TilesetRenderer(BaseObject):
self.level = game.levels_lib[mapfoldername] self.level = game.levels_lib[mapfoldername]
self.reinit(self.level) self.reinit(self.level)
self.game.globals["totaltrashes"] = 0
self.game.globals["trashes"] = 0
self.game.globals["timer"] = 0
self.bgs = [game.sprite_lib["fallbackground.png"]] self.bgs = [game.sprite_lib["fallbackground.png"]]
if len(self.level["backgrounds"]): if len(self.level["backgrounds"]):
self.bgs = self.level["backgrounds"] self.bgs = self.level["backgrounds"]
@ -72,7 +77,7 @@ class TilesetRenderer(BaseObject):
self.layers = [] self.layers = []
self.spawns = [] self.spawns = []
spawnlists = {"Spawns":self.spawns} spawnlists = {"Spawns":self.spawns}
ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon,"Spring":Spring,"WaterChange":WaterChange,"Levels":Levels,"End":EndFlag} ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon,"Spring":Spring,"WaterChange":WaterChange,"Levels":Levels,"End":EndFlag,"TrashBag":TrashBag}
self.queue = [] # For spawning ennemies after beeing initialized self.queue = [] # For spawning ennemies after beeing initialized
if "layers" in json.keys() and type(json["layers"]).__name__=="list": if "layers" in json.keys() and type(json["layers"]).__name__=="list":
solidlayer = False solidlayer = False

View File

@ -17,6 +17,11 @@ class Levels(BaseObject):
self.playerwalking = self.game.getSpriteDir("player/walking/") self.playerwalking = self.game.getSpriteDir("player/walking/")
self.playerstill = self.game.sprite_lib["player/still.png"] self.playerstill = self.game.sprite_lib["player/still.png"]
self.medalwave = self.game.sprite_lib["medals/wave.png"]
self.medalwaveoff = self.game.sprite_lib["medals/waveoff.png"]
self.medalclock = self.game.sprite_lib["medals/clock.png"]
self.medalclockoff = self.game.sprite_lib["medals/clockoff.png"]
self.flip = False self.flip = False
self.moving = False self.moving = False
self.spriteindex = 0 self.spriteindex = 0
@ -35,7 +40,7 @@ class Levels(BaseObject):
# Get sprites for the level's name # Get sprites for the level's name
if str(i) in customvalues.keys(): if str(i) in customvalues.keys():
sprites = self.game.getchars(customvalues[str(i)]) sprites = self.game.getchars(customvalues[str(i)].split(";")[0])
self.names.append(sprites) self.names.append(sprites)
else: else:
self.names.append(None) self.names.append(None)
@ -64,7 +69,13 @@ class Levels(BaseObject):
# Launch the level # Launch the level
t = Transition(self.game,level = "Level "+str(self.cursor+1)) t = Transition(self.game,level = "Level "+str(self.cursor+1))
self.launched = True self.launched = True
self.game.globals["levelname"] = "Level "+str(self.cursor+1) self.game.globals["levelname"] = self.cursor
if str(self.cursor) in self.customvalues.keys():
props = self.customvalues[str(self.cursor)].split(";")
self.game.globals["levellore"] = props[0]
self.game.globals["timetobeat"] = props[1]
else:
self.game.globals["levellore"] = None
self.game.gameloop.summon(t) self.game.gameloop.summon(t)
self.cursor = min(self.cursor,len(self.nodes)-1) self.cursor = min(self.cursor,len(self.nodes)-1)
self.cursor = max(0,self.cursor) self.cursor = max(0,self.cursor)
@ -87,7 +98,7 @@ class Levels(BaseObject):
def draw(self): def draw(self):
for i,v in enumerate(self.nodes): # Draw flags for i,v in enumerate(self.nodes): # Draw flags
sprites = self.blueflags sprites = self.blueflags
if "Level "+str(i+1) in self.game.globals["finishedlevels"]: if i in self.game.globals["finishedlevels"]:
sprites = self.greenflags sprites = self.greenflags
sprite = sprites[int(self.flagsindex[i])%len(sprites)] sprite = sprites[int(self.flagsindex[i])%len(sprites)]
x = v["x"]-sprite.get_width()/2-self.game.globals["camerax"]+8 x = v["x"]-sprite.get_width()/2-self.game.globals["camerax"]+8
@ -110,6 +121,19 @@ class Levels(BaseObject):
x = self.nodes[self.cursor]["x"]-self.game.globals["camerax"]-sprite.get_width()/2 x = self.nodes[self.cursor]["x"]-self.game.globals["camerax"]-sprite.get_width()/2
y = self.nodes[self.cursor]["y"]-self.game.globals["cameray"]-sprite.get_height()/2-50 y = self.nodes[self.cursor]["y"]-self.game.globals["cameray"]-sprite.get_height()/2-50
self.game.window.blit(sprite,[x,y]) self.game.window.blit(sprite,[x,y])
# Medals
wave = self.medalwaveoff
if self.cursor in self.game.globals["completedlevels"]:
wave = self.medalwave
clock = self.medalclockoff
if self.cursor in self.game.globals["speedrunlevels"]:
clock = self.medalclock
x = self.nodes[self.cursor]["x"]-self.game.globals["camerax"]
y = self.nodes[self.cursor]["y"]-72
self.game.window.blit(wave,[x-wave.get_width()-1,y])
self.game.window.blit(clock,[x+1,y])
# Draw the level's name # Draw the level's name
if self.names[self.cursor]: if self.names[self.cursor]:
sprite = self.names[self.cursor] sprite = self.names[self.cursor]

View File

@ -0,0 +1,78 @@
from gamedata.objects.base import BaseObject
from gamedata.objects.transition import Transition
class Results(BaseObject):
def __init__(self,game):
super().__init__(0,0,game)
self.maxcount = self.game.globals["totaltrashes"]
self.currentcount = 0
self.count = self.game.globals["trashes"]
self.text = self.game.getchars("Cleared : 0 / "+str(self.maxcount))
self.levelname = self.game.getchars("Level "+str(self.game.globals["levelname"]+1))
self.levellore = None
txt = "Time : "+str(int(self.game.globals["timer"]))
txt += " ( "+str(self.game.globals["timetobeat"])+" for medal )"
self.seconds = self.game.getchars(txt)
if self.game.globals["levellore"]:
self.levellore = self.game.getchars(self.game.globals["levellore"])
self.fill = self.game.pygame.Surface((self.game.globals["cameraw"],self.game.globals["camerah"]))
self.fill.fill([62,33,55])
self.fadetimer = self.game.lib.Timer(2)
self.faded = False
self.alphamax = 200
self.alpha = 0
self.medalwave = self.game.sprite_lib["medals/wave.png"]
self.medalclock= self.game.sprite_lib["medals/clock.png"]
self.transition = False
self.depth = 3
def step(self):
past = int(self.currentcount)
self.currentcount+=self.game.dt
self.currentcount += (self.count - self.currentcount)*self.game.dt
self.currentcount = min(self.currentcount,self.count)
if int(self.currentcount)>past:
# Make a noise
self.text = self.game.getchars("Cleared : "+str(int(self.currentcount))+" / "+str(self.maxcount))
if not self.transition:
keys = ["up","down","left","right"]
for i in keys:
self.transition = self.transition or self.game.inputs["keys"][i]["timer"]==1
if self.transition:
t = Transition(self.game)
self.game.gameloop.summon(t)
if not self.faded:
self.alpha = (1-self.fadetimer.getratio())*self.alphamax
if self.fadetimer.tick(self.game.dt):
self.faded = True
else:
self.alpha = self.alphamax
def draw(self):
self.fill.set_alpha(self.alpha)
self.game.window.blit(self.fill,[0,0])
cx = self.game.globals["cameraw"]/2
cy = self.game.globals["camerah"]/2
self.game.lib.drawcenter(self.game,self.levelname,cx,cy-50) # Level names
if self.levellore:
self.game.lib.drawcenter(self.game,self.levellore,cx,cy-39)
self.game.lib.drawcenter(self.game,self.text,cx,cy) # Clean
self.game.lib.drawcenter(self.game,self.seconds,cx,cy+20)
if self.currentcount == self.maxcount: # Medals
self.game.lib.drawcenter(self.game,self.medalwave,cx+150,cy)
if int(self.game.globals["timetobeat"]) >= int(self.game.globals["timer"]):
self.game.lib.drawcenter(self.game,self.medalclock,cx+150,cy+20)

View File

@ -28,7 +28,10 @@ class Transition(BaseObject):
else: else:
if self.holdtimer.tick(self.game.dt): if self.holdtimer.tick(self.game.dt):
if self.level: if self.level:
if self.level!="END":
self.game.scenes.ingame(self.game,level = self.level) self.game.scenes.ingame(self.game,level = self.level)
else:
self.game.scenes.end(self.game)
else: else:
self.game.scenes.overworld(self.game) self.game.scenes.overworld(self.game)

View File

@ -9,6 +9,7 @@ from gamedata.objects.ingame.manager import FightManager
from gamedata.objects.ingame.hitbox import Hitbox from gamedata.objects.ingame.hitbox import Hitbox
from gamedata.objects.ingame.tileset import TilesetRenderer from gamedata.objects.ingame.tileset import TilesetRenderer
from gamedata.objects.ingame.water import Water from gamedata.objects.ingame.water import Water
from gamedata.objects.results import Results
def main(game): def main(game):
game.scaleCamera() game.scaleCamera()