naming convention for most stuff but not all
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
Entity = {class = "Entity"}
|
||||
LoadedObjects.Entities = {}
|
||||
|
||||
function Entity:New(x,y)
|
||||
function Entity:new(x,y)
|
||||
local o = {}
|
||||
|
||||
o.pos = {x = x, y = y}
|
||||
@@ -9,7 +9,7 @@ function Entity:New(x,y)
|
||||
|
||||
o.direction = 0
|
||||
|
||||
o.boxCollision = {
|
||||
o.box = {
|
||||
from = {x = x, y = y},
|
||||
to = {x = x, y = y},
|
||||
}
|
||||
@@ -30,7 +30,7 @@ function Entity:New(x,y)
|
||||
return o
|
||||
end
|
||||
|
||||
function Entity:CheckNearest(type,maxdistance)
|
||||
function Entity:checkNearest(type,maxdistance)
|
||||
local return_entity = nil
|
||||
local shortest = -1
|
||||
for _, entity in pairs(LoadedObjects.Entities) do
|
||||
@@ -51,15 +51,15 @@ function Entity:CheckNearest(type,maxdistance)
|
||||
return return_entity
|
||||
end
|
||||
|
||||
function Entity:Smart()
|
||||
function Entity:doLogic()
|
||||
end
|
||||
|
||||
function Entity:Move()
|
||||
function Entity:move()
|
||||
self.pos.x = self.pos.x + self.vel.x
|
||||
self.pos.y = self.pos.y + self.vel.y
|
||||
end
|
||||
|
||||
function Entity:CollisionMove()
|
||||
function Entity:moveWithCollision()
|
||||
local r = false
|
||||
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then
|
||||
self.pos.x = self.pos.x + self.vel.x
|
||||
@@ -76,7 +76,7 @@ function Entity:CollisionMove()
|
||||
return r
|
||||
end
|
||||
|
||||
function Entity:LightAdjust(x,y)
|
||||
function Entity:adjustLight(x,y)
|
||||
if self.light ~= nil then
|
||||
local x = x or 0
|
||||
local y = y or 0
|
||||
@@ -85,9 +85,9 @@ function Entity:LightAdjust(x,y)
|
||||
end
|
||||
end
|
||||
|
||||
function Entity:Kill()
|
||||
function Entity:kill()
|
||||
if self.light ~= nil then
|
||||
self.light:Kill()
|
||||
self.light:kill()
|
||||
end
|
||||
if self.id ~= nil then
|
||||
for _, e in pairs(LoadedObjects.Entities) do
|
||||
@@ -100,7 +100,7 @@ function Entity:Kill()
|
||||
self = nil
|
||||
end
|
||||
|
||||
function Entity:CheckVisionLine(entity,range)
|
||||
function Entity:checkVisionLine(entity,range)
|
||||
local target_x = entity.pos.x + entity.target_offset.x
|
||||
local target_y = entity.pos.y + entity.target_offset.y
|
||||
|
||||
@@ -128,10 +128,10 @@ function Entity:CheckVisionLine(entity,range)
|
||||
return not is_colliding
|
||||
end
|
||||
|
||||
function Entity:Draw(animation)
|
||||
function Entity:draw(animation)
|
||||
local c1, c2, c3, a = love.graphics.getColor()
|
||||
love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3],self.sprite_alpha)
|
||||
animation:Draw(
|
||||
animation:draw(
|
||||
self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x,
|
||||
self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y,
|
||||
self.sprite_rotation,
|
||||
@@ -148,15 +148,15 @@ function Entity:centerOffset(animation,x,y)
|
||||
self.sprite_offset.y = animation.imgs[1]:getHeight()/2 + y
|
||||
end
|
||||
|
||||
function Entity:getBoundingBox(animation,top,left,bottom,right)
|
||||
function Entity:createBox(animation,top,left,bottom,right)
|
||||
local left = left or 0
|
||||
local right = right or 0
|
||||
local top = top or 0
|
||||
local bottom = bottom or 0
|
||||
self.boxCollision.from.x = -animation.imgs[1]:getWidth()/2 + left
|
||||
self.boxCollision.to.x = animation.imgs[1]:getWidth()/2 + right
|
||||
self.boxCollision.from.y = -animation.imgs[1]:getHeight()/2 + top
|
||||
self.boxCollision.to.y = animation.imgs[1]:getHeight()/2 + bottom
|
||||
self.box.from.x = -animation.imgs[1]:getWidth()/2 + left
|
||||
self.box.to.x = animation.imgs[1]:getWidth()/2 + right
|
||||
self.box.from.y = -animation.imgs[1]:getHeight()/2 + top
|
||||
self.box.to.y = animation.imgs[1]:getHeight()/2 + bottom
|
||||
end
|
||||
|
||||
-- checks if the the reciever would collide with an object if it was positioned at the given point.
|
||||
@@ -169,10 +169,10 @@ function Entity:getCollidingAt(x,y,object)
|
||||
for _, collision in pairs(object) do
|
||||
if collision.disable then
|
||||
-- Dont calculate if disabled
|
||||
elseif x + self.boxCollision.from.x < collision.to.x
|
||||
and x + self.boxCollision.to.x > collision.from.x
|
||||
and y + self.boxCollision.from.y < collision.to.y
|
||||
and y + self.boxCollision.to.y > collision.from.y
|
||||
elseif x + self.box.from.x < collision.to.x
|
||||
and x + self.box.to.x > collision.from.x
|
||||
and y + self.box.from.y < collision.to.y
|
||||
and y + self.box.to.y > collision.from.y
|
||||
then
|
||||
collision.isColliding = true
|
||||
return collision
|
||||
@@ -182,10 +182,10 @@ function Entity:getCollidingAt(x,y,object)
|
||||
end
|
||||
|
||||
function Entity:isCollidingWith(entity)
|
||||
return self.pos.x + self.boxCollision.from.x < entity.pos.x + entity.boxCollision.to.x
|
||||
and entity.pos.x + entity.boxCollision.from.x < self.pos.x + self.boxCollision.to.x
|
||||
and self.pos.y + self.boxCollision.from.y < entity.pos.y + entity.boxCollision.to.y
|
||||
and entity.pos.y + entity.boxCollision.from.y < self.pos.y + self.boxCollision.to.y
|
||||
return self.pos.x + self.box.from.x < entity.pos.x + entity.box.to.x
|
||||
and entity.pos.x + entity.box.from.x < self.pos.x + self.box.to.x
|
||||
and self.pos.y + self.box.from.y < entity.pos.y + entity.box.to.y
|
||||
and entity.pos.y + entity.box.from.y < self.pos.y + self.box.to.y
|
||||
end
|
||||
|
||||
function Entity:isCollidingAtAll(x,y)
|
||||
@@ -202,7 +202,7 @@ function Entity:isCollidingAtAll(x,y)
|
||||
return result
|
||||
end
|
||||
|
||||
function Entity:CheckVisionLineDebug(entity,range)
|
||||
function Entity:checkVisionLineDebug(entity,range)
|
||||
local c1, c2, c3, a = love.graphics.getColor()
|
||||
|
||||
local target_x = entity.pos.x + entity.target_offset.x
|
||||
@@ -237,7 +237,7 @@ function Entity:CheckVisionLineDebug(entity,range)
|
||||
love.graphics.setColor(c1,c2,c3,a)
|
||||
end
|
||||
|
||||
function Entity:Debug()
|
||||
function Entity:debug()
|
||||
-- draw center GREEN
|
||||
love.graphics.setColor(0,1,0)
|
||||
love.graphics.circle("fill", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, 1)
|
||||
@@ -245,10 +245,10 @@ function Entity:Debug()
|
||||
love.graphics.setColor(1,0,1)
|
||||
love.graphics.rectangle(
|
||||
"line",
|
||||
-Camera.pos.x + self.pos.x + self.boxCollision.from.x,
|
||||
-Camera.pos.y + self.pos.y + self.boxCollision.from.y,
|
||||
-Camera.pos.x + self.pos.x + self.boxCollision.to.x -(-Camera.pos.x + self.pos.x + self.boxCollision.from.x),
|
||||
-Camera.pos.y + self.pos.y + self.boxCollision.to.y -(-Camera.pos.y + self.pos.y + self.boxCollision.from.y)
|
||||
-Camera.pos.x + self.pos.x + self.box.from.x,
|
||||
-Camera.pos.y + self.pos.y + self.box.from.y,
|
||||
-Camera.pos.x + self.pos.x + self.box.to.x -(-Camera.pos.x + self.pos.x + self.box.from.x),
|
||||
-Camera.pos.y + self.pos.y + self.box.to.y -(-Camera.pos.y + self.pos.y + self.box.from.y)
|
||||
)
|
||||
if self.target ~= nil then
|
||||
love.graphics.line(
|
||||
@@ -260,10 +260,10 @@ function Entity:Debug()
|
||||
end
|
||||
end
|
||||
|
||||
function Entity:HandleAnimation()
|
||||
function Entity:handleAnimation()
|
||||
end
|
||||
|
||||
function Entity:DrawBackground()
|
||||
function Entity:drawBackground()
|
||||
end
|
||||
|
||||
require "code/entities/kupo"
|
||||
|
||||
Reference in New Issue
Block a user