Jump to content

Blanking a sprite in INTYBasic.

Recommended Posts

Surely there has to be a better way to do this than this:

  bitmap "00000000"
  bitmap "00000000"
  bitmap "00000000"
  bitmap "00000000"
  bitmap "00000000"
  bitmap "00000000"
  bitmap "00000000"
  bitmap "00000000"



    DEFINE 60,1,nothingf
    SPRITE 0,manx+$300,many+$100,SPR60 + 0   

What is it?

Link to comment
Share on other sites

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.



Edited by DZ-Jay
Link to comment
Share on other sites

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

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