lscharen / iigs-game-engine

A tile-based game engine for the Apple IIgs written in 65816 asssembly language
31 stars 1 forks source link

Add capability to show/hide sprites #4

Closed lscharen closed 2 years ago

lscharen commented 2 years ago

From Alex L: https://apple2infinitum.slack.com/archives/CPSGNGE05/p1637562144077500?thread_ts=1637439754.061100&cid=CPSGNGE05

Can the GTE support flickering sprites if you want them? For example, if a player gets hit/damaged and is temporarily invulnerable, giving them time to move to a safer spot, and their sprite flickers during this time?

lscharen commented 2 years ago

Behaviors like that aren't built-in, so the main code would need to track the on/off state of the sprite. But, there would be two ways to accomplish that effect

  1. Use the UpdateSprite subroutine to change the sprite's Tile ID to a transparent tile every other frame to give the appearance of disappearing
  2. Use the MoveSprite subroutine to move the sprite off-screen to hide it

Neither one of these is ideal. Switching to a transparent sprite will still go through the work of drawing, and moving it off screen can be inconvenient if the scroll position is based off of the Sprite's location on-screen. I have some free bits to use, so I think having a SPRITE_HIDE flag is useful enough to be added.

lscharen commented 2 years ago

Flag added and example added to sprite demo. Use f key to toggle "flash" effect ezgif com-gif-maker