From a7a0bde8eaba259f65bcb765e0318664ce1d715f Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 2 Feb 2020 08:27:33 +0100 Subject: [PATCH] feat: add basic autorun on shoot maps --- .../game/modules/world/actors/player.lua | 34 ++++++++++++------- .../game/modules/world/parent.lua | 1 + .../game/modules/world/shoot.lua | 1 + 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/sonic-bluestreak.love/game/modules/world/actors/player.lua b/sonic-bluestreak.love/game/modules/world/actors/player.lua index 94c6d4a..60e96f8 100644 --- a/sonic-bluestreak.love/game/modules/world/actors/player.lua +++ b/sonic-bluestreak.love/game/modules/world/actors/player.lua @@ -28,18 +28,7 @@ end function Player:updateStart(dt) self.xfrc, self.yfrc = 480*3, 480*3 - if self.keys["up"].isDown then - self.ysp = -160 - end - if self.keys["down"].isDown then - self.ysp = 160 - end - if self.keys["left"].isDown then - self.xsp = -160 - end - if self.keys["right"].isDown then - self.xsp = 160 - end + self:basicMovements() if self.keys["A"].isPressed and (self.onGround) then self.zsp = 280*1.33 @@ -50,6 +39,27 @@ function Player:updateStart(dt) end end +function Player:basicMovements() + + if self.keys["up"].isDown then + self.ysp = -160 + end + if self.keys["down"].isDown then + self.ysp = 160 + end + if (self.world.autorun == true) then + self.xsp = 160 + else + if self.keys["left"].isDown then + self.xsp = -160 + end + if self.keys["right"].isDown then + self.xsp = 160 + end + end + +end + function Player:collisionResponse(collision) if collision.other.type == "collectible" then collision.other.owner:getPicked(self) diff --git a/sonic-bluestreak.love/game/modules/world/parent.lua b/sonic-bluestreak.love/game/modules/world/parent.lua index f8cea6c..724f59d 100644 --- a/sonic-bluestreak.love/game/modules/world/parent.lua +++ b/sonic-bluestreak.love/game/modules/world/parent.lua @@ -10,6 +10,7 @@ function ParentWorld:new(scene, maptype, mapname) ParentWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype) self.mapname = mapname + self.autorun = false end function ParentWorld:createMapController() diff --git a/sonic-bluestreak.love/game/modules/world/shoot.lua b/sonic-bluestreak.love/game/modules/world/shoot.lua index b3f99d7..63a692c 100644 --- a/sonic-bluestreak.love/game/modules/world/shoot.lua +++ b/sonic-bluestreak.love/game/modules/world/shoot.lua @@ -8,6 +8,7 @@ function ShootWorld:new(scene, mapname) ShootWorld.super.new(self, scene, "shoot", mapname) self.mapname = mapname + self.autorun = true end function ShootWorld:getViewCenter(x, y)