+atari2600land Posted January 9, 2021 Share Posted January 9, 2021 Surely there has to be a better way to do this than this: nothingf: bitmap "00000000" bitmap "00000000" bitmap "00000000" bitmap "00000000" bitmap "00000000" bitmap "00000000" bitmap "00000000" bitmap "00000000" samplecode: DEFINE 60,1,nothingf wait SPRITE 0,manx+$300,many+$100,SPR60 + 0 What is it? Quote Link to comment Share on other sites More sharing options...
artrag Posted January 9, 2021 Share Posted January 9, 2021 (edited) set x=0 to make the sprite disappear More details here http://spatula-city.org/~im14u2c/intv/jzintv-1.0-beta3/doc/programming/stic.txt The macro resetsprite(n) does this. Edited January 9, 2021 by artrag 1 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted January 10, 2021 Share Posted January 10, 2021 (edited) Are you trying to just hide the sprite? The solution that @artrag offers is the easiest way, but perhaps a bit of context may help explain why: A sprite is only visible on the screen when all the following conditions are met: The "visible" flag of the sprite in the "X" register of the MOB is set to "true" (1). The position of the sprite is within the visible area of the screen. The card that the "A" register of the MOB points to has any pixels set. The foreground color of the sprite is different from the color of the background cards under it. By way of example, consider that the way you hid the sprite in your own example falls under the third option from the list above: the card that the MOB points to is set to a block of all blank pixels. It works, but as you noticed, it's a bit involved and expensive, and overkill. If all you want to do is "hide" the sprite, but not alter any of its existing attributes (say, keep its original position, card, color, etc. intact), then you are better off just clearing the "visible" flag in the "X" register of the MOB. However, most of the time, removing a sprite from the screen comes as a result of "disabling" or "killing" the sprite, or otherwise taking it out of commission entirely; in which case resetting the state of the MOB completely to zero will do that. It also has the benefit of being super easy to do. And as to why it works: "resetting" the sprite clears the values of all MOB registers back to zero, which in turn means the following: The "visible" flag in the MOB's "X" register is now "false" (0). The X and Y position values of the MOB are now set to zero, which falls outside the visible screen area. The card in the MOB's "A" register is set to zero, which points to the first card in GROM, which happens to be a block of all blank pixels. Notice that the above violates most of the conditions needed to make the sprite visible. As @artrag also pointed out, the "RESETSPRITE(n)" macro does this in one go by clearing all MOB registers. -dZ. Edited January 10, 2021 by DZ-Jay Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted January 10, 2021 Author Share Posted January 10, 2021 Duh me! I forgot there was a visible flag in the X register. Quote Link to comment Share on other sites More sharing options...
intvnut Posted January 14, 2021 Share Posted January 14, 2021 Note that if you're using hardware collisions, the visible flag is separate from the interaction flag. An invisible MOB can still interact with other MOBs and the background. IIRC, Maze-A-Tron uses an invisible MOB that's "one pixel larger" than the player's character, but otherwise coincident with it, for collision detection. (Or something like that. Maybe it was one pixel "smaller". I forget.) 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.