+Random Terrain Posted May 25, 2008 Share Posted May 25, 2008 I was moving a sprite left and right and tried to slow it down with a counter. Looked like crap. I also tried to speed it up by adding or subtracting 2. Looked like crap. I then tried fixed point math. Whether you slow it down or speed it up to something like 1.5, it just looks smoother. I even cranked it up to 3.5 and it still looked pretty good. After playing around with fixed point math, there's no way I'd use a counter or plain old regular numbers again for sprite movement. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted May 25, 2008 Share Posted May 25, 2008 yes...it was a miracle for me prior somebody explained me the magic behind fp maths.... first 8.8 then 4.4 then even signed.... and the real magic is... there is no magic behind it... just use it... Quote Link to comment Share on other sites More sharing options...
MausGames Posted May 25, 2008 Share Posted May 25, 2008 I used a counter for my "TZ" demo, and I think sprite movement is pretty smooth. I start the single variable used at 50 though, and increase velocity depending on how far the variable moves toward 0 or 100. I prefer this method for the sake of saving a precious variable. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 25, 2008 Author Share Posted May 25, 2008 I used a counter for my "TZ" demo, and I think sprite movement is pretty smooth. I start the single variable used at 50 though, and increase velocity depending on how far the variable moves toward 0 or 100. I prefer this method for the sake of saving a precious variable. Do you have time to make a quick, small program where you can move a simple object around the screen using your technique? Since there would be no extra code for other things, it would be easier to understand and follow. Thanks. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted May 25, 2008 Share Posted May 25, 2008 (edited) I just use this method Maus taught me: w=w-1 if a{6} && w=0 then w=2 : player0x=player0x-w : rem move left if a{7} && w=0 then w=2 : player0x=player0x+w : rem move right Edited May 25, 2008 by atari2600land Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted October 16, 2009 Share Posted October 16, 2009 I was moving a sprite left and right and tried to slow it down with a counter. Looked like crap. I also tried to speed it up by adding or subtracting 2. Looked like crap. I then tried fixed point math. Whether you slow it down or speed it up to something like 1.5, it just looks smoother. I even cranked it up to 3.5 and it still looked pretty good. After playing around with fixed point math, there's no way I'd use a counter or plain old regular numbers again for sprite movement. Do you have a code example of this? I've been looking for a good example of fixed point variables but I haven't found one yet. Quote Link to comment Share on other sites More sharing options...
+batari Posted October 16, 2009 Share Posted October 16, 2009 I used a counter for my "TZ" demo, and I think sprite movement is pretty smooth. I start the single variable used at 50 though, and increase velocity depending on how far the variable moves toward 0 or 100. I prefer this method for the sake of saving a precious variable. Do you have time to make a quick, small program where you can move a simple object around the screen using your technique? Since there would be no extra code for other things, it would be easier to understand and follow. Thanks. You can use fixed-point math for moving players without using an extra variable and without needing to do something like Maus is suggesting. When you set up your variables, do this: dim p0pos = player0x.a Then you may add a 4.4 or an 8.8 to p0pos and it will move your player, and you don't need to waste a variable - in this example, a becomes the fractional portion of player0x. Quote Link to comment Share on other sites More sharing options...
accousticguitar Posted October 16, 2009 Share Posted October 16, 2009 (edited) Something like this? set romsize 4k playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end player0x=50 player0y=50 dim p0pos=player0x.a dim p0posy=player0y.b main COLUP0=28 COLUBK=22 player0: 001111 001111 001111 001111 end drawscreen if joy0right then p0pos=p0pos+1.5 if joy0left then p0pos=p0pos-1.5 if joy0up then p0posy=p0posy-1.5 if joy0down then p0posy=p0posy+1.5 goto main Edited October 16, 2009 by accousticguitar Quote Link to comment Share on other sites More sharing options...
MausGames Posted October 16, 2009 Share Posted October 16, 2009 (edited) Thanks Batari, great to know. My math and organizational skills are lacking, tips like this always help a lot. I hope a2600l sees this, I've been bugging him to try new physics. Edited October 16, 2009 by MausGames 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.