Advertisement

Problem using loops...

Started by March 01, 2003 05:57 PM
0 comments, last by skittleZ 22 years ago
I have this bit of code, the program is meant to draw a triangle that you can move by pressing F7 and F8 and stop its movement when it reaches a certain x position. This works when I use an if statement, but when I tried to do it as a while statement or do whilem the program just freezes up as soon as I run it. Anyone know why? //This is the only part that causes the problem, when I change the if to a while, it says no errors but the program doesnt run. if(move == true) { if (keys[VK_F7]) { transtri+=0.5; } if (keys[VK_F8]) { transtri-=0.5; } if(transtri == 1.0) { move = false; } }
sounds more like you''re stuck in an endless loop. shouldn''t you stick this code inside your main loop? your code here keeps looping until transtri == 1.0. so it just sits there looping over and over, not doing anythin except adding or subtracting when a key is pressed. nothing is displayed inside the loop so you can''t see anything moving obviously.

This topic is closed to new replies.

Advertisement