chore(levels): rename Actor.collType to Actor.type

This commit is contained in:
Kazhnuz 2019-06-16 18:32:31 +02:00
parent 652771de5a
commit 666aa13565
7 changed files with 21 additions and 21 deletions

View File

@ -10,7 +10,7 @@ end
function Bullet:setFilter()
self.filter = function(item, other)
if (other.collType=="wall") then
if (other.type=="wall") then
return 'touch'
else
return nil
@ -26,7 +26,7 @@ function Bullet:update(dt)
for j=1,cols_len do
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()
end
end

View File

@ -2,8 +2,8 @@ local Entity = require "scenes.levels.entities.parent"
local Collision = Entity:extend()
function Collision:new(world, x, y, w, h, collType)
Collision.super.new(self, world, collType, x, y, w, h)
function Collision:new(world, x, y, w, h, type)
Collision.super.new(self, world, type, x, y, w, h)
self:setDebugColor(0,0,0)
end

View File

@ -16,7 +16,7 @@ end
function Debris:setFilter()
self.filter = function(item, other)
if ((other.collType=="wall")) then
if ((other.type=="wall")) then
return 'bounce'
else
return nil

View File

@ -4,7 +4,7 @@ local Loot = Entity:extend()
function Loot:new(world, x, y, name)
Loot.super.new(self, world, "loot", x, y, 16, 16)
self.collType = "loot"
self.type = "loot"
self.sprite = name
end

View File

@ -1,18 +1,18 @@
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.
self:initPhysics(world, collType, x, y, w, h)
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)
end
function Entity:initPhysics(world, collType, x, y, w, h)
function Entity:initPhysics(world, type, x, y, w, h)
self.scene = world.scene
self.world = world
self.camera = self.scene.camera
self.obj = self.world.obj
self.collType = collType
self.type = type
self.gacc = 550
self.xsp = 0

View File

@ -91,12 +91,12 @@ end
function Player:setFilter()
self.filter = function(item, other)
if (other.collType == "wall") then return 'slide'
elseif (other.collType == "block") then return 'slide'
elseif (other.collType == "platform") and
if (other.type == "wall") then return 'slide'
elseif (other.type == "block") then return 'slide'
elseif (other.type == "platform") and
(self.ysp > 0) and
((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
end
end
@ -106,7 +106,7 @@ function Player:resolveCollisions(cols, cols_len)
local cols, cols_len = cols, cols_len
for j=1,cols_len do
local other = cols[j].other
if (other.collType == "loot") then
if (other.type == "loot") then
other:takeLoot()
end
end

View File

@ -12,11 +12,11 @@ end
function Weapon:setFilter()
self.filter = function(item, other)
if (other.collType=="wall") then
if (other.type=="wall") then
return 'touch'
elseif (other.collType=="block") then
elseif (other.type=="block") then
return "touch"
elseif (other.collType=="ennemy") then
elseif (other.type=="ennemy") then
return "touch"
else
return nil
@ -33,14 +33,14 @@ function Weapon:update(dt)
for j=1,cols_len do
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()
end
if other.collType=="block" and (self.life == 1) then
if other.type=="block" and (self.life == 1) then
self:destroy()
other:breakBlock()
end
if other.collType=="ennemy" and (self.life == 1) then
if other.type=="ennemy" and (self.life == 1) then
self:destroy()
other:getDamage(1)
end