Page 10 of 13 FirstFirst ... 678910111213 LastLast
Results 91 to 100 of 125

Thread: Metroid:Return of the SA-X development

                  
   
  1. #91

    Default

    I you need a shooting system, I have sumtin perfect for ya!! PM, its secret

  2. #92
    DCEmu Coder ninja9393's Avatar
    Join Date
    Dec 2005
    Location
    Space Pirate Homeworld
    Age
    34
    Posts
    1,028
    Rep Power
    85

    Default

    ok i compleatly re did my shooting code
    erased every shooting bit and orginized it corectly

    But now i have an error message saying
    Quote Originally Posted by lua error
    error script1.lua:33: attempt to compare nil with number
    here is my code but i dont see any problem with line 33 cause the shooting code is abuot the same as evil mana's
    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

  3. #93

    Default

    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?

  4. #94
    DCEmu Coder ninja9393's Avatar
    Join Date
    Dec 2005
    Location
    Space Pirate Homeworld
    Age
    34
    Posts
    1,028
    Rep Power
    85

    Default

    cause i have to add an enemy and i am not doing that right now

  5. #95

    Default

    ok, so anyways put currentbullet = 1 before line 33. That way you not comparing a nil variable to with a number

  6. #96
    DCEmu Coder ninja9393's Avatar
    Join Date
    Dec 2005
    Location
    Space Pirate Homeworld
    Age
    34
    Posts
    1,028
    Rep Power
    85

    Default

    k i fixed that problem but know i have a bullet that just stays in one spot and doesent move



    oh and i forgot to show u guys the bg's that pspdemon made




  7. #97

    Default

    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...

  8. #98
    DCEmu Coder ninja9393's Avatar
    Join Date
    Dec 2005
    Location
    Space Pirate Homeworld
    Age
    34
    Posts
    1,028
    Rep Power
    85

    Default

    IT WORKS KINDA NOT GOOD but it shoots more then one bullet

    scrren:

  9. #99

    Default

    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

  10. #100
    DCEmu Legend acn010's Avatar
    Join Date
    Dec 2005
    Location
    Galaxy not far away?
    Age
    37
    Posts
    4,656
    Rep Power
    103

    Default

    im glad is going well. hope for the best

Page 10 of 13 FirstFirst ... 678910111213 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •