Ive been working on a game, but for some reason the "bullet" im trying to spawn in just wont!?
This is my 'Main'
require "scripts.player"
require "scripts.bullet"
function love.load()
bulletShoot = love.graphics.newImage("pics/bullet.png")
playerPic = love.graphics.newImage("pics/player.png")
background = love.graphics.newImage("pics/background.jpg")
player_load()
bullet.load()
end
function love.update(dt)
player_update(dt)
bullet.update(dt)
end
function love.draw()
love.graphics.draw(background, 0, 0)
bullet.draw()
player_draw()
end
My 'Player' where I try to call it
function player_shoot(dt)
playerShootTimer = playerShootTimer * dt
if(playerShootTimer > playerShootTimerLim) then
if love.keyboard.isDown("space")then
bullet.spawn(playerX + (playerWidth / 2) - (bullet.width / 2), playerY)
end
end
end
function player_update(dt)
player_move(dt)
player_boundary()
player_shoot(dt)
end
and my 'Bullet' where I try to draw and spawn it
function bullet.spawn(x,y)
table.insert(bullet, {x = x, y = y})
end
function bullet.draw()
for i,v in ipairs(bullet) do
love.graphics.draw(bulletShoot, v.x, v.y, bullet.width, bullet.height)
end
end
things ive tried - ive changed the bullet to a filled square instead of calling the png - ive copied and pasted the bullet class from an existing(working) game ive made
none of these things have been useful. Any help is useful, thank you!
bullet.spawnyou add a table withxandymembers set, but inbullet.drawyou loop through every member ofbulletand attempt to draw using thosexandyvariables. Correct me if I'm wrong, but wouldn't that loop also include the functionsbullet.spawnandbullet.draw? - Thelmund