Climbing Action

At heart, Trash Panda is a button mashing game! So let's set up some buttons to mash.

on A button pressed will be for climbing on the right side of the building and B on the left.

To prevent button presses during the splash screen from doing anything, such as playing unexpected sounds, we'll first check to see if the GameOn variable is true.

Then, we check to see if the goalMet variable is false. (This way, the buttons will stop working when Lynn reaches the top and the goalMet variable is flipped to true.)

The A button will move Lynn's horizontal (x) position to 180, and the B button to 110, which represent the two sides of the building.

Next, her velocity on y is set to -45, which is a boost in the vertical direction. Remember, we already set her acceleration on y to 200, so gravity will be constantly fighting against her. Press quickly to ascend! Her activate animation block will cause her to cycle through the climbing animation frames. Note the on game update block used to return her to Idle animation cycle when she isn't climbing in the y direction.

Now, we'll use our camera follow sprite block with the two offset nulls we created during the Lynn setup function. A button follows the Lynn_offset_Right null sprite and B the Lynn_offset_Left null sprite. Note the on game update block used to adjust the nulls to keep them in sync with Lynn's x position with offsets.

Lastly, we'll play a little two note climbing sound.

Pizza Power Up

When Lynn needs a power up, she can grab a slice! on sprite of kind Player overlaps otherSprite of kind Food will take care of noting when the collision occurs.

In this block we'll use destroy other Sprite with hearts effect for 500 ms to get rid of the pizza, change life by 1 to power up the hearts, and play sound ba ding until done.

Scoring

The faster Lynn makes it to the top, the higher the score! In order to calculate the score, we'll use on game update every 50 ms block.

It will first check that the goalMet variable is false.

Then, it will change scory by -1 point from the initial value of 1000.

Not only does this determine the score, but it's also a countdown timer! By adding the if score < 1 then ... game over lose blocks we can cause the game to end if the player takes too much time.

 

 

Bricks Keep Falling on My Head!

There are two kinds of enemies in Trash Panda -- falling bricks and flying crows. They work in nearly the same way, with a few adjustments. We'll look at the bricks first.

To begin with, on game update every pick random 600 to 1200 ms gives us a bit of variability to when bricks will fall.

Then, we check if dropBricks = true to see if the game has started and bricks are allowed to fall.

for element value of array of all pink tiles...do is a way of iterating through a list. In this case, there are three pink tiles in the tile map at the top of the level. The for element... block loops through those three tiles, one at a time.

Per element, the loop will do an if 10% chance then check, which randomizes the true/false check.

When the percent chance comes up true, we set brick to sprite of kind Enemy with a brick sprite graphic, and then on top of value place brick sets the sprite on top of the currently active element tile.

To drop the brick we set brick vy to 80, and we also set it to destroy on wall which is what happens if a brick reaches to bottom of the tile map where there is a row of tiles with the wall flag turned on.

Lastly, we'll play a descending tone glide from 1320hz to 440hz over the course of 800ms. This is a fancy looking block, because it doesn't yet exist in MakeCode Arcade's Block mode -- it was entered over in the JavaScript mode.

Crows Fly

We'll make the Crows just as we did the bricks. The main differences here are the tiles from which they spawn on either side of the board, and direction of travel, and the addition of a two frame animation cycle.

You can tune the feel of the gameplay by adjusting the timing and velocity of the various enemies. Try a lot of playtesting and adjusting of these, and get friends to help out!

I've Been Hit!

Here's what happens when Lynn collides with a brick or a crow:

  • on sprite of kind Enemy overlaps otherSprite of kind Player block senses the collision
  • change otherSprite y by 22 moves Lynn down the building a bit, so she looses progress and really needs to scramble to get to the top. Go Lynn!
  • change life by -1 removes one of the player's hearts
  • destroy sprite with rings effect for 200 ms gets rid of the brick or crow
  • camera shake by 5 pixels for 350 ms gives the player a good, jolting sense of a strong impact

Reaching Goals

The final element of the game is to determine what happens when Lynn reaches to top of the UBS building!

on sprite of kind Player overlaps otherSprite of kind Goal Lastly, we'll play a little two note climbing sound is the block that will check for that collision.

  • First, we'll flip the goalMet variable to true. Based on our previous setup, this will disable the buttons and stop the scoring from counting down anymore
  • We'll set Lynn to her Idle pose, and set acceleration y and velocity y to 0 so she stops moving
  • set dropBricks to false prevents new brick from spawning

Now, let's get on with some celebration!

  • play sound magic wand until done
  • show animation theatre chase for 2000 ms comes from the Light extension and will light up a pattern on the PyGamer or PyBadge NeoPixel strip!
  • use repeat block to flash the keyLogo from red to white four times, landing on red.
  • game over ... WIN!

 

This guide was first published on Jun 15, 2019. It was last updated on Mar 08, 2024.

This page (Trash Panda Game Play) was last updated on Mar 08, 2024.

Text editor powered by tinymce.