Jump to content

AI movement speed control?


Recommended Posts

This was buried in my previous thread , so I thought I would start a new one...


One question I never asked was this :
Incrementing x or y position of enemy 1 pixel/scanline per frame creates the relatively slow movement in waves 1 and 2 of my game.

In wave 3 to 8 , the movement is 2 pixel/scanline per frame ( at least in one direction), and this is quite an abrupt ramp up in speed.
I tried moving one pixel , then moving two , then one, or waiting a frame ,but that just created jerky movement .

Are there any tricks for more finely controlling speed of movement ? Specifically, something in between my two speeds .

With other processors you can just add a delay ( like nops) at the end of the program loop, but here you have to keep up with TV picture....



​Surely there are games with AI movements that are between 1 and 2 pixels per frame. I am certainly missing something obvious.

Edited by easmith
Link to comment
Share on other sites

search on fractional or subpixel



But how does this affect positioning routine? The positioning routine I am using is from Collect I believe, and loops through bytes which are in order xp1, xp0 to position p1 and p0 .


now that my p1 x is two bytes , how should I adjust? Is it just using the integer byte for x positioning ? This seems to work for controlling speed a bit , but


I have a jitter again now in my enemy movement when they are near the left side of screen .Perhaps it is something else causing the jitter, my cycles must be off .

Edited by easmith
Link to comment
Share on other sites

You don't have to keep the 2 bytes next to each other. Instead of changing

ObjectX:        ds 5    ; player0, player1, missile0, missile1, ball

to this:
ObjectX:        ds 10   ; player0, player1, missile0, missile1, ball

you could change it to this:
ObjectXlow:     ds 5    ; player0, player1, missile0, missile1, ball - FRACTIONAL part of position
ObjectXhigh:    ds 5    ; player0, player1, missile0, missile1, ball - INTEGER part of position

then your position object routine becomes:
        ldx #4              ; position all objects
        lda ObjectXhigh,x   ; get the object X position
        jsr PosObject       ; set coarse X position and fine-tune amount 
        dex                 ; DEcrement X
        bpl POloop          ; Branch PLus so we position all objects
        sta WSYNC           ; wait for end of scanline
        sta HMOVE           ; use fine-tune values to set final X positions
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...