Coding the gameplay is pretty simple, since all of the gameplay pretty much amounts to checking for collisions between things and then adjusting the score, lives, effects, and sounds accordingly.
Your Aim is True
First, let's take care of the ESD shots. They are automatically destroyed when they hit a wall, so nothing special needs to be done for the barriers.
When the shots hit the enemies, we'll know it by using the on sprite of kind Projectile overlaps otherSprite of kind Enemy block.
In here we then destroy with fire effect the Enemy that has been hit (indicated by the otherSprite parameter).
We'll also get rid of the ESD shot with the destroy sprite block, then change the score by 100 points, and play a little tone pair.
If you recall, we set up the fire button so it couldn't be rapid fired, by testing the shotFired variable. Here is where we flip that back to false after the current EDS is destroyed using the on destroyed sprite of kind Projectile block.
The ESD is of type projectile so it automatically disappears when it hits a wall, such as our barriers set in the tile map.
Sparky's Been Hit!
Here's how we deal with an enemy making it past the barriers and crashing into Sparky!
The on sprite of kind Player overlaps otherSprite of kind Enemy block runs its code when the collision occurs.
In it, we destroy othersPrite with ashes effect for 200 to remove the enemy Chip from the screen.
We have Sparky change life by -1 from the three we start with initially.
And then we play a low wobbly tone set.
Chips Reach Safety
If an enemy Chip reaches the safety of a barrier without being hit, we'll have the player lose 50 points, and make the Chip emit an effect. (Remember, Chips are actually projectiles, so they automatically disappear when the collide with walls.)
The on sprite of kind Enemy hits wall with the proper index color from our tile map is used to detect the collision.
We then use change score by -50 and then run the sprite start warm radial effect for 100 ms effect.
Our game is finished! Now, you can play it in the browser, or upload it to a Pybadge or Pygamer!