Code: Select all
require "collide"
Code: Select all
COLLIDE_UPDATE()
Error
main.lua:62: attempt to call global 'COLLIDE_UPDATE' (a nil value)
Traceback
main.lua:62: in function 'update'
[C]: in function 'xpcall'
When I take all of the individual functions and put them there without using the super function, it works.
For future reference after this point, gsize is what I multiply everything related to the coordinates, because my textures are 32x32, and I want them to be 64x64
collide.lua:
Code: Select all
function collidescreen(entity)
--Keep entity on tiles
if entity.x < 32 * gsize then
bump:setVolume(.5)
bump:play()
entity.x = 32 * gsize
end
if entity.x > (288 * gsize) - 32 * gsize then
bump:setVolume(.5)
bump:play()
entity.x = (288 * gsize) - 32 * gsize
end
if entity.y < 32 * gsize then
bump:setVolume(.5)
bump:play()
entity.y = 32 * gsize
end
if entity.y > (288 * gsize) - 32 * gsize then
bump:setVolume(.5)
bump:play()
entity.y = (288 * gsize) - 32 * gsize
end
end
function collideconveyorbelt(entity)
--Do entity conveyorbelt
if entity.x > 64 * gsize and entity.x < 96 * gsize and entity.y > 64 * gsize and entity.y < 96 * gsize then
entity.x = entity.x + 3.5
end
end
function COLLIDE_UPDATE()
collidescreen(player)
collidescreen(zombie)
collideconveyorbelt(player)
collideconveyorbelt(zombie)
end
love.update in main.lua:
Code: Select all
function love.update(dt)
music:play()
if gamestate ~= "paused" then
--WASD Controls
if love.keyboard.isDown("d") then
player.r = 90
player.x = player.x + player.speed * dt
elseif love.keyboard.isDown("a") then
player.r = 270
player.x = player.x - player.speed * dt
elseif love.keyboard.isDown("s") then
player.r = 180
player.y = player.y + player.speed * dt
elseif love.keyboard.isDown("w") then
player.r = 0
player.y = player.y - player.speed * dt
end
--Entity movement
zombie.loop = zombie.loop + zombie.inc * dt
if zombie.loop > 0 and zombie.loop <= 7 then
zombie.r = 0
zombie.y = zombie.y - zombie.speed * dt
elseif zombie.loop > 7 and zombie.loop <= 14 then
zombie.r = 180
zombie.y = zombie.y + zombie.speed * dt
elseif zombie.loop > 14 then
zombie.loop = 1
end
end
--Collision updates
COLLIDE_UPDATE()
end
Code: Select all
--Player entity statuses
player = {
x = 48 * gsize,
y = 48 * gsize,
speed = 125,
r = 0
}
--Zombie entity statuses
zombie = {
x = 240 * gsize,
y = 272 * gsize,
speed = 80,
r = 0,
loop = 1,
inc = 1
}
--Girl NPC entity statuses
girl = {
x = 80 * gsize,
y = 40 * gsize,
r = 180
}