new explosion -- char matrix draw

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

Here's a revision of the explosions.  First pass, so not perfect; there appear to be inconsistencies in how it looks. Strange; will fix.


I think it is quite effective, and way better than previous explosion effects.

Andrew Davie


Andrew Davie

#2
This'll do for a while. Pretty nice!


Andrew Davie

Here's the explosion in 1/4 speed slow-motion. Pretty awesome!


Andrew Davie

Here's a test of the explosion in different scenarios on different levels.


Andrew Davie

The next big problem was explosions causing explosions. For example a mine next to another mine. Or a bomb exploding next to the player. Because of the character-based nature of the explosions, it was a challenge to prevent explosions partially overwriting other explosions.

Anyway, I found an "elegant" way - extremely cheap in processing time, and ROM.

So, here's a short video showing some chained explosions. Looking OK to me.


Andrew Davie

#6
Here's a level designed with the chained explosions in mind. And I fixed up the sound so chained explosions restart the bang rather than remain silent after the first.


Andrew Davie

Here, with slower animation. I think I like this better.


Andrew Davie

There are a number of things I can tweak. I've been tweaking. This version looks pretty good -- redraw of the frames to use different colours, a delay before the screen flashing are the most obvious ones. Looks pretty good.  Screen 45 has the chain reacting bombs.  Pickup the bomb just by walking into it. Then button+direction to drop it.

Suicide also has the bomb. To do that, hold down the RESET (F2).

Oh, in the emulator you could/should attach a SaveKey.  And on power up hold down RESET to zap the menu grid progress indicators, or better yet hold down SELECT go get the board lit up with random status (and effectively make all levels available to play). I kinda forgot to mention this for previous binaries, I think!





Andrew Davie

Masking explosions into the background

One of the trickier bits of polish in the ACME-cloud explosion effect: the blast needs to visually roll over everything in its 3×3 radius — walls, doors, bombs, whatever — but only some of that is actually supposed to die. Walls survive. A bomb or the player caught in the blast needs to survive the initial hit but then chain-detonate on its own once the smoke clears. Everything else just gets destroyed. And none of it should flicker or pop.

Getting all three of those to hold at once needed three separate pieces working together.

1. Decide everyone's fate before the cloud ever moves
The moment an explosion ignites (frame 0 of the animation), the code walks the 3×3 neighbourhood once and decides — right then, before a single cloud pixel is drawn — what each of those 9 cells is going to end up as:

Solid, non-explodable stuff (walls, anchors) → keeps its own character, unchanged.
A bomb, mine, or the player caught in the blast → resolves straight to its "pending" marker, so it quietly detonates for real once this explosion is done (that's how chain reactions happen without the two explosions ever overlapping).
Everything else → resolves to blank.
That result gets stashed in a small 9-slot buffer (acmeRestoreBuffer) and never touched again until the very last frame, when it gets written back onto the board verbatim. So the "did this survive" decision and the "put it back" action are two completely separate moments — the whole middle of the animation doesn't need to know or care what's about to happen.

2. The cloud never actually replaces anything mid-blast
Here's the part that took a couple of iterations to get right: if the cloud cel just overwrites the board character every frame, a destructible object (a rock, some dirt) visually disappears the instant the explosion starts, not when it's actually destroyed. That reads as wrong — the thing should look like it's still there, getting pummelled by the cloud, right up until the smoke clears and it's gone.

So there's a second, separate 9-slot buffer (acmeBlendBackground) that captures the true, untouched original content of each cell at ignition — completely independent of what its eventual fate is. Every frame of the animation blends that against the current cloud frame. Only the final frame ever touches the real "fate" buffer from step 1. Two buffers, two jobs: one says what things look like right now, the other says what they'll be left as.

3. Actually blending two characters together
The 2600 doesn't do alpha blending, obviously — so "blend" here means building a brand new character glyph in RAM, every frame, for every one of the 8 non-centre cells in the blast. Each of those 8 positions gets its own scratch RAM buffer, and every frame we composite.

The compositing itself is the fun bit. Our character format stores each logical row as 3 consecutive bytes (vertical sub-pixel phase copies for fine positioning), and each byte is a plain 1-bit-per-column mask. Naively OR-ing background and cloud bytes together corrupts things (two different non-zero colour values OR'd together make a bogus third colour), and naively picking "whichever byte is non-zero" per byte risks splicing half a background pixel-row together with half a cloud one in the same logical row.

The actual fix is a classic cookie-cutter mask, done per row.

OR the cloud's 3 phase-bytes together to get its real occupied-columns mask for that row (a pixel column the cloud lights up in only one of its three phases still counts). Invert it, AND that into all 3 background bytes — that punches the cloud's exact silhouette out of the background, column by column, regardless of which of the 3 phase-bytes the background pixel actually lived in. Then OR the cloud's own bytes back in to actually draw it. Any column the cloud never touches in any of its three bytes keeps its background bit completely untouched — genuinely transparent, not just zeroed.

The one cell that's exempt from all of this is the centre of the blast itself — it has to keep writing its own specific animation-frame character every frame, because that character is the frame counter (the game derives "what frame of the explosion is this" directly from which specific character is sitting there). Blend that one into a RAM glyph too and the animation loses track of its own state.

The end result
A wall gets visibly chewed up by the cloud and reappears intact once it clears. A bomb sitting in the blast radius keeps looking like a bomb the whole time, then — once the smoke's gone — reveals itself as primed and goes off on its own a moment later. Ordinary destructible terrain just isn't there anymore. All from one small state machine, two 9-slot buffers, and a per-row cookie-cutter mask.