Fighting game in scratch

Fighting game in scratch



There are two sprites: Imran and Faysal

Each sprite has 8 costumes

Imran

1st row: standing, punching 1, punching 2, beging punched
2nd row: kicking, being kicked, winner, loser

Faysal

1st row: standing, punching 1, punching 2, beging punched
2nd row: kicking, being kicked, winner, loser

There are other different sounds and backdrops which you can find in the file.

Copy the project: https://scratch.mit.edu/projects/855785035


Final result:

Let's do it step by step:

  1. Moving Faysal to the left and right
  2. Task: Moving Imran to the left and right
  3. Punching and kicking of Faysal
  4. Task: Punching and kicking of Imran
  5. Being punched and kicked of Faysal
  6. Task: Being punched and kicked of Imran
  7. Winning of Faysal
  8. Task: Winning of Imran
  9. Losing of Faysal
  10. Task: Losing of Imran
  11. Changing the backdrop


1.Moving Faysal to the left and right

Begin from Faysal sprite


Step 1. Initial state.

Faysal shoud

  • be on the right bottom corner
  • be in the standing state
  • move only left and right


Step 2. Moving left

Step 3. Moving right. Build yourself


2.Task: Moving Imran to the left and right

Use q and w keys to move left and right for Imran


3.Punching and kicking of Faysal

We use o, p and l keys to punch and kick for Faysal

  • o key - for punching 1
  • p key - for punching 2
  • l key - for kicking

Step 1. Punching 1

1.When we click o key we change it's costume called 3 punch 1.

2.Then tell to Imran sprite "hey Faysal is punching, if it touches you change your state". So here we used broadcast block and wrote new nessage in it Faysal punched.

3.Then wait for 0.3 second

4. Then switch back to it's initial state

5. Then again wait 0.3 seconds

Here we used wait block so that Faysal can change it's state after some seconds

6. Play sound when you receive 'Faysal kicked' message

Step 2. Punching 2. Build yourself. For punching 2 use previous message to broadcast

Step 3. Kicking. Build yourself. For kicking create new message like 'Faysal kicked' to broadcast


4.Task: Punching and kicking of Imran

Use e, r and d keys for punching and kicking

  • e key for punching 1
  • r key for punching 2
  • d key for kicking

Create new message for punching and kicking like 'Imran punched' and 'Imran kicked' for broadcasting

Use punch and kick sounds


5.Being punched and kicked of Faysal

Step 1. Being punched

1.We are checking if Imran touches Faysal in punching state then switch costume to being punched

2.Play sound

3.wait for a while

4. switch back to initial state


Step 2. Being kicked. Do it yourself

6.Task: Being punched and kicked of Imran

Do as the previous task


7.Winning of Faysal

Step 1. Create variable called Faysal. We need this variable to save the Faysal's punched and kicked scores.

  • 1 point for punching
  • 2 points for kicking

Step 2. Set Faysal variable to 0 (Do it in the sprite of Faysal)

Step 3. Go to Imran sprite. Insert change Faysal by 2 block. So for kicking we give 2 points, for punching 1 point (Do it in the sprite of Imran)

Add 2 points to Faysal for kicking

Add 1 point to Faysal for punching

Step 4. If score is equal or greater then 20 then Faysal wins

1.Stop all scrips in this sprite

2.Change costume to winner

3.Broadcast that Faysal won

4.Play sound

5.Then stop all

Insert this blocks into forever block in Faysal


8. Task: Winning of Imran

Do it yourself

9. Losing of Faysal

Build this blocks in Faysal sprite


The result:


10.Task: Losing of Imran

Do it yourself


11.Changing the backdrop

We have 2 backdrops:

Change the backdrop when you receive 'Imran is winner' message (Backdrop)








Report Page