Programmingempire
In this article on Essential Elements of Scratch 3.0, I will explain some basic concepts for learning Scratch 3.0.
The following section describes different types of block commands in Scratch including sequential commands, conditional commands, and looping commands.
To begin with, let us see how to create some sequential commands. In order to create a Scratch project, visit the following URL.
Next, click on the Create tab as shown below.
The following Scratch editor opens.
At first, let us create a simple project of moving sprites. Therefore, select a sprite as shown below.
After that, you need to drag the code blocks that cause this sprite to move. Hence, we select the following blocks.
- Go to a random position
- Move 30 steps
- Wait for 0.1 seconds
- Repeat above steps forever
- Start when green flag is clicked
As can be seen below, the above steps move the ball sprites forever.
Output
Once we get the ball moving, we can proceed further to create a simple game. In this game, we have another paddle sprite that moves horizontally. Whenever, ball touches the paddle its color changes for certain duration. After that, again its color gets normal.
Code for Ball Sprite
At first, we take two variables z and y. While, y indicates a touch, the variable z is used for the duration, the color of ball remains changed. Therefore, initially, we set z to 20 anf y to 0. After that, in forever loop, ball goes to random position, moves 30 steps, and waits for 0.2 seconds. If the ball touches the paddle, its color changes and y becomes 1. Further, if y is 1, z decrements by 1 in each step until it becomes 0. Once z becomes 0, y and z both get their initial value of 0 and 20 respectively. After that, graphics of the ball is cleared.
Code for Paddle Sprite
Since, the paddle sprite needs to move horizontally, we take two variables x and offset. While x denotes the x coordinate, the variable offset represents change in its value. Further, the y-coordinate remains same at -150, since paddle is not moving vertically. Therefore, in the forever block, first the paddle moves to x and y coordinate. After that, the value of x changes by the offset and paddle waits for 0.1 seconds. If the value of x reaches -150, the offset becomes10. Hence, now paddle moves in right direction. Similarly, if the value of x becomes 150, the offset is again becomes -10 so that now paddle moves in left direction.
Output
You can view the project here:
https://scratch.mit.edu/projects/629113225/
Further Reading
How to Create Moving Balloons Project in Scratch 3.0
Cloning Sprites in Scratch 3.0
Getting Started with Scratch 3.0
Essential Elements of Scratch 3.0
Example of Column Properties in CSS
Examples of Outline Properties in CSS
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML