chore(levels): rename Actor.collType to Actor.type
This commit is contained in:
parent
652771de5a
commit
666aa13565
|
@ -10,7 +10,7 @@ end
|
||||||
|
|
||||||
function Bullet:setFilter()
|
function Bullet:setFilter()
|
||||||
self.filter = function(item, other)
|
self.filter = function(item, other)
|
||||||
if (other.collType=="wall") then
|
if (other.type=="wall") then
|
||||||
return 'touch'
|
return 'touch'
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
|
@ -26,7 +26,7 @@ function Bullet:update(dt)
|
||||||
|
|
||||||
for j=1,cols_len do
|
for j=1,cols_len do
|
||||||
local other = cols[j].other
|
local other = cols[j].other
|
||||||
if other.collType=="wall" and (self.life == 1) then
|
if other.type=="wall" and (self.life == 1) then
|
||||||
self:destroy()
|
self:destroy()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,8 @@ local Entity = require "scenes.levels.entities.parent"
|
||||||
|
|
||||||
local Collision = Entity:extend()
|
local Collision = Entity:extend()
|
||||||
|
|
||||||
function Collision:new(world, x, y, w, h, collType)
|
function Collision:new(world, x, y, w, h, type)
|
||||||
Collision.super.new(self, world, collType, x, y, w, h)
|
Collision.super.new(self, world, type, x, y, w, h)
|
||||||
|
|
||||||
self:setDebugColor(0,0,0)
|
self:setDebugColor(0,0,0)
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ end
|
||||||
|
|
||||||
function Debris:setFilter()
|
function Debris:setFilter()
|
||||||
self.filter = function(item, other)
|
self.filter = function(item, other)
|
||||||
if ((other.collType=="wall")) then
|
if ((other.type=="wall")) then
|
||||||
return 'bounce'
|
return 'bounce'
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -4,7 +4,7 @@ local Loot = Entity:extend()
|
||||||
|
|
||||||
function Loot:new(world, x, y, name)
|
function Loot:new(world, x, y, name)
|
||||||
Loot.super.new(self, world, "loot", x, y, 16, 16)
|
Loot.super.new(self, world, "loot", x, y, 16, 16)
|
||||||
self.collType = "loot"
|
self.type = "loot"
|
||||||
self.sprite = name
|
self.sprite = name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
local Entity = Object:extend() -- On créer la classe des entitées, c'est la classe de base
|
local Entity = Object:extend() -- On créer la classe des entitées, c'est la classe de base
|
||||||
|
|
||||||
function Entity:new(world, collType, x, y, w, h) -- On enregistre une nouvelle entité, avec par défaut sa hitbox.
|
function Entity:new(world, type, x, y, w, h) -- On enregistre une nouvelle entité, avec par défaut sa hitbox.
|
||||||
self:initPhysics(world, collType, x, y, w, h)
|
self:initPhysics(world, type, x, y, w, h)
|
||||||
self.destroyed = false
|
self.destroyed = false
|
||||||
self.registered = false
|
self.registered = false
|
||||||
self:setDebugColor(0,0,0)
|
self:setDebugColor(0,0,0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Entity:initPhysics(world, collType, x, y, w, h)
|
function Entity:initPhysics(world, type, x, y, w, h)
|
||||||
self.scene = world.scene
|
self.scene = world.scene
|
||||||
self.world = world
|
self.world = world
|
||||||
self.camera = self.scene.camera
|
self.camera = self.scene.camera
|
||||||
self.obj = self.world.obj
|
self.obj = self.world.obj
|
||||||
self.collType = collType
|
self.type = type
|
||||||
|
|
||||||
self.gacc = 550
|
self.gacc = 550
|
||||||
self.xsp = 0
|
self.xsp = 0
|
||||||
|
|
|
@ -91,12 +91,12 @@ end
|
||||||
|
|
||||||
function Player:setFilter()
|
function Player:setFilter()
|
||||||
self.filter = function(item, other)
|
self.filter = function(item, other)
|
||||||
if (other.collType == "wall") then return 'slide'
|
if (other.type == "wall") then return 'slide'
|
||||||
elseif (other.collType == "block") then return 'slide'
|
elseif (other.type == "block") then return 'slide'
|
||||||
elseif (other.collType == "platform") and
|
elseif (other.type == "platform") and
|
||||||
(self.ysp > 0) and
|
(self.ysp > 0) and
|
||||||
((self.y+24) <= other.y) then return 'slide'
|
((self.y+24) <= other.y) then return 'slide'
|
||||||
elseif (other.collType == "loot") then return 'cross'
|
elseif (other.type == "loot") then return 'cross'
|
||||||
else return nil
|
else return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -106,7 +106,7 @@ function Player:resolveCollisions(cols, cols_len)
|
||||||
local cols, cols_len = cols, cols_len
|
local cols, cols_len = cols, cols_len
|
||||||
for j=1,cols_len do
|
for j=1,cols_len do
|
||||||
local other = cols[j].other
|
local other = cols[j].other
|
||||||
if (other.collType == "loot") then
|
if (other.type == "loot") then
|
||||||
other:takeLoot()
|
other:takeLoot()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,11 +12,11 @@ end
|
||||||
|
|
||||||
function Weapon:setFilter()
|
function Weapon:setFilter()
|
||||||
self.filter = function(item, other)
|
self.filter = function(item, other)
|
||||||
if (other.collType=="wall") then
|
if (other.type=="wall") then
|
||||||
return 'touch'
|
return 'touch'
|
||||||
elseif (other.collType=="block") then
|
elseif (other.type=="block") then
|
||||||
return "touch"
|
return "touch"
|
||||||
elseif (other.collType=="ennemy") then
|
elseif (other.type=="ennemy") then
|
||||||
return "touch"
|
return "touch"
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
|
@ -33,14 +33,14 @@ function Weapon:update(dt)
|
||||||
|
|
||||||
for j=1,cols_len do
|
for j=1,cols_len do
|
||||||
local other = cols[j].other
|
local other = cols[j].other
|
||||||
if other.collType=="wall" and (self.life == 1) then
|
if other.type=="wall" and (self.life == 1) then
|
||||||
self:destroy()
|
self:destroy()
|
||||||
end
|
end
|
||||||
if other.collType=="block" and (self.life == 1) then
|
if other.type=="block" and (self.life == 1) then
|
||||||
self:destroy()
|
self:destroy()
|
||||||
other:breakBlock()
|
other:breakBlock()
|
||||||
end
|
end
|
||||||
if other.collType=="ennemy" and (self.life == 1) then
|
if other.type=="ennemy" and (self.life == 1) then
|
||||||
self:destroy()
|
self:destroy()
|
||||||
other:getDamage(1)
|
other:getDamage(1)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue