I'm trying to use a While loop to stop the player when he is looking at a wall, but when the player does look at a wall the game crashes, From what I found on my own, if a while loop doesn't have an exit it will become an infinite loop, which is what crashes the game, I'm assuming that the Else statement I made is not doing anything and that's the problem, however I don't know what to use to replace it.
asked Jul 17 '12 at 08:31 PM
I do not see why you want a while() there, try an if()
This is unnecessary:
You can use:
You don't need a while loop to change a speed value to zero, you set it to zero once and the object should stop moving, in fact take out
and replace it with
It sounds like you're trying to implement collision detection before you have a basic understanding of how program flow works. Please start by doing some programming tutorials before trying game development, it will save you alot of frustration.
answered Jul 17 '12 at 09:02 PM