InsaneSonikkuFan Posted April 27, 2006 Share Posted April 27, 2006 so i've been trying to write asteroids, and i'm running across a problem where bits 3 and 5 of variable c are unsetting themselves. let me explain the way the variable works: [0] UP FAST [1] UP SLOW [2] DOWN FAST [3] DOWN SLOW [4] LEFT FAST [5] LEFT SLOW [6] RIGHT FAST [7] RIGHT SLOW so if you run the code, moving up and/or right drift correctly. however, moving left or down (from a stop) causes the screen to flicker, the ship to only move one tick and then stop, and what seems to be bits 3 and 5 turning from 1 to 0. i've attached my code. i'm using bB bleeding edge 99b. am i overlooking something totally obvious, or is there an actual problem? thanks. asteroids.bas Quote Link to comment Share on other sites More sharing options...
+batari Posted April 27, 2006 Share Posted April 27, 2006 so i've been trying to write asteroids, and i'm running across a problem where bits 3 and 5 of variable c are unsetting themselves. let me explain the way the variable works:[0] UP FAST [1] UP SLOW [2] DOWN FAST [3] DOWN SLOW [4] LEFT FAST [5] LEFT SLOW [6] RIGHT FAST [7] RIGHT SLOW so if you run the code, moving up and/or right drift correctly. however, moving left or down (from a stop) causes the screen to flicker, the ship to only move one tick and then stop, and what seems to be bits 3 and 5 turning from 1 to 0. i've attached my code. i'm using bB bleeding edge 99b. am i overlooking something totally obvious, or is there an actual problem? thanks. Bit access uses {}. [] are for arrays - so by using c[2] for instance, you are actually accessing e. I went ahead and fixed it - I literally did a global search and replace and everything seems to work now. asteroids.bas Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted April 27, 2006 Share Posted April 27, 2006 so i've been trying to write asteroids, and i'm running across a problem where bits 3 and 5 of variable c are unsetting themselves. let me explain the way the variable works:[0] UP FAST [1] UP SLOW [2] DOWN FAST [3] DOWN SLOW [4] LEFT FAST [5] LEFT SLOW [6] RIGHT FAST [7] RIGHT SLOW so if you run the code, moving up and/or right drift correctly. however, moving left or down (from a stop) causes the screen to flicker, the ship to only move one tick and then stop, and what seems to be bits 3 and 5 turning from 1 to 0. i've attached my code. i'm using bB bleeding edge 99b. am i overlooking something totally obvious, or is there an actual problem? thanks. It looks like the only thing c is ever set to is 0 or 1. The square brackets ([ and ]) that you think you're using for the bit operations are actually for variable arrays. To do bit operations, use the curly set brackets ({ and }). Also, checking the bit settings in an if...then is done a little differently-- you can't use an equals sign or you'll get compile errors, so you just say "if c{3} then" or "if !c{3} then" (or whatever variable and bit you're checking), where the first case means "equals 1" (or is "true"), and the second case means "equals 0" (or is "not true"). I've made the appropriate changes in your code so you can see how to do it. Michael Rideout asteroids.bas Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted April 27, 2006 Share Posted April 27, 2006 I went ahead and fixed it - I literally did a global search and replace and everything seems to work now. Heh, I guess we were doing it at the same time! Michael Rideout Quote Link to comment Share on other sites More sharing options...
+batari Posted April 27, 2006 Share Posted April 27, 2006 I went ahead and fixed it - I literally did a global search and replace and everything seems to work now. Heh, I guess we were doing it at the same time! Michael Rideout And it looks like both .bas files will produce exactly the same binary... BTW, your explanation is better, as I left out the part about how to use a bit operation in an if-then statement. Quote Link to comment Share on other sites More sharing options...
InsaneSonikkuFan Posted April 27, 2006 Author Share Posted April 27, 2006 d'oh. thanks a ton, guys. 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.