use class() in more places

This commit is contained in:
binarycat 2022-03-16 21:01:04 -04:00
parent fa62e1428b
commit 8edcbe2d9b
10 changed files with 35 additions and 45 deletions

View File

@ -1,4 +1,4 @@
Collision = {} Collision = class()
LoadedObjects.Collisions = {} LoadedObjects.Collisions = {}
LoadedObjects.Platforms = {} LoadedObjects.Platforms = {}
@ -48,7 +48,6 @@ function Collision:new(ox,oy,tx,ty)
end end
setmetatable(o, self) setmetatable(o, self)
self.__index = self
return o return o
end end

View File

@ -1,8 +1,7 @@
Arrow = {} Arrow = class(Entity, {
Arrow.type = "Arrow" type = "Arrow",
Arrow.supertype = Entity.type display = Animation:new(animation.kupo.arrow),
Arrow.display = Animation:new(animation.kupo.arrow) })
setmetatable(Arrow, Entity)
function Arrow:new(x,y,rotation,speed) function Arrow:new(x,y,rotation,speed)

View File

@ -1,8 +1,7 @@
CursedBook = {} CursedBook = class(Entity, {
CursedBook.type = "CursedBook" type = "CursedBook",
CursedBook.supertype = Entity.type display = Animation:new(animation.cursed_book.flying),
CursedBook.display = Animation:new(animation.cursed_book.flying) })
setmetatable(CursedBook, Entity)
function CursedBook:new(x,y) function CursedBook:new(x,y)
local o = Entity:new(x,y) local o = Entity:new(x,y)

View File

@ -1,8 +1,7 @@
Candelabra = {} Candelabra = class(Decoration, {
Candelabra.type = "Candelabra" type = "Candelabra",
Candelabra.supertype = Decoration.type display = Animation:new(animation.decoration.candelabra),
Candelabra.display = Animation:new(animation.decoration.candelabra) })
setmetatable(Candelabra, Decoration)
function Candelabra:new(x,y) function Candelabra:new(x,y)
local light_data = {} local light_data = {}

View File

@ -1,8 +1,7 @@
Fairy = {} Fairy = class(Entity, {
Fairy.type = "Fairy" type = "Fairy",
Fairy.supertype = Entity.type display = Animation:new(animation.fairy.flying),
Fairy.display = Animation:new(animation.fairy.flying) })
setmetatable(Fairy, Entity)
function Fairy:new(x,y) function Fairy:new(x,y)
local o = Entity:new(x,y) local o = Entity:new(x,y)

View File

@ -1,8 +1,7 @@
HookAnchor = {} HookAnchor = class(Entity, {
HookAnchor.type = "HookAnchor" type = "HookAnchor",
HookAnchor.supertype = Entity.type display = Animation:new(animation.fairy.flying),
HookAnchor.display = Animation:new(animation.fairy.flying) })
setmetatable(HookAnchor, Entity)
function HookAnchor:new(x,y,hook_distance) function HookAnchor:new(x,y,hook_distance)
local o = Entity:new(x,y) local o = Entity:new(x,y)

View File

@ -1,8 +1,7 @@
Kupo = {} Kupo = class(Entity, {
Kupo.type = "Kupo" type = "Kupo",
Kupo.supertype = Entity.type display = Animation:new(animation.kupo.body),
Kupo.display = Animation:new(animation.kupo.body) })
setmetatable(Kupo, Entity)
function Kupo:new(x,y) function Kupo:new(x,y)
local o = Entity:new(x,y) local o = Entity:new(x,y)

View File

@ -1,9 +1,8 @@
LoadedObjects.Particles = {} LoadedObjects.Particles = {}
Particle = {} Particle = class(Entity, {
Particle.type = "Particle" type = "Particle",
Particle.supertype = Entity.type display = Animation:new(animation.particle.simple),
Particle.display = Animation:new(animation.particle.simple) })
setmetatable(Particle, Entity)
function Particle:new(x,y,particle_data) function Particle:new(x,y,particle_data)
local o = Entity:new(x,y) local o = Entity:new(x,y)

View File

@ -1,8 +1,7 @@
Player = {} Player = class(Entity, {
Player.type = "Player" type = "Player",
Player.supertype = Entity.type display = Animation:new(animation.nancy.idle),
Player.display = Animation:new(animation.nancy.idle) })
setmetatable(Player, Entity)
function Player:new(x,y) function Player:new(x,y)
local o = Entity:new(x,y) local o = Entity:new(x,y)

View File

@ -13,7 +13,7 @@ local function backspace(text)
return "" return ""
end end
Prompt = { Prompt = class(nil, {
-- defaults for instance variables -- defaults for instance variables
pos = { x = 10, y = 10 }, pos = { x = 10, y = 10 },
input = "", input = "",
@ -23,7 +23,7 @@ Prompt = {
color = {1,1,1,1}, color = {1,1,1,1},
background_color = {0,0,0,1}, background_color = {0,0,0,1},
active_prompt = nil, active_prompt = nil,
} })
function Prompt:cancelActive() function Prompt:cancelActive()
if Prompt.active_prompt then if Prompt.active_prompt then
Prompt.active_prompt.canceled = true Prompt.active_prompt.canceled = true
@ -33,7 +33,6 @@ end
function Prompt:new(o) function Prompt:new(o)
o = o or {} o = o or {}
setmetatable(o, self) setmetatable(o, self)
self.__index = self
return o return o
end end