Jump to content
Sign in to follow this  
RSS Bot

EricBall's Tech Projects - Fractional movement

Recommended Posts

My current challenge is rewriting the movement routine to use fractional positioning for both the player and enemies. (Well, the enemies already used fractional positioning, but now I'm giving them two speeds.) There are actually four different speeds:

falling speed - 20 pixels per second

fast player - 13.3 pixels per second

slow player / fast enemy - 10 pixels per second

slow enemy - 8 pixels per second

 

Weird numbers, but those are the integer movements which match up with the round-robin movement logic which does each enemy & player every 1/10th of a second.

 

Of course, these values don't translate into an even number of 256th pixels per frame so I'm using my super-duper fractional adder which handles the remainders: (NTSC falling)

CODE

7$ CMP #FALLING

BNE 8$

LDA YFPOS,X

CMP #170

ADC #85

STA YFPOS,X

BVC 8$

DEC YPOS,X

BVS 8$

 

Unfortunately, although I can make it work for 5 of the 8 possibilities (NTSC/PAL), 3 of them aren't 100% reversible. This is important because the player can change direction in mid-stride (the enemies don't), so if the calculations aren't symetrical in both directions, then the player could manage to get off-grid and all kinds of weird things would happen. (Because most of the movement logic is only done when the player/enemy is on grid.)

 

Fortunately, one of the 3 possibilities is slow NTSC enemy so I can ignore it. Unfortunately, that still leaves two which I need to figure out how to fix. Right now I'm trying things out in a spreadsheet to see if I can come up with some exception logic to make one direction look like the other.

 

One good thing with all of this is it will make player & enemy movement even smoother since everyone's position is updated every frame (even if it's just fractionally).

 

 

http://www.atariage.com/forums/index.php?a...&showentry=1449

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...