Thread: Scorpion Engine
View Single Post
Old 01 October 2019, 12:20   #224
Registered User

Join Date: Dec 2013
Location: Auckland
Posts: 2,224

Time for another TOG mini tutorial. This one is fairly advanced, but I did want to talk about the possibilities for what the Scorpion Engine can do through it's block management system - which is flexible enough that it could theoretically power a game like Lode Runner, Boulder Dash or DynaBlaster.

So what I've written is likely to be confusing, but I'm happy to elaborate if anyone has any specific questions.

There's a level near the end of part 1 of TOG where the player has to dig through a mine. The destroyable walls are implemented the same as the bushes were in the previous tutorial - as active objects rather than static blocks, so they're costly in terms of the CPU and blitter, and they will slow the game down a lot if there's more than 1 or 2.

But we can't do exactly the same as we did with converting the bush from an object to a block - the destroyable walls are 32x32, and we want to be able to hit any corner of them to collapse the entire wall. Fortunately, Scorpion can handle it.

Firstly, we need to add four new blocks to our tileset, and then add those blocks to the level. We'll name them BreakBlockTL, BreakBlockTR, BreakBlockBL, BreakBlockBR

Next, we want to add these blocks into our Project.Txt file.

[Block BreakBlockTL]

[Block BreakBlockTR]

[Block BreakBlockBL]

[Block BreakBlockBR]
Depending on which of the four corners we hit with our sword, the code to handle the collapsing wall is different, which is why we're calling four different routines from "divert_playerprojectilecollision". So finally, we add code to

=== BreakBlockTL_Hit ===
//Play the destroy sound
~ Sound = SndUNIVERS2

//Destroy the player's projectile
~ PlayerProjectile_Type = null

//Destroy this block and the surrounding three
~ Block_Type = null
~ Block_X = Block_X + 1
~ Block_Type = null
~ Block_Y = Block_Y + 1
~ Block_Type = null
~ Block_X = Block_X - 1
~ Block_Type = null
~ Block_Y = Block_Y - 1

//Spawn a block break animation object from the top left corner
~ Block_Spawn = ENEMY_Block_die

=== BreakBlockTR_Hit ===
~ Block_X = Block_X - 1
-> BreakBlockTL_Hit

=== BreakBlockBL_Hit ===
~ Block_Y = Block_Y - 1
-> BreakBlockTL_Hit

=== BreakBlockBR_Hit ===
~ Block_X = Block_X - 1
~ Block_Y = Block_Y - 1
-> BreakBlockTL_Hit
Here we're manipulating the 'block pointer', the X/Y co-ordinates that allow the scripting engine to change any block on the map in real time. If we hit any block other than the top left block, we move the block pointer to the top left block and execute the routine for handling a hit on that block.

From there, we do the following:

- Play the block destroy sound
- Destroy the thrown sword
- Spawn the block wall destroy animation (this is a simple object that plays an animation, and then deletes itself from the game)
- Destroy the top left block, as well as the surrounding three

Here's what it looks like

earok is offline  
Page generated in 0.04904 seconds with 11 queries