Dragon Jump II
Dragon Jump is inspired by the Chrome browser Dino game. You must make the dragon jump over obstacles and help it go as far as possible. Yes, the dragon is still learning to fly, so it can't simply fly over and has to take long strides :)
Supplies
Tools used: Scratch (https://scratch.mit.edu/projects/editor)
Scratch helps create innovative games using simple drag-and-drop components.
There are a variety of components such as motion (to create movement/animation), looks (to control how the entities or the background look), sound (to add any sound effects), events (to define specific events when certain code flow shall execute), control (to direct the flow of code using various control statements), sense (a bit similar to events, to sense certain inputs and other changes in the canvas), operators (to solve any statements (one of the most important blocks)), and variables (to store data while the game runs).
We can also create custom blocks if we want to use some complex snippets and don't want to recreate them from the beginning every time. Additionally, there are certain tasks that are not possible to be done with the given blocks. For those cases, custom blocks come to the rescue.
Anyway, this tutorial only uses pre-existing blocks and so you don't have to think about the custom blocks yet.
Create Entities
We need to create entities for the game. Entities are the subjects that are present in the game. Here, we have a dragon (the main character entity), repeating trees (the obstacle entities) and a background to give the game a lively look.
Additionally, you can add some special effects to the game. Like here I have added a sound on every dragon jump (spacebar click). Feel free to explore various similar options. You can even record custom sounds/dialouges and add it to your game.
Configure Main Character Movements
Make the dragon jump on an event. Here, I made it jump at the space bar click event.
Endless Obstacle Loop
Make the obstacles keep appearing in a never-ending loop, as shown in the code flow.
Also, on the game restart, both the main character entity (dragon) and the obstacle entity (trees) shall take their initial positions. This is also implemented in the block code below.
Scoring and Game End Condition
Create a variable block and name it "score".
Set its value to zero as the game starts. Every time the dragon jumps and successfully dodges an obstacle, increment the score by one and display it on the screen.
If the dragon fails to dodge the obstacle, the game ends. And everything shall freeze at that instant.
The game can be restarted after that.
Project Resource and Conclusion
This was a simple game and it primarily teaches you the following things:
1.) The concept of entities.
2.) Basic animation of entities.
3.) Use of Variables
4.) Entity Collision detection
Using these fundamentals, you can use your imagination and make as many games. I hope you found something useful here. I'll see you all again in my next tutorial!