Navigation

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

    Problem with sprites & arrays

    Beginners
    11
    42
    2921
    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.
    • pianofire
      pianofire Fuze Team @SteveZX81 last edited by

      @SteveZX81 Ah yes 4AM programming. I know it well

      1 Reply Last reply Reply Quote 0
      • M
        MikeDX last edited by

        Yep! sounds perfectly normal to me. wake up with idea and must try it. programming isn't typing, it's thinking. well actually the typing is the programming but the developer part is the thinking

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

          Guys, I'm really sorry for keeping spamming this thread but I feel I'm so close..

          I've been working on my 4am idea and that is to use an array to set the # of coins in a column (row to you guys) and then draw the coins using the array to draw however many coins in each column then deduct 1 from the index of the array when a coin in that column(row to you) is hit.

          This is what I have now.
          newcode.jpg

          The first bit sets up the array and sets each index to 3 (3 coins in a stack, just to test it)

          The second bit of code draws the coin sprites on screen using the array to see how many to add

          The third bit tests for a collision with the bomb and apart from adding to the score etc, it takes one away from the array (which hopefully means that column(row to you) will draw with one less coin next time)

          but I'm getting errors like 'array out of bounds'.

          I honestly feel that I'm close to this working.. well, I think so.
          am I on the right track or utterly clueless?

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

            @SteveZX81 It's line 140 that gets the error isn't it? You're looping up to 26, while the highest array index you can use for that array is 9.

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

              @Nisse5 said in Problem with sprites & arrays:

              @SteveZX81 It's line 140 that gets the error isn't it? You're looping up to 26, while the highest array index you can use for that array is 9.

              Right yeah! ohh damn.. that kind of trashes the whole 'approach'. as changing that to 9 means it won't detect a collision with the others. ughhhh and I really thought I was close to fixing it. hells bells

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

                @SteveZX81 said in Problem with sprites & arrays:

                @Nisse5 said in Problem with sprites & arrays:

                @SteveZX81 It's line 140 that gets the error isn't it? You're looping up to 26, while the highest array index you can use for that array is 9.

                Right yeah! ohh damn.. that kind of trashes the whole 'approach'. as changing that to 9 means it won't detect a collision with the others. ughhhh and I really thought I was close to fixing it. hells bells

                I'm not actually sure the approach is wrong... I just think you use the wrong index for what you want to do. (Hint: look for example how you draw the coins and how you use array indexes there.)

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

                  Thanks.

                  I've tried redoing the collision bit to this but alas no joy. I've tried so many variants now that I'm about to put my fist through my monitor lol.

                  Here is my latest lame failed attempt
                  morecode.jpg

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

                    @SteveZX81 Go a bit further and use "c=0" and "c+=1" as you do in the draw loop. Then reference c in the same way as you do in the draw loop. Currently, you loop in the same way, but you reference the array indexes in a different way.

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

                      Thanks, I did do that but no joy. I think I've wasted enough of your time on this so we'll call it a day but I really do appreciate the help you gave me!

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

                        I'm utterly thrilled and delighted to announce that my problem is now solved and the game is working as should be.
                        This is not my doing (I thought I was close, but not really)

                        Martin has gone above and beyond to help me with this and all I can do is say a HUGE Thank you!

                        1 Reply Last reply Reply Quote 6
                        • Dave
                          Dave Fuze Team last edited by

                          @Martin I think a pint is in order for you sir.

                          1 Reply Last reply Reply Quote 1
                          • Dave
                            Dave Fuze Team @Martin last edited by

                            @Martin Mate... That's awesome! Think I heard an angelic chorus when I read this! The joy and embarrassment that occurs when you learn something new in programming...

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