Added springs
BIN
gamedata/assets/spring/diagonal/0.png
Normal file
After Width: | Height: | Size: 857 B |
BIN
gamedata/assets/spring/diagonal/1.png
Normal file
After Width: | Height: | Size: 852 B |
BIN
gamedata/assets/spring/diagonal/2.png
Normal file
After Width: | Height: | Size: 743 B |
BIN
gamedata/assets/spring/diagonal/3.png
Normal file
After Width: | Height: | Size: 852 B |
BIN
gamedata/assets/spring/normal/0.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
gamedata/assets/spring/normal/1.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
gamedata/assets/spring/normal/2.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
gamedata/assets/spring/normal/3.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
gamedata/assets/spring/side/0.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
gamedata/assets/spring/side/1.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
gamedata/assets/spring/side/2.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
gamedata/assets/spring/side/3.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
@ -1248,13 +1248,13 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[5, 4],
|
||||
[6, 4],
|
||||
[5, 4],
|
||||
[6, 4],
|
||||
[4, 4],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[10, 4],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -1337,13 +1337,13 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[5, 5],
|
||||
[6, 5],
|
||||
[5, 5],
|
||||
[6, 5],
|
||||
[4, 5],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[10, 5],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -1426,11 +1426,11 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[7, 4],
|
||||
[8, 4],
|
||||
[7, 4],
|
||||
[8, 4],
|
||||
[4, 5],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -1515,11 +1515,11 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[7, 5],
|
||||
[8, 5],
|
||||
[7, 5],
|
||||
[8, 5],
|
||||
[4, 6],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -1604,11 +1604,11 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[0, 5],
|
||||
[1, 5],
|
||||
[7, 4],
|
||||
[8, 4],
|
||||
[4, 6],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -1693,10 +1693,10 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[0, 6],
|
||||
[1, 6],
|
||||
[7, 5],
|
||||
[8, 5],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -1784,8 +1784,8 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[0, 5],
|
||||
[1, 5],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -1873,8 +1873,8 @@
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
[0, 6],
|
||||
[1, 6],
|
||||
[-1],
|
||||
[-1],
|
||||
[-1],
|
||||
@ -2449,7 +2449,8 @@
|
||||
{"name": "Solid", "id": 38, "_eid": "17026310", "x": 832, "y": 304, "width": 96, "height": 32, "originX": 0, "originY": 0},
|
||||
{"name": "Solid", "id": 39, "_eid": "17026310", "x": 848, "y": 336, "width": 64, "height": 96, "originX": 0, "originY": 0},
|
||||
{"name": "SemiSolid", "id": 40, "_eid": "59763689", "x": 832, "y": 208, "width": 64, "height": 16, "originX": 0, "originY": 0},
|
||||
{"name": "SemiSolid", "id": 42, "_eid": "59763689", "x": 1040, "y": 176, "width": 80, "height": 16, "originX": 0, "originY": 0}
|
||||
{"name": "SemiSolid", "id": 42, "_eid": "59763689", "x": 1040, "y": 176, "width": 80, "height": 16, "originX": 0, "originY": 0},
|
||||
{"name": "SemiSolid", "id": 43, "_eid": "59763689", "x": 1184, "y": 208, "width": 80, "height": 16, "originX": 0, "originY": 0}
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -2496,14 +2497,16 @@
|
||||
{"name": "Crate", "id": 14, "_eid": "16023910", "x": 624, "y": 208, "originX": 0, "originY": 0},
|
||||
{"name": "Crate", "id": 15, "_eid": "16023910", "x": 608, "y": 208, "originX": 0, "originY": 0},
|
||||
{"name": "Crate", "id": 16, "_eid": "16023910", "x": 592, "y": 208, "originX": 0, "originY": 0},
|
||||
{"name": "Balloon", "id": 18, "_eid": "16494694", "x": 912, "y": 160, "originX": 0, "originY": 0},
|
||||
{"name": "Balloon", "id": 19, "_eid": "16494694", "x": 976, "y": 144, "originX": 0, "originY": 0},
|
||||
{"name": "Balloon", "id": 20, "_eid": "16494694", "x": 800, "y": 160, "originX": 0, "originY": 0},
|
||||
{"name": "Crate", "id": 21, "_eid": "16023910", "x": 864, "y": 192, "originX": 0, "originY": 0},
|
||||
{"name": "Crate", "id": 22, "_eid": "16023910", "x": 864, "y": 176, "originX": 0, "originY": 0},
|
||||
{"name": "Crate", "id": 23, "_eid": "16023910", "x": 864, "y": 160, "originX": 0, "originY": 0},
|
||||
{"name": "Crate", "id": 24, "_eid": "16023910", "x": 864, "y": 144, "originX": 0, "originY": 0},
|
||||
{"name": "Crate", "id": 25, "_eid": "16023910", "x": 864, "y": 128, "originX": 0, "originY": 0}
|
||||
{
|
||||
"name": "Spring",
|
||||
"id": 35,
|
||||
"_eid": "24018769",
|
||||
"x": 864,
|
||||
"y": 192,
|
||||
"originX": 0,
|
||||
"originY": 0,
|
||||
"values": {"angle": 45, "strength": 8}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -2,12 +2,12 @@ from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
||||
|
||||
class Balloon(Ennemy):
|
||||
|
||||
def __init__(self,x,y,game,nodes=None):
|
||||
def __init__(self,*args):
|
||||
|
||||
super().__init__(x,y,game,nodes)
|
||||
super().__init__(*args)
|
||||
|
||||
self.sprites = game.getSpriteDir("balloon/")
|
||||
self.deadsprite = game.sprite_lib["balloon/broke.png"]
|
||||
self.sprites = self.game.getSpriteDir("balloon/")
|
||||
self.deadsprite = self.game.sprite_lib["balloon/broke.png"]
|
||||
|
||||
self.rect[2],self.rect[3] = self.sprites[0].get_size()
|
||||
self.rect[3]*=0.6
|
||||
|
@ -2,12 +2,12 @@ from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
||||
|
||||
class Crate(Ennemy):
|
||||
|
||||
def __init__(self,x,y,game,nodes=None):
|
||||
def __init__(self,*args):
|
||||
|
||||
super().__init__(x,y,game,nodes)
|
||||
super().__init__(*args)
|
||||
|
||||
self.sprite = game.sprite_lib["crate/crate.png"]
|
||||
self.deadsprite = game.sprite_lib["crate/broke.png"]
|
||||
self.sprite = self.game.sprite_lib["crate/crate.png"]
|
||||
self.deadsprite = self.game.sprite_lib["crate/broke.png"]
|
||||
|
||||
self.size = self.sprite.get_size()
|
||||
self.rect[2],self.rect[3] = self.size
|
||||
|
@ -2,7 +2,7 @@ from gamedata.objects.combat.movable import Movable
|
||||
|
||||
class Ennemy(Movable):
|
||||
|
||||
def __init__(self,x,y,game,nodes=None):
|
||||
def __init__(self,x,y,game,nodes,customvalues):
|
||||
|
||||
super().__init__(game,x,y)
|
||||
|
||||
@ -20,6 +20,9 @@ class Ennemy(Movable):
|
||||
self.candie = True
|
||||
self.cancombo = True
|
||||
|
||||
self.nodes = nodes
|
||||
self.customvalues = customvalues
|
||||
|
||||
self.dustparticles = game.getSpriteDir("particles/dust/")
|
||||
|
||||
def step(self):
|
||||
@ -37,9 +40,7 @@ class Ennemy(Movable):
|
||||
hor = 1
|
||||
else:
|
||||
hor = -1
|
||||
self.player.horkb = hor*6
|
||||
self.player.verkb = self.player.gravityway*-3
|
||||
self.player.combo = 0
|
||||
self.player.yeet(hor*6,self.player.gravityway*-3)
|
||||
if self.candie and self.player.canhit:
|
||||
if self.rect.colliderect(self.player.hitrect):
|
||||
# Die
|
||||
|
@ -2,13 +2,13 @@ from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
||||
|
||||
class Robot(Ennemy):
|
||||
|
||||
def __init__(self,x,y,game,nodes=None):
|
||||
def __init__(self,*args):
|
||||
|
||||
super().__init__(x,y,game,nodes)
|
||||
super().__init__(*args)
|
||||
|
||||
self.sprites = game.getSpriteDir("robot/")
|
||||
self.sprites = self.game.getSpriteDir("robot/")
|
||||
self.sprite = self.sprites[0]
|
||||
self.deadsprite = game.sprite_lib["robot/death.png"]
|
||||
self.deadsprite = self.game.sprite_lib["robot/death.png"]
|
||||
|
||||
self.rect[2],self.rect[3] = self.deadsprite.get_size()
|
||||
|
||||
@ -20,11 +20,11 @@ class Robot(Ennemy):
|
||||
self.walkingway = 1 # Horizontal flip
|
||||
|
||||
# Offset it correctly
|
||||
self.rect[0] = x+8-self.rect[2]/2
|
||||
self.rect[0] += 8-self.rect[2]/2
|
||||
|
||||
# Movement boundaries
|
||||
if nodes:
|
||||
self.endpoints = [x["x"] for x in nodes[:2]] # Get only x positions
|
||||
if self.nodes:
|
||||
self.endpoints = [x["x"] for x in self.nodes[:2]] # Get only x positions
|
||||
self.endpoints.sort()
|
||||
else:
|
||||
self.endpoints = None
|
||||
|
69
gamedata/objects/combat/ennemies/spring.py
Normal file
@ -0,0 +1,69 @@
|
||||
from gamedata.objects.combat.ennemies.ennemy import Ennemy
|
||||
|
||||
class Spring(Ennemy):
|
||||
|
||||
def __init__(self,*args):
|
||||
|
||||
super().__init__(*args)
|
||||
|
||||
spritesnormal = self.game.getSpriteDir("spring/normal/")
|
||||
spritesside = self.game.getSpriteDir("spring/side/")
|
||||
spritesdiagonal = self.game.getSpriteDir("spring/diagonal/")
|
||||
self.sprite = spritesnormal[0]
|
||||
self.rect[2],self.rect[3] = self.sprite.get_width(),round(self.sprite.get_height()/2)
|
||||
self.spriteindex = 0
|
||||
self.animspeed = 8
|
||||
|
||||
# Zone in with the player is colliding
|
||||
|
||||
# Formatting the angle ( clockwise, in degrees, starting at the top )
|
||||
if "angle" in self.customvalues:
|
||||
angle = self.customvalues["angle"]
|
||||
else:
|
||||
angle = 0
|
||||
# Sprite,flipx,flipy
|
||||
self.orientations = [[spritesnormal,False,False],[spritesdiagonal,False,False],[spritesside,False,False],[spritesdiagonal,False,True],[spritesnormal,False,True],[spritesdiagonal,True,True],[spritesside,True,False],[spritesdiagonal,True,False]]
|
||||
orientation = self.orientations[int((angle/360*len(self.orientations))+0.5)%len(self.orientations)]
|
||||
self.sprites = []
|
||||
for i in orientation[0]:
|
||||
self.sprites.append(self.game.pygame.transform.flip(i,orientation[1],orientation[2]))
|
||||
self.sprite = self.sprites[0]
|
||||
angle = self.game.math.radians(angle-90)
|
||||
|
||||
# Offsetting the zone
|
||||
distance = self.rect[3]
|
||||
self.ratiox = self.game.math.cos(angle)
|
||||
self.ratioy = self.game.math.sin(angle)
|
||||
offx = self.ratiox*distance
|
||||
offy = self.ratioy*distance
|
||||
self.jumpcenter = [self.rect.center[0]+offx,self.rect.center[1]+offy]
|
||||
self.jumpradius = 10
|
||||
|
||||
if "strength" in self.customvalues:
|
||||
self.jumpstrength = self.customvalues["strength"]
|
||||
else:
|
||||
self.jumpstrength = 5
|
||||
|
||||
self.candie = False
|
||||
self.canhit = False
|
||||
|
||||
def step(self):
|
||||
super().step()
|
||||
|
||||
# Check for collision with player
|
||||
if self.player.verspd*self.ratioy<0 or abs(self.ratioy)<0.3:
|
||||
if self.game.math.sqrt((self.player.rect.center[0]-self.jumpcenter[0])**2+(self.player.rect.center[1]-self.jumpcenter[1])**2)<self.jumpradius and not self.player.onground:
|
||||
# Yeet the player
|
||||
force = self.jumpstrength
|
||||
if self.player.fastfall:
|
||||
force*=1.5
|
||||
self.player.yeet(self.ratiox*force,self.ratioy*force)
|
||||
self.spriteindex = len(self.sprites)
|
||||
|
||||
self.spriteindex-=self.animspeed*self.game.dt
|
||||
if self.spriteindex<0:
|
||||
self.spriteindex=0
|
||||
self.sprite = self.sprites[int(self.spriteindex)]
|
||||
|
||||
def draw(self):
|
||||
self.game.window.blit(self.sprite,[self.rect[0]-self.game.globals["camerax"],self.rect[1]-self.game.globals["cameray"]])
|
@ -222,6 +222,8 @@ class Player(Movable):
|
||||
self.verspd = self.maxgravity/5
|
||||
if self.leaptimer>0:
|
||||
self.verspd*=self.gravityway
|
||||
else:
|
||||
self.leaptimer = 0
|
||||
self.canfastfall = False
|
||||
self.fastfall = self.gravityway
|
||||
else:
|
||||
@ -244,6 +246,13 @@ class Player(Movable):
|
||||
self.combo+=1
|
||||
self.combotimer = 1
|
||||
|
||||
def yeet(self,hor,ver):
|
||||
self.verspd = 0
|
||||
self.combo = 0
|
||||
self.horkb = hor
|
||||
self.verkb = ver
|
||||
self.canfastfall = True
|
||||
|
||||
def draw(self):
|
||||
flipy = (self.gravityway<0 and not self.leaptimer<0)
|
||||
if self.fastfall:
|
||||
|
@ -2,6 +2,7 @@ from gamedata.objects.base import BaseObject
|
||||
from gamedata.objects.combat.ennemies.robot import Robot
|
||||
from gamedata.objects.combat.ennemies.crate import Crate
|
||||
from gamedata.objects.combat.ennemies.balloon import Balloon
|
||||
from gamedata.objects.combat.ennemies.spring import Spring
|
||||
|
||||
class TilesetRenderer(BaseObject):
|
||||
|
||||
@ -23,7 +24,7 @@ class TilesetRenderer(BaseObject):
|
||||
# Spawning ennemies
|
||||
while len(self.queue)>0:
|
||||
props = self.queue.pop()
|
||||
e = props[0](props[1],props[2],self.game,nodes=props[3])
|
||||
e = props[0](props[1],props[2],self.game,props[3],props[4])
|
||||
self.game.gameloop.summon(e)
|
||||
|
||||
def draw(self):
|
||||
@ -39,7 +40,7 @@ class TilesetRenderer(BaseObject):
|
||||
self.layers = []
|
||||
self.spawns = []
|
||||
spawnlists = {"Spawns":self.spawns}
|
||||
ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon}
|
||||
ennemies = {"Robot":Robot,"Crate":Crate,"Balloon":Balloon,"Spring":Spring}
|
||||
self.queue = [] # For spawning ennemies after beeing initialized
|
||||
if "layers" in json.keys() and type(json["layers"]).__name__=="list":
|
||||
solidlayer = False
|
||||
@ -62,9 +63,12 @@ class TilesetRenderer(BaseObject):
|
||||
for entity in layer["entities"]:
|
||||
x,y = entity["x"],entity["y"]
|
||||
nodes = []
|
||||
customvalues = {}
|
||||
if "nodes" in entity.keys():
|
||||
nodes = entity["nodes"]
|
||||
self.queue.append((ennemies[entity["name"]],x,y,nodes))
|
||||
if "values" in entity.keys():
|
||||
customvalues = entity["values"]
|
||||
self.queue.append((ennemies[entity["name"]],x,y,nodes,customvalues))
|
||||
|
||||
|
||||
else: # J'ajoute un layer de tiles
|
||||
|