Jump to content
IGNORED

"Destroying" Sprites


Peter G

Recommended Posts

Are the different sprites always in existence from boot up and just blank, or do you "create" them when first called and they can be removed?

 

My game calls for the sprites to be hit and destroyed. But rather than immediately repositioning the sprite and starting it over again, I want a split second without the sprite on the screen. Is there a way to remove the sprite, or will it always be there because of the registers and, to erase it, I need to draw a "blank" sprite in its location?

Link to comment
Share on other sites

Yes, the players, missiles, and ball are always there. You can "enable" or "disable" the missiles and ball, but since they're just 1 bit wide, all that's really doing is setting their bit to 0 or 1. You can't "enable" or "disable" the players, at least not in the sense of turning a player off without destroying its current value. If you want a player to "disappear" you have to set it to 0. But you don't need to "draw a 'blank' sprite" in the sense of drawing an 8x8 grid of "empty" pixels-- just set the player to 0 and it will not be visible.

 

Note that the above answer is most pertinent to assembly programming. If you're using batari Basic, it's a different story, because batari Basic handles all the details of drawing the screen for you, and part of the details of drawing a sprite at a particular vertical position is "turning it off" (setting it to 0) on certain lines, then drawing it on the desired lines, then turning it back off again. So to make a sprite disappear without changing its existing shape you just set its vertical position to someplace off of the screen.

Link to comment
Share on other sites

I use one of two strategies:

 

A. Set the sprites x/y position to zero

player0x = 0 : player0y = 0

 

B. Set the sprite graphic to blank

 

player0:

%00000000

end

 

As it says on the bB page for the DPC+ kernel, if you want to disable a sprite, do not set its Y value to zero (it would still be visible). Set it to around 200 to move it off the screen. It's probably a good habit to do that for the standard kernel too. Then you won't have to worry if you switch from one kernel to the other.

Link to comment
Share on other sites

Both of my above mentioned methods work. To be clear the exception is the DPC+ kernel.

 

I didn't say it didn't work, I said it's probably a good habit to get into for the standard kernel too. Then you won't have to worry if you switch from one kernel to the other.

Link to comment
Share on other sites

Then we are agreed :)

 

I actually like it disappearing at y = 0. This comes in handy for things like lasers and rockets firing up.

 set smartbranching off
 set romsize 4k

 player0:
 %00100100
 %01011010
 %11011011
 %01011010
 %00111100
 %01100110
 %00100100
 %00011000
end

 player0x = 81

main
 if player0y > 0 then player0y = player0y - 1
 if joy0fire && player0y = 0 then player0y = 88
 COLUP0 = $1E
 drawscreen
 goto main
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.

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