ok i compleatly re did my shooting code
erased every shooting bit and orginized it corectly
But now i have an error message saying
here is my code but i dont see any problem with line 33 cause the shooting code is abuot the same as evil mana'sOriginally Posted by lua error
so here is my code
---------player loading--------
player1 = Image.load("sprites/right1.png")
player2 = Image.load("sprites/right2.png")
player3 = Image.load("sprites/left1.png")
player4 = Image.load("sprites/left2.png")
morphball = Image.load("morphball.png")
-------backgound and other loading---
background = Image.load("background.png")
bullet = Image.load("bullet.png")
bullet1 = Image.load("bullet1.png")
----player properties----
player = {}
player.img= player1
player.gravity = 190
player.y = 100
player.x = 200
player.jumpspeed = 10
player.jumpstate = "ground"
--Create Array for Bullets
BulletInfo = {}
for a = 1,5 do
BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = player.x + 32,
y = player.y + 16 }
end
function bulletSetup()
--Increase the current bullet by one, or reset it to 1
if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end
if direction == "left" then
BulletInfo[currentBullet].x = player.x
BulletInfo[currentBullet].y = player.y + 16
end
if direction == "right" then
BulletInfo[currentBullet].x = player.x + 32
BulletInfo[currentBullet].y = player.y + 16
end
BulletInfo[currentBullet].direction = direction
BulletInfo[currentBullet].firing = true
end
function bulletFire()
for i = 1,5 do
if BulletInfo[i].firing == true then
if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end
if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end
if BulletInfo[i].direction == "up" then BulletInfo[i].y = BulletInfo[i].y - 10 end
if BulletInfo[i].direction == "down" then BulletInfo[i].y = BulletInfo[i].y + 10 end
screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic)
end
if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then
BulletInfo[i].firing = false
end
end
end
function move()
rand=math.random(1,2)
if pad:left() and rand==1 then
player.x= player.x -4
player.img= player3
end
if pad:left() and rand==2 then
player.x= player.x -4
player.img= player4
end
if pad:right() and rand==1 then
player.x=player.x +4
player.img= player1
end
if pad:right() and rand==2 then
player.x= player.x +4
player.img= player2
end
end
while true do
pad = Controls.read()
screen:clear()
move()
screen:blit(0,0,background,false)
pad = Controls.read()
if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping"
end
if pad:circle() and oldpad:circle() ~= pad:circle() then
bulletSetup()
end
if pad:down() and player.jumpstate == "ground" then
player.img = morphball
end
if pad:right() and player.img == morphball then
player.x=player.x-4
end
if pad:left() and player.img == morphball then
player.x=player.x+4
end
if player.x >= 445 then
screen:clear()
dofile "credits.lua"
end
if player.jumpstate == "jumping" then
player.jumpspeed = player.jumpspeed - 0.5
player.gravity = player.gravity - player.jumpspeed
end
if player.gravity < 0 then
player.jumpstate = "falling"
end
if player.gravity < 190 and player.jumpstate == "falling" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 190 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 190 then player.gravity = 230 end
player.y = player.gravity
screen:blit(player.x,player.y,player.img)
bulletFire()
screen.flip()
screen.waitVblankStart()
end
hope u guys can help
Bookmarks