Cybearg Posted October 14, 2013 Share Posted October 14, 2013 Currently, this doesn't work: const START_VELOCITY = 0.5 _velocity = START_VELOCITY[code] Is there a way to make floating numbers work with constants or perhaps to "fake it" by just setting the decimal-place variable to a constant? The problem with the latter is that it doesn't seem to be clear-cut as to what real number is interpreted as what in decimal places. For instance, .3 looks like $4C or 76 in decimal, so I can't say I see the connection. Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 14, 2013 Share Posted October 14, 2013 I apologize in advance for not directly answering your question. Stop noodling around with that weird fixed point variables stuff. Start using whole integers and bitwise operations. If you need something to move at half speed just keep a counter variable that increments every main loop: main counter = counter + 1 then take the first bit and use to as a trigger to move the enemy: if counter{0} then goto move_enemy That ends up being .5 velocity if you move the enemy by a single pixel per movement. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted October 14, 2013 Share Posted October 14, 2013 Did you use "dim _velocity = <var>.<var>"? Stop noodling around with that weird fixed point variables stuff. Start using whole integers and bitwise operations. Good luck with that if you are trying to do Breakout-style games or pinball games. Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 14, 2013 Share Posted October 14, 2013 Did you use "dim _velocity = <var>.<var>"? Good luck with that if you are trying to do Breakout-style games or pinball games. Actually, my "bb Brix" was doing pretty well without it. I got stuck on the collision not the physics Quote Link to comment Share on other sites More sharing options...
bogax Posted October 14, 2013 Share Posted October 14, 2013 Can't say I really know how it worksbut it seems that if the variable who'svalue you're assigning is not 8.8you get the integer part of the 8.8 variabledim var = a.bc = varis the same asc = aThe fractional part is in 256thsso .3 * 256 = 76.8 and bB truncates to 76For named constants you can use defbut def is kind of flakeydef pi = 3.14var = pivar = var + pi Quote Link to comment Share on other sites More sharing options...
Omegamatrix Posted October 14, 2013 Share Posted October 14, 2013 For instance, .3 looks like $4C or 76 in decimal, so I can't say I see the connection. 255 is the highest value that can be stored in 1 byte, yes? .3 * 255 = 76.5 (or just 76 when truncated.) Quote Link to comment Share on other sites More sharing options...
Cybearg Posted October 14, 2013 Author Share Posted October 14, 2013 I didn't really get it figured out, but I worked around it when I realized how the decimal place was handled. I was expecting it to be a 0-100 decimal place kind of thing, but it's fractions of 256, so 0.5 is 00 on var 1 and 128 on var 2. Pretty obvious, in hindsight. Loon, up to now, I've used counters to time things. For instance: if !(counter & 3) then player1x = player1x + 1 It's worked alright, but I wanted to be able to incrementally increase the velocity, which that movement-skipping method can't do so easily, even if the results are essentially the same. 1 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.