Jump to content

Horizontal movement

Recommended Posts

I can't move the fish sprite left and right. What I want it to do is move in a circle. have it move up and then when it reaches the top, move right. I got it moving up, but I can't get it to move right.



Share this post

Link to post
Share on other sites

I cleaned up my code a little. No matter what I do I can not get the fish to move down. WHY? It's especially anger-inducing when the up code is exactly like the down code except the down code doesn't work.


Share this post

Link to post
Share on other sites

I don't fully follow the code, but I traced through to the first NMI. I see you initialize direction and all that fine, but in mov_cod there's a (small, probably inconsequential) bug where if COD_DIR is not 1-4, you'll start moving up.


It looks like in the normal case where it jumps to move_cod_up, move_cod_down, etc, that de is not initialized. You only ld de in the begin_cod_xxx blocks, which are not called during normal movement. It might simply be that up never finishes. Try putting a ld de,COD_DIR after move_cod_up? Otherwise it looks like de is whatever was read from $8002... (which I don't see being initialized...?)






Share this post

Link to post
Share on other sites

First some suggestions:


1. try and split your logic so that you are only writing your sprite table to VRAM during the NM, and any other video writes.

2. Put your logic to update the sprites position in your main code (outside of NMI), use the TIMER routines to control how fast things move


Now your actual bug:

You are using a Zero value comparison, and directly calling the next direction setup, with it's own Zero value comparison which ends up already being true i.e. you skip through your different direction set-ups immediately.


You should probably split up your logic into two sections:

1. Decide whether it is time to change direction

2. Update the position based on the current direction


and each should only be called once per loop.


I hope that has not confused you further.  If you want to see some of what I have described above I have made a video series called Lets Make a Retro game on Youtube, that includes sample code for the Coleco.

Share this post

Link to post
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.

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...