Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Breakout problemo...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Insectoid




PostPosted: Mon May 26, 2008 5:17 pm   Post subject: Breakout problemo...

I am currently working on making the game Breakout and I am having some sprite issues.

All of the bricks in the game are sprites (just for the heck of it) and I am using arrays to initialize/place/check if hit. This of course leads to problems with checking for collisions with freed sprites. I devised a way to skip over the sprites that have been freed, though it seems to be faulty.

The code is a mess right now (still in the early stages of the game) so if you can't figure it out, I forgive you.

Oh, and I know I could have used records.

Turing:

for boxhit : 1 .. numberofboxes
       
        if boxhitnumber > numberofboxes then
            boxhitnumber := 1 %resets to 1 after checking every box
        end if

        loop % the problem area. Should always skip sprites that hae been freed.
            exit when nobox (boxhitnumber) ~= boxhitnumber
            boxhitnumber += 1
        end loop

        if ballx > boxx (boxhitnumber) and ballx < boxx (boxhitnumber) + 30 and
                bally >= boxy (boxhitnumber) then
            ballvert *= -1

            nobox (boxhitnumber) := boxhit
            Sprite.Free (boxes (boxhitnumber))
            remaining -= 1
        end if
    boxhitnumber += 1 %This number is manipulated, so I can't use 'boxhit'
        end for
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: