I you need a shooting system, I have sumtin perfect for ya!! PM, its secret ;)
Printable View
I you need a shooting system, I have sumtin perfect for ya!! PM, its secret ;)
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'sQuote:
Originally 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
you haven't defined current bullet to a number yet. You need to define the variable currentbullet to first before it can be checked to see if it is less then 5. so put currentbullet = 1 line 33.
BTW, why not use my system for bullets, I sent you?
cause i have to add an enemy and i am not doing that right now
ok, so anyways put currentbullet = 1 before line 33. That way you not comparing a nil variable to with a number ;)
k i fixed that problem but know i have a bullet that just stays in one spot and doesent move
http://i59.photobucket.com/albums/g2...screenshot.png
oh and i forgot to show u guys the bg's that pspdemon made
http://i59.photobucket.com/albums/g297/ninja9393/1.png
http://i59.photobucket.com/albums/g297/ninja9393/2.png
http://i59.photobucket.com/albums/g297/ninja9393/3.png
I think its because you not defining wether the variable diretion is left or right.... Also when you have
if pad:circle() then
bulletsetup()
end
I think you need to replace that wil bulletfire() and then put bulletsetup() where bulletfir is now...
IT WORKS KINDA NOT GOOD but it shoots more then one bullet
scrren:http://i59.photobucket.com/albums/g2...reenshot-1.png
yeah, evilmanas bullet system is meant to shoot 5 and only 5 bullets
Mine on the other hand is not. It shoots one bullet when ever you press circle
im glad is going well. hope for the best :)