Jump to content
IGNORED

Using negative values in plotsprite


Tickled_Pink

Recommended Posts

Looks like the compiler isn't sure how to interpret it.

In 8 bit maths, -1 is the same as 255 where the value of the byte underflows from its minimum to maximum values. If you just want to stick a negative number in you can do so by subtracting from 256. For example -32 would be 256-32=224.
The visible part of the screen is from 0 to 159 so that gives you 96 pixels that are offscreen to work with.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

That might explain the issue. I noticed previously, at least this is how I'm remembering it, that when I allowed my player sprite to move horizontally under joystick control, it would go off screen okay. I'm fairly sure it went off the bottom of the screen when I applied a simple gravity to it before I clamped it. I've been trying to test its top screen vertical behaviour with a static negative y number and the compiler doesn't accept it. What you're saying makes sense. However, I do think I tried this method at one point and while it did work, it got stuck and wouldn't move from that initial position. So, maybe I need to have a little play around with that logic.

Link to comment
Share on other sites

I don't know why I assumed you were talking about the X position but I did and that's where the 160 figure comes from. The visible Y is from 0 to either 191, 207, or 223 depending on your screenheight setting. The same rules about 192 / 208 / 224 to 255 being offscreen still count and things will wrap around.

Link to comment
Share on other sites

  • 3 weeks later...

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.

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

Loading...
  • Recently Browsing   0 members

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