refactor(levels): use Actor2D initialization functions
This commit is contained in:
parent
4ee17f01b6
commit
cd7e381672
|
@ -9,7 +9,7 @@ function Debris:new(world, x, y, speed, dir, timelimit)
|
|||
self.timelimit = timelimit or 2
|
||||
self:setMotionDirection(dir, speed)
|
||||
self.grav = 1
|
||||
self.bounce = 0.5
|
||||
self:setBounceFactor(0.5)
|
||||
self.frc = 0.046875*60*1.5
|
||||
self.rotation = love.math.random(0, 360)
|
||||
end
|
||||
|
|
|
@ -1,42 +1,27 @@
|
|||
local Base = require "core.modules.world.actors.actor2D"
|
||||
local Entity = Base:extend() -- On créer la classe des entitées, c'est la classe de base
|
||||
|
||||
function Entity:new(world, type, x, y, w, h) -- On enregistre une nouvelle entité, avec par défaut sa hitbox.
|
||||
self:initPhysics(world, type, x, y, w, h)
|
||||
self.destroyed = false
|
||||
self.registered = false
|
||||
self:setDebugColor(0,0,0)
|
||||
function Entity:new(world, type, x, y, w, h, isSolid)
|
||||
self.playerID = -1
|
||||
self.camera = world.scene.camera -- TODO: change that
|
||||
Entity.super.new(self, world, type, x, y, w, h, isSolid)
|
||||
end
|
||||
|
||||
function Entity:initPhysics(world, type, x, y, w, h)
|
||||
self:setManagers(world)
|
||||
self.camera = self.scene.camera
|
||||
self.type = type
|
||||
|
||||
self.gacc = 550
|
||||
self.xsp = 0
|
||||
self.ysp = 0
|
||||
|
||||
self.bounce = 0
|
||||
self.grav = 0
|
||||
function Entity:initMovement()
|
||||
Entity.super.initMovement(self)
|
||||
self.frc = 0
|
||||
end
|
||||
|
||||
self:initHitbox(x, y, w, h)
|
||||
function Entity:initGravity()
|
||||
self.grav = 0
|
||||
self.gacc = 550
|
||||
self.onGround = false
|
||||
|
||||
self.playerID = -1
|
||||
|
||||
self:register()
|
||||
end
|
||||
|
||||
function Entity:update(dt)
|
||||
|
||||
end
|
||||
|
||||
function Entity:canBounce(bounce)
|
||||
self.bounce = bounce
|
||||
end
|
||||
|
||||
function Entity:setMotion(xsp, ysp)
|
||||
self.xsp, self.ysp = xsp, ysp
|
||||
end
|
||||
|
@ -66,20 +51,6 @@ function Entity:friction(dt)
|
|||
end
|
||||
end
|
||||
|
||||
function Entity:changeSpeedToCollisionNormal(nx, ny)
|
||||
local xsp, ysp = self.xsp, self.ysp
|
||||
|
||||
if (nx < 0 and xsp > 0) or (nx > 0 and xsp < 0) then
|
||||
xsp = -xsp * self.bounce
|
||||
end
|
||||
|
||||
if (ny < 0 and ysp > 0) or (ny > 0 and ysp < 0) then
|
||||
ysp = -ysp * self.bounce
|
||||
end
|
||||
|
||||
self.xsp, self.ysp = xsp, ysp
|
||||
end
|
||||
|
||||
function Entity:purge()
|
||||
self:remove()
|
||||
end
|
||||
|
|
|
@ -24,11 +24,10 @@ function Player:new(world, x, y, playerID)
|
|||
self:getStats(playerID)
|
||||
self:lifeInit()
|
||||
self:initWeapon()
|
||||
self:initStats()
|
||||
|
||||
self.currentWeapon = 1
|
||||
|
||||
self:initMovement()
|
||||
|
||||
self:setDebugColor(0,255,0)
|
||||
end
|
||||
|
||||
|
@ -43,7 +42,7 @@ function Player:lifeInit()
|
|||
self.mp = self.stats.maxMP
|
||||
end
|
||||
|
||||
function Player:initMovement()
|
||||
function Player:initStats()
|
||||
self.maxxsp = 16*60
|
||||
self.maxysp = self.maxxsp
|
||||
self.topsp = 4.5*60
|
||||
|
|
Loading…
Reference in New Issue