feat: add basic autorun on shoot maps

This commit is contained in:
Kazhnuz 2020-02-02 08:27:33 +01:00
parent 93ce28f3ba
commit a7a0bde8ea
3 changed files with 24 additions and 12 deletions

View file

@ -28,18 +28,7 @@ end
function Player:updateStart(dt) function Player:updateStart(dt)
self.xfrc, self.yfrc = 480*3, 480*3 self.xfrc, self.yfrc = 480*3, 480*3
if self.keys["up"].isDown then self:basicMovements()
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
if self.keys["A"].isPressed and (self.onGround) then if self.keys["A"].isPressed and (self.onGround) then
self.zsp = 280*1.33 self.zsp = 280*1.33
@ -50,6 +39,27 @@ function Player:updateStart(dt)
end end
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) function Player:collisionResponse(collision)
if collision.other.type == "collectible" then if collision.other.type == "collectible" then
collision.other.owner:getPicked(self) collision.other.owner:getPicked(self)

View file

@ -10,6 +10,7 @@ function ParentWorld:new(scene, maptype, mapname)
ParentWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype) ParentWorld.super.new(self, scene, "game.modules.world.actors", mappath, maptype)
self.mapname = mapname self.mapname = mapname
self.autorun = false
end end
function ParentWorld:createMapController() function ParentWorld:createMapController()

View file

@ -8,6 +8,7 @@ function ShootWorld:new(scene, mapname)
ShootWorld.super.new(self, scene, "shoot", mapname) ShootWorld.super.new(self, scene, "shoot", mapname)
self.mapname = mapname self.mapname = mapname
self.autorun = true
end end
function ShootWorld:getViewCenter(x, y) function ShootWorld:getViewCenter(x, y)