Bullet code not working.
Posted: Wed Jan 01, 2014 9:22 am
Hello i tried to make my character shoot a pic that looks like laser here is the code
The code works fine but when i press the key it does nothing, Got any ideas anyone, btw my main file has bin linked up with this one so that's not the problem Thanks and happy new year
~CreeperCats Dev
Code: Select all
bullet_speed = 50
bullet ={}
function bullet.spawn(x,y,dir)
table.insert(bullet,{width = 50, height = 50, x = x, y = y, dir = dir})
end
function bullet.draw()
for i,v in ipairs(bullet) do
love.graphics.newImage("images/Laser.png",v.x,v.y,v.width,v.height)
end
end
function bullet.update(dt)
for i,v in ipairs(bullet) do
if v.dir == "up" then
v.x = v.x + bullet_speed * dt
end
end
end
function bullet.shoot(key)
if key == "up" then
bullet.spawn(player.y + player.height, player.y + player.height/2, "up" )
end
end
~CreeperCats Dev