Raspberry Pi 4 Ultimate Guide: From Beginner to Pro: Everything You Need to Know: Setup, Programming Theory, Techniques, and Awesome Ideas to Build Your Own Projects (Raspberry Master Series Book 1) by Upton Ethan J
Author:Upton, Ethan J. [Upton, Ethan J.]
Language: eng
Format: epub
Published: 2019-11-30T16:00:00+00:00
Application Development - Hard Level
Let's now create a difficult level game that we will call Block Breaker: The Game will have a Menu, game over screen and will be controlled by the mouse. The interesting thing about the block breaking game is that it works with practically all the functions found on the Scratch platform and the player will have a lot of fun developing the game and playing, as the main objective of the game is to be able to break all the blocks in the shortest time.
Let's import the library stage: go to the bottom left corner and click on the Choose background icon;
Several models of the library are shown, choose one (this may be Brick wall 1) and click Ok. Using Paint Editor (see item PAINT EDITOR) draw a green line at the bottom of the wall;
Note that there is a scroll bar under the stage;
Remember to draw the line along its full length.
This line will be the limit: every time the ball touches it, thus passing through the racket, a message of Game Over will be sent, and the game will end. Now let's create the racket (our first actor) that will hit the ball to break the blocks. Repeat what you have already done; the racket is now horizontal and blue. The blocks that will be destroyed by the ball are also actors. Just as you did with the racket, draw a block. Duplicate the blocks (in our case, we get 18 blocks). Name the blocks by numbering them: Block 1, Block 2, Block 3 ... and set the colors for the blocks to have a heterogeneous structure. Our other actor is the ball; let's import it from the library. After creating all the actors, drag them on the stage. Now we need to program each of these characters. The first script will be the racket: it will only walk on the x axis, following the mouse, and should hit the ball. Click on the Actor Racket, and on the Scripts, tab enter the two start instructions. When you click and Go to x: ... and y: ...; change the starting position to x: -58 and yy: -148. Then enter the Always statement.
Drag the Change x statement to ... (from the Motion function) to the Always open; then drag the Mouse Position x instruction (from the Sensors function) to the typing box. This will keep the racket on the same line (y axis) but will follow the mouse to the right and left (varying the x axis). This is just the racket script. The blocks also have a simple behavior: when the game starts, they show themselves in a certain position; if they are touched by the ball, they hide.
To do this, we will use two new commands: Show and Hide (from the Appearance function). Click on a block to start your script. Put the command When you click ... (from the Events function), then drag the Show (from the Appearance function) command and the Go to x: .
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Design | Control Systems |
DSPs | Embedded Systems |
Microprocessor Design | PIC Microcontroller |
Linux Device Driver Development Cookbook by Rodolfo Giometti(3932)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3586)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3523)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3353)
TinyML Cookbook by Gian Marco Iodice(3293)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2838)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2601)
Fusion 360 for Makers by Lydia Sloan Cline(2219)
Networking A Beginner's Guide by Bruce Hallberg(2209)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2030)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1950)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1898)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1860)
MicroPython Projects by Jacob Beningo(1728)
Hands-On Internet of Things with MQTT by Tim Pulver(1704)
