this is what my code looks like:
Code: Select all
require "AnimatedSprite"
HC = require 'hardoncollider'
Polygon = require 'hardoncollider.polygon' --Including the file
diag = 0
collide = false
x = 400
y = 400
function love.load()
love.graphics.setDefaultFilter("nearest", "nearest")
player = GetInstance ("player.lua")
level = GetInstance ("level.lua")
subject = GetInstance ("subject.lua")
beam = GetInstance ("beam.lua")
emitter = HC.circle(400,300,20)
poly = HC.polygon(10,35, 40,50, 70,35, 40,20)
poly:moveTo(x+25,y+80)
end
function love.update(dt)
love.mouse.setVisible(false)
UpdateInstance(player, dt)
UpdateInstance(level, dt)
UpdateInstance(beam, dt)
UpdateInstance(subject, dt)
poly:moveTo(x+25,y+80)
for shape, delta in pairs(HC.collisions(poly)) do
collide=true
end
if collide == false then
if(love.keyboard.areDown('s','a')) then
y=y+dt+0.83
x=x-dt-1.7
player.curr_anim = player.sprite.animations_names[4]
diag = 1
frozen=false
elseif(love.keyboard.areDown('s','d')) then
y=y+dt+0.83
x=x+dt+1.7
player.curr_anim = player.sprite.animations_names[10]
diag=2
elseif(love.keyboard.areDown('w','a')) then
y=y-dt-0.83
x=x-dt-1.7
player.curr_anim = player.sprite.animations_names[6]
diag=3
elseif(love.keyboard.areDown('w','d')) then
y=y-dt-0.83
x=x+dt+1.7
player.curr_anim = player.sprite.animations_names[8]
diag=4
elseif(love.keyboard.isDown('w')) then
y=y-dt-1.6
player.curr_anim = player.sprite.animations_names[7]
diag=0
elseif(love.keyboard.isDown('a')) then
x=x-dt-1.6
player.curr_anim = player.sprite.animations_names[5]
elseif(love.keyboard.isDown('s')) then
y=y+dt+1.6
diag=0
player.curr_anim = player.sprite.animations_names[3]
elseif(love.keyboard.isDown('d')) then
x=x+dt+1.6
player.curr_anim = player.sprite.animations_names[9]
end
end
end