Help with my game
I'm trying to make a game, but I'm having trouble making the bullets appear, continue until they leave the screen, then delete themselves/disappear. Any ideas?
init = function()
gameState = "menu"
wave = 1
xp = 0
end
initBullet = function()
bullet = object
x = 0
y = 0
rotation = 0
end
end
shootBullet = function()
screen.drawSprite("bullet", bullet.x, bullet.y, 10, 10)
end
update = function()
if gameState == "shoot" then
if keyboard.SPACE then
if shot == 1 then
shot = 0
audio.playSound("shot")
shootBullet()
end
else
shot = 1
end
if keyboard.LEFT then
angle += 4
else if keyboard.RIGHT then
angle -= 4
end
end
else
if gameState == "upgrade" or gameState == "menu" then
if mouse.press then
audio.playSound("click")
end
end
end
end
draw = function()
if gameState == "shoot" then
screen.clear()
screen.setDrawRotation(0)
max_xp = wave * 100
screen.setFont("grapesoda")
screen.drawText("Wave: " + wave,0,90,15,"rgb(255,255,255)")
screen.drawText("XP: " + xp + "/" + max_xp,0,80,10,"rgb(255,255,255)")
screen.drawSprite("base", 0, 0, 25, 25)
screen.setDrawRotation(angle)
screen.drawSprite("barrel", 0, 0, 25, 25)
else if gameState == "menu" then
screen.drawSprite("startbutton", 0, 0, 50, 50)
if mouse.y < 10 and mouse.y > -10 and mouse.x < 10 and mouse.x > -10 then
if mouse.press then
gameState = "shoot"
end
end
end
end
end