diff --git a/gamedata/maps/TulipFields/map.json b/gamedata/maps/TulipFields/map.json index abe5fb3..bff034b 100644 --- a/gamedata/maps/TulipFields/map.json +++ b/gamedata/maps/TulipFields/map.json @@ -2481,10 +2481,14 @@ {"x": 576, "y": 160} ] }, - {"name": "Crate", "id": 4, "_eid": "16023910", "x": 832, "y": 240, "originX": 0, "originY": 0}, - {"name": "Crate", "id": 6, "_eid": "16023910", "x": 896, "y": 240, "originX": 0, "originY": 0}, - {"name": "Crate", "id": 7, "_eid": "16023910", "x": 864, "y": 240, "originX": 0, "originY": 0}, - {"name": "Crate", "id": 8, "_eid": "16023910", "x": 672, "y": 144, "originX": 0, "originY": 0} + {"name": "Crate", "id": 9, "_eid": "16023910", "x": 592, "y": 192, "originX": 0, "originY": 0}, + {"name": "Crate", "id": 10, "_eid": "16023910", "x": 608, "y": 192, "originX": 0, "originY": 0}, + {"name": "Crate", "id": 11, "_eid": "16023910", "x": 624, "y": 192, "originX": 0, "originY": 0}, + {"name": "Crate", "id": 12, "_eid": "16023910", "x": 640, "y": 192, "originX": 0, "originY": 0}, + {"name": "Crate", "id": 13, "_eid": "16023910", "x": 640, "y": 208, "originX": 0, "originY": 0}, + {"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} ] } ] diff --git a/gamedata/objects/combat/ennemies/crate.py b/gamedata/objects/combat/ennemies/crate.py index 67622ec..6427d6f 100644 --- a/gamedata/objects/combat/ennemies/crate.py +++ b/gamedata/objects/combat/ennemies/crate.py @@ -10,6 +10,8 @@ class Crate(Ennemy): self.deadsprite = game.sprite_lib["crate/broke.png"] self.rect[2],self.rect[3] = self.sprite.get_size() + + self.canhit = False def step(self): super().step() diff --git a/gamedata/objects/combat/ennemies/ennemy.py b/gamedata/objects/combat/ennemies/ennemy.py index 9a6f3d4..9d51277 100644 --- a/gamedata/objects/combat/ennemies/ennemy.py +++ b/gamedata/objects/combat/ennemies/ennemy.py @@ -16,6 +16,8 @@ class Ennemy(Movable): self.particleoffsetx = 0 self.particleoffsety = 0 + self.canhit = True + self.dustparticles = game.getSpriteDir("particles/dust/") def step(self): @@ -26,6 +28,15 @@ class Ennemy(Movable): if not self.player: self.player = next(iter(self.game.gameloop.findname("Player")),None) else: + if self.canhit: + if self.rect.colliderect(self.player): + # Knock it horizontally + if self.player.rect[0]>self.rect[0]: + hor = 1 + else: + hor = -1 + self.player.horkb = hor*6 + self.player.verkb = self.player.gravityway*-3 if self.player.canhit: if self.rect.colliderect(self.player.hitrect): # Die diff --git a/gamedata/objects/combat/player.py b/gamedata/objects/combat/player.py index a8d8a4d..aa82bdf 100644 --- a/gamedata/objects/combat/player.py +++ b/gamedata/objects/combat/player.py @@ -37,7 +37,7 @@ class Player(Movable): self.horkb = 0 self.verkb = 0 - self.reducekb = 50 + self.reducekb = 15 self.multkb = 1 self.attackstate = None @@ -82,8 +82,11 @@ class Player(Movable): self.leaptimer = self.leapmaxtimer # Outside, reset the timer if not self.game.globals["hitpose"]: + + canmove = (abs(self.verkb)+1)*(abs(self.horkb)+1)<2 keys = self.game.inputs["keys"] - if self.controlled: + self.horspd = 0 + if self.controlled and canmove: self.horspd=(keys["right"]["pressed"]-keys["left"]["pressed"])*self.game.dt*self.speed if self.attackstate: self.attackstate(self) # Si je suis sur le sol @@ -138,9 +141,11 @@ class Player(Movable): # Reducing the knockback if self.horkb>0: - self.horkb = max(0,self.horkb-self.reducekb)*self.game.dt + self.horkb -= self.reducekb*self.game.dt + self.horkb = max(0,self.horkb) if self.horkb<0: - self.horkb = min(0,self.horkb+self.reducekb)*self.game.dt + self.horkb += self.reducekb*self.game.dt + self.horkb = min(0,self.horkb) if self.verkb>0: self.verkb = max(0,self.verkb-self.reducekb)*self.game.dt if self.verkb<0: