Exploding Blocks - game-stuff-official/exampledustry GitHub Wiki

Examples

Explodium Wall

Resources

Step 1: Create Your Block

name: Explodium
type: Wall
scaledHealth: 260
size: 2x2
requirements: {
    explodium/24
    blastCompound/6
}

Step 2: Add a destroyBullet Property

This is the magic property that enables your block to explode.

destroyBullet is an object so you use brackets to enclose the bullet

destroyBullet:{

}

[!TIP] Block owns the destroyBullet property so you can make any other block explode with this tutorial.

Step 3: Create your bullet

We set the type of the object to BulletType which is a very basic bullet. You could set it to any other bullet that extends bullet, but make sure you know what you're doing.

destroyBullet: {
    type: BulletType

    // These values are set to make sure that the bullet immediately explodes and does not interact with anything.
    speed: 0
    lifetime: 0
    collides: false
    hittable: false
    hitEffect: none

    // These are the values we care about. splashDamageRadius is how close something has to be to deal damage.
    splashDamage: 75
    splashDamageRadius: 150
    despawnSound: dullExplosion // alternatively use explosion or other sounds.
}

Step 4: Add despawnEffects

Effects are very important in an exploding block, without them there would be no indication of where an explosion comes from or even if there is an explosion at all.

Add despawnEffect inside destroyBullet.

Since we will be using multiple effects the destroyBullet will be an array of objects. For this tutorial we use 3 effects.

despawnEffect: [
    {

    }
    {

    }
    {

    }
]

Step 5: Add your effects.

ParticleEffect

The first 2 Effects we will use are ParticleEffects. This effect spawns particles that change color, size and move over time.

lifetime: 40 // Time is measured in 60ths of a second
type: ParticleEffect
colorFrom: ff0000ff // From solid red
colorTo: aaaaaa00 // To an invisible grey. This makes the effect appear as if it is diffusing like smoke.
particles: 12 // Amount of particles to spawn. 
randLength: true // Makes the particles go a random distance from the origin.
sizeFrom: 10 // Particle goes from 10
sizeTo: 0 // To zero and disappears.
region: circle // What shape the particle is.
length: 400 // How far the particle goes from the origin.
interp: pow2Out // A mathematical function that makes the particles go quickly at first but then slow down towards the end. You can use linear if you want the particles to have constant speed.

This effect will make red particles explode from the block and shrink, turn grey and disappear. Screenshot 2024-12-06 8 17 31 PM

The second particle Effect we will add is a smokier effect. It lasts twice as long as the first effect.

lifetime: 80
type: ParticleEffect
colorFrom: ffffffff
colorTo: 88888800
particles: 16
randLength: true
sizeFrom: 8
sizeTo: 0
region: circle
length: 200
interp: pow2Out

Screenshot 2024-12-06 8 26 23 PM

This will create an effect that lasts over a second. It starts white and turns grey.

ExplosionEffect

This effect is short and is a type separate from ParticleEffect but still extends Effect

type: ExplosionEffect
waveColor: ff0000 // Wave is the ring that explodes from the explosion.
smokeSize: 10
smokeSizeBase: 0.1 // How big the smoke starts.
smokes: 10
sparks: 10

This effect creates sparks and short lived smoke particles.

Screenshot 2024-12-06 8 48 06 PM

Now that you have learned to make exploding Blocks, go and experiment. Try using different bullet types, effects. Try using other types of blocks.