+atari2600land Posted May 12, 2007 Share Posted May 12, 2007 (edited) Suppose I got this code (I snipped it from a game I'm working on). When a{2}=1 (or when the player falls), f automatically goes to 7 instead of being 1 like it should be. Why? if a{1} then t=t+1 : y=y-1 : n=n-1 : b=3 : f=f-1 if a{1} && f<2 then f=1 if t=40 then a{1}=0 : a{2}=1 if a{2} then y=y+1 : n=n+1 : b=3 : f=f+1 if a{2} && f>7 then f=7 Edited May 12, 2007 by atari2600land Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted May 12, 2007 Share Posted May 12, 2007 Suppose I got this code (I snipped it from a game I'm working on). When a{2}=1 (or when the player falls), f automatically goes to 7 instead of being 1 like it should be. Why? if a{1} then t=t+1 : y=y-1 : n=n-1 : b=3 : f=f-1 if a{1} && f<2 then f=1 if t=40 then a{1}=0 : a{2}=1 if a{2} then y=y+1 : n=n+1 : b=3 : f=f+1 if a{2} && f>7 then f=7 If this code is part of a loop, then whenever a{2} is 1, the next-to-last line will keep incrementing f each time through the loop, and the last line will prevent f from exceeding 7-- so after you go through the loop a few times, f will be 7. Michael Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.