Today, we're going to have lots of fun making a spooky Halloween game called Pumpkin Catch. You'll create a friendly ghost that you can move around to catch falling pumpkins and get points. But watch out for the falling stones β they might take away your lives! We'll build everything step by step using code. Are you ready to start your adventure?
Go to MakeCode Arcade and create a new project. Name your project 'Pumpkin Catch'.
Let's create the ghost that you will control to catch pumpkins. We will use code to make a sprite for the ghost.
Add the following code and choose the ghost sprite from the gallery:
let mySprite = sprites.create(img` ........................ ........................ ........................ ........................ ..........ffff.......... ........ff1111ff........ .......fb111111bf....... .......f11111111f....... ......fd11111111df...... ......fd11111111df...... ......fddd1111dddf...... ......fbdbfddfbdbf...... ......fcdcf11fcdcf...... .......fb111111bf....... ......fffcdb1bdffff..... ....fc111cbfbfc111cf.... ....f1b1b1ffff1b1b1f.... ....fbfbffffffbfbfbf.... .........ffffff......... ...........fff.......... ........................ ........................ ........................ ........................ `, SpriteKind.Player)
Now, let's make the ghost move left and right. We will add code to control it and put it at the bottom of the screen.
Add the following code:
let mySprite = sprites.create(img` ........................ ........................ ........................ ........................ ..........ffff.......... ........ff1111ff........ .......fb111111bf....... .......f11111111f....... ......fd11111111df...... ......fd11111111df...... ......fddd1111dddf...... ......fbdbfddfbdbf...... ......fcdcf11fcdcf...... .......fb111111bf....... ......fffcdb1bdffff..... ....fc111cbfbfc111cf.... ....f1b1b1ffff1b1b1f.... ....fbfbffffffbfbfbf.... .........ffffff......... ...........fff.......... ........................ ........................ ........................ ........................ `, SpriteKind.Player) controller.moveSprite(mySprite, 100, 0) mySprite.y = 110
Let's make pumpkins fall from the top. The ghost will catch them for points.
There is no pumpkin sprite in Makecode Arcade, so we will need to design our own using the paint function for this!
Add the following code:
let projectile: Sprite = null game.onUpdateInterval(2000, function () { projectile = sprites.createProjectileFromSide(img` . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . f f f f . f f f f f . . . . . f f 4 4 f f f 4 4 4 f f f . . . f 4 4 4 4 4 4 4 4 4 4 4 f . . . f 4 4 4 4 4 4 4 4 4 4 4 f f . f f 4 4 f f 4 4 4 f f 4 4 4 f . f 4 4 4 f f 4 4 4 f f 4 4 4 4 . f 4 4 4 f f 4 4 4 f f 4 4 4 4 f f 4 4 4 4 4 4 4 4 4 4 4 4 4 4 f 4 4 f 4 4 4 4 4 4 4 4 f f 4 f . f 4 f f f 4 4 4 4 4 f f 4 4 f . f 4 4 4 f f f f f f f 4 4 f . . f 4 4 4 4 4 4 4 4 4 4 4 4 f . . f f f f f f f f f f f f f f . . . . . . . . . . . . . . . . . `, 0, 50) projectile.x = randint(0, scene.screenWidth()) projectile.setKind(SpriteKind.Food) })
This code makes a new pumpkin every 2 seconds. It falls down from a random spot at the top and is set as 'Food' kind.