Tickled_Pink Posted August 15, 2023 Share Posted August 15, 2023 Is there an easy way to use negative values with plotsprite? I'd like my sprites to disappear gradually off the edges of the screen but it seems that plotsprite doesn't work with negative values. Quote Link to comment Share on other sites More sharing options...
+SmittyB Posted August 15, 2023 Share Posted August 15, 2023 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. 1 1 Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted August 15, 2023 Author Share Posted August 15, 2023 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. Quote Link to comment Share on other sites More sharing options...
+SmittyB Posted August 15, 2023 Share Posted August 15, 2023 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. Quote Link to comment Share on other sites More sharing options...
Tickled_Pink Posted September 6, 2023 Author Share Posted September 6, 2023 Oh, yeah. Forgot to mention that this was the issue. Basically I have to offset the Y position so that it's bigger than I actually need it so that I can then do a 0-16+ypos, or something like that so that the flag is properly set. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.