Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Having a hard time with multiple shots

    Help
    2
    3
    214
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • waldron
      waldron F last edited by pianofire

      Having trouble with some code i'v been putting off as i'v always had trouble with it with other programs.
      Currently i'v got this

      maxArrow = 9
      Arrow = createGameSprites (maxArrow)
      numArrows = 0 //number of players current arrows to use which is tied to the controls
      function createArrow()
        for i = 0 to maxArrow loop
          if !Arrow[i].active then
            list of sprite properties......
            Arrow[i].active = true
            setspriteimage... 
            animation ...
            collision shape ..
            break
          endif
        repeat
      return void
      

      so the sprite is ready to be used so i call it with

      if numArrows >0 and c.r and !oldc.r then
        createArrow()
        numArrows -=1
      endif
      

      This all works as expected i even have player direction dictating the direction and speed of the arrow working.
      my main issue is when it comes to collision with other enemies something i'v done time and time again but with a single sprite vs for looped ones but with 2 sets of looped sprites the first shot will register but past that they don't.
      i'v tried all sorts plus removing the sprite to refresh the array. Don't want to do what i'v done before with dodgy code probably something simple im missing ;)

      1 Reply Last reply Reply Quote 0
      • SteveZX81
        SteveZX81 F last edited by

        I'm not sure if this is what you need but this is how I deal with collision with two sets of sprites

        for sh = 0 to len(pshots) loop
            for en =  0 to len(enemies) loop
                col = detectspritecollision(pshots[sh], enemies[en])
                if col then
                    removesprite([pshots[sh])
                    pshots[sh] = createsprite()
                    pshots[sh].active = false
                    removesprite(enemies[en])
                    enemies[en] = createsprite()
                    enemies[en].active = false
                endif
            repeat
        repeat
        
        waldron 1 Reply Last reply Reply Quote 5
        • waldron
          waldron F @SteveZX81 last edited by

          @SteveZX81 yep i was only processing one of the loops in my collision code so now it works with processing both ! , iv added life counters to my enemies spawn code so now to respawn its just enemylife =1 and there all reset.
          cheers steve !

          1 Reply Last reply Reply Quote 1
          • First post
            Last post