Jump to content

Duck Doesn't Stop

Recommended Posts

I am having a small issue with my code. I am trying to get the duck to stop when it reaches the top after hitting the flyaway state. However no matter what I try the code gets ignored.


Source Code

Relevant section


Any of you experts have any ideas on what's going on?

Edited by Mallard Games
Link to comment
Share on other sites

Near label "SkipReverseDuckXVelocity" you are missing a "#", what you mean is probably:


ldx DuckState




As is (cpx STATE_DUCK_FLYAWAY), you are comparing DuckState to the contents of address $02, which happens to be the collision register CXP0FB.




This is really a common error and hard to spot, especially in your own code (this is a bit like proof reading your own text).

As you are already using upper-case constants for those values, setting up a regular expression search in your text editor to find any of those missing "#" may be a good idea. E.g.,




meaning, we are searching for any words starting with "STATE_" and headed by a white-space character (like a blank).

Any hit should indicate one of those hard to catch errors.


(Alternatively, instead of using a regular expression, just search for " STATE_" [mind the blank!] with word-matching disabled. The regular expression is essentially the same, but matches both heading blanks and tabs. Moreover, you may extend it to match any of your constants at once, like \s(STATE|VALUE|POS)\w* ...)


Edited by NoLand
  • Like 1
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...