+21622886281
Game Scratch

Tennis game with Scratch

Tennis is a popular sport that is played by millions of people around the world. It can be played as a recreational activity or as a competitive sport at the professional level. In tennis, players use rackets to hit a ball back and forth over a net, trying to score points by hitting the ball into the opponent’s half of the court. The player who wins the most points in a match is the winner.

There are many different ways to play tennis, including singles (one player on each side) and doubles (two players on each side). The rules of tennis are governed by the International Tennis Federation (ITF).

There are also many video games that simulate the sport of tennis, which can be played on a variety of platforms such as home consoles, mobile devices, and computers. These games typically allow players to control a virtual tennis player and compete against other players or the computer. Some popular examples of tennis video games include the Mario Tennis series and the Top Spin series.

Scratch is a visual programming language that can be used to create a variety of interactive programs, including games. It is possible to create a simple tennis game using Scratch.

To create a tennis game in Scratch, you will need to create a background image that represents a tennis court, and create two sprites that represent the players. You can then use the Scratch blocks to make the sprites move and hit the ball back and forth over the net. You can also use blocks to keep score and determine when the game is over.

To add more realism to the game, you can use sound blocks to play sound effects such as the sound of a tennis ball being hit, and you can use costume changes to animate the sprites and make them look like they are swinging their rackets.

Creating a tennis game in Scratch is a good way to learn programming concepts and have fun at the same time.

Description of Tennis game with Scratch:

The game of Tennis is one of the first computer games. This simple game includes two rackets and a ball.

The game is played with two human players.

The object of the game is not to miss the ball by either player.

The game stops if the ball touches the left edge or the right edge of the stage.

Creation of the two player1 and player2 sprites:

1) Go to the new sprites section and select the brush icon.

2) Draw the player1 sprite using the drawing editor.

3) Player1 sprite program:

Insert these program blocks in the code area of ​​the Player1 sprite which allows the racket to be directed up or down using the two keys (a and q) on the keyboard.

4) Draw the player2 sprite using the drawing editor.

3) Player2 sprite program:

Insert these program blocks in the code area of ​​the Player1 sprite which allows the racket to be directed up or down using the two up and down arrows on the keyboard.

Added ball sprite from the Scratch library:

The library gathers all the sprites created by Scratch.

1) Click on the Choose sprite icon.

2) Clicking the “Import Sprite” button should take you to the Sprite menu, a library of different sprites you can use in the program.

3) Click on the sprite ball and Scratch will create it as a new sprite in your game.

4) Sprite ball program:

First we will initialize the position and orientation of the sprite ball:

Then we move the sprite ball through the scene using the repeat until loop.

The sprite stops moving if it exceeds its abscissa 224 or -224.

If the sprite ball touches one of the two paddles it changes its orientation

If the game stops, the message ‘game over’ is displayed.

Here is the final sprite ball program:




0 commentaire


Leave a comment

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Scroll to Top