Player Vs Computer
Player Vs Computer
In this project you will make any sprite (I’m using Wizard girl) as Player that you can control its
move - up and down. And any sprite (I’m using Dragon) as computer that will move by itself
when we click on the green flag. The player will shoot something (I’m using lightning), if key
space pressed. And the computer also shoot something automatically (I’m using Fire). This
game have 2 variables for computer’s and player’s live. You can find the steps and instructions
how to make it down below.
2. Do the code
First make the computer sprite glide 1 second to certain X and Y pick random 180 to -
180 right after you clicked the green flag. Then when the green flag clicked set computer
life to any number you like (maximum is 5, minimum is 3). Then add forever block,
inside it make condition : if touching player’s shooting object then change computer life
to -1. Notes: if you want the sprite smaller you can add <set size to> block. If you want
your sprite have special looks effect you can use <set effect to> block. And put this block
right below <when green flag klicked> block.
Secondly make the player sprite move up by using if key up arrow pressed then change
Y by 10. And if key down arrow pressed then chane the Y by -1. When green flag clicked
set the player’s life to any number you like (maximum is 5, minimum is 3). Then add
forever block, inside it make condition : if touching computer’s shooting object then
change computer life to -1.
After that we will make the code for player’s shooting object. The code will be start
when you click the space button. And it will go to player, repeat until touching edge or
touching computer and change x by 10. And then hide this sprite. Don’t forget to add
show block at beginning.
Then we will make the code for computer’s shooting object. Use when green flag
clicked code to start this script. Then forever blocked to make the script inside run
continuously. Inside forever block you’ll have wait (pick random 0.1 to 0.5) second, go to
computer sprite, repeat until touching player or touching edge, show and change X by -
10. Outside the repeat until block add hide.
The last code is for Text Sprite. This sprite will hide when you click n green flag. If
computer’s live is 0 then show and change looks to costume player win and stop all. If
player’s live is 0 then show and change looks to costume computer win and stop all.
3. Choose any backdrop you like.
4. Enjoy the game!