How to Make a Basic Shooter
Описание | Как создать проект игры "стрелялки" и какие блоги и конструкции используются для построения игр такого типа. |
---|---|
Область знаний | Математика |
Область использования (ISTE) | Computational Thinker |
Возрастная категория | 10
|
Поясняющее видео | |
Близкие рецепту понятия | |
Среды и средства для приготовления рецепта: | Scratch |
This tutorial features an endless basic shooting game.
Plan
Before starting to build the game, here's a plan that will be followed:
- Make the player fire lasers when the left mouse button is down.
- When a shape is destroyed, give the player a specific amount of money depending on what shape was destroyed.
- When a laser hits an enemy (in this tutorial, a zombie), make that zombie lose some health points; when the zombie runs out of health points (has less than 0.1), delete the zombie and change the $ by an amount depending on what type of zombie it is.
- Include multiple weapons for the player to choose from.
- Release specific zombies at a specific rate depending on the level/wave the player is on.
- Show all variables that need to be shown in a fancy way.
Building the Game
There are no given costumes included with this tutorial — be creative and create some!
The Player
This section will focus on the movement and direction of the player sprite. After a base costume for the PCS (player-controlled sprite) has been made, create the variables (Player Bounceback)
, (xspeed)
, and (yspeed)
for all sprites.
when flag clicked set [Player Bounceback v] to (0) // reset the player bounceback forever if <<(Pause)=(0)>and<(Player Bounceback)<(0)>> then // if the game isn't paused and the player bonunceback is less than 0(the variable will be negitave to make the player go backward) then... move (Player Bounceback) steps // move the player back change [Player Bounceback v] by (0.1) // increase (or decrease, whichever way you'd refer to it as) the player bounceback. By adding a positive to a negitave make the number smaller end end when flag clicked // You can change this if you would like to. switch costume to (player v) // Switch the costume to "player" or what you named your player costume. set [xspeed v] to (0) // Reset xspeed. set [yspeed v] to (0) // Reset yspeed. go to x(-100) y(0) // Move the pcs (player-controlled sprite) to the middle of the left side of the screen. forever // Loop the following script forever. if <(pause) = (0)> then // if the game isn't paused point towards [mouse-pointer v] // Make the pcs point towards the mouse pointer. change x by (xspeed) // Change x by a variable. change y by (yspeed) // Change y by a variable. if <<key (w v) pressed?> or <key (up arrow v) pressed?>> then // If w or up arrow key pressed. change [vspeed v] by (1) end if <<key (s v) pressed?> or <key (down arrow v) pressed?>> then // If s or down arrow key pressed. change [vspeed v] by (-1) end if <<key (a v) pressed?> or <key (left arrow v) pressed?>> then // If a or left arrow key pressed. change [xspeed v] by (-1) end if <<key (d v) pressed?> or <key (right arrow v) pressed?>> then // If d or right arrow key pressed. change [xspeed v] by (1) end set [yspeed v] to ((0.9) * (yspeed)) // Decrease the y variable. set [xspeed v] to ((0.9) * (xspeed)) // Decrease the x variable. create clone of [myself v] // This is optional (O#1). if on edge, bounce // doesn't let the player go off the edge - going off the edge restricts the player from firing end end when I start as clone :: control hat // Do this if you did (O#1). switch costume to [trail v] // A costume is needed without any player graphics. set size to (90)% // Set the size to 90% (9/10) of the original size. repeat (10) // Repeat the following code 10 times (10*10=100, 100% ghost=invisible) change [ghost v] effect by (10) // Make the trail slightly disappear. end delete this clone // Delete the clone.
Guns and Weapons
The player needs to have some tools to defend themselves. In this tutorial, there will be eight weapons that one can use.
- Daggers (move forward and back when mouse is down).
- Sword (turns when mouse is down).
- Flank swords (turns when mouse is down).
- Gun (points towards mouse pointer & fires a projectile when the mouse is down).
- Machine Gun (same characteristics as a gun, but fires rapidly, and isn't very accurate).
- Twin guns (like a machine gun, but it is accurate).
- Hunter (fires two fast and piercing projectiles).
- Destroyer (fires a projectile that can go through many zombies and shapes while dealing excessive damage).
Enemies
In this game, the enemies will be zombies. They will not fire projectiles but will instead smash use melee attacks on the player instead. There will be 5 types of zombies.
- Normals.
- Fast (run instead of walk and gives 100% more cash than normals).
- Strong (have more shield than normals and give 200% more cash than them).
- Boss (walk slower than normals, but have 20000% more health and give 5000% more cash than them. They also spawn clones — who are like normals, but have 50% of their health).
- Boss minions (normals but have less health).
Shapes
The player should have a way to earn cash without having to shoot zombies. In this game, the player will have 3 different shapes to destroy.
- Squares (has low protection, and a low amount of points will be earned by destroying it).
- Triangles (100% more protection that a square, and gives twice the cash).
- Pentagons (has high protection, and gives a bundle of cash).
Displays
The scripts below will give the game a display, although you can skip these two steps and just show the variables with show variable [ v]
and hide variable [ v]
. Make sure you go to the costumes section of a new sprite and type all of the one-digit numbers (1, 2, 3, 4, 5, 6, 7, 8, 9, 0) in 11 costumes and name them their number. Then, include a blank costume named "" (clear the name spot) — this will help in the coding part. Lastly, make sure that you position them at the center. To properly center the costumes, use the marked cross section in the middle.
Before any code is created, create the variables below for this sprite only: (variable)
and (digit)
Here's the code:
when flag clicked hide set y to (150) // Make sure you're cloning at the right height... set [variable v] to (1) // This variable will be used to define what variable will be displayed. set [digit v] to (1) // This variable is used to determine the digit of the variable. clone | x:(-205) // Use multiple blocks to make the numbers appear faster. clone | x:((x position)+(17)) clone | x:((x position)+(17)) clone | x:((x position)+(17)) clone | x:((x position)+(17)) set y to (130) set [variable v] to (2) set [digit v] to (1) clone | x:(-205) // Most likely, the "lives" variable won't go more than three digits, so the block is just used three times. clone | x:((x position)+(17)) clone | x:((x position)+(17)) set y to (-160) set [variable v] to (3) clone | x:(-165) // Most likely, the "waves" variable won't go more than three digits, so the block is just used three times. clone | x:((x position)+(17)) clone | x:((x position)+(17)) define clone | x: (x) show set x to (x) create clone of (myself v) // Create a single-digit displayer. change [digit v] by (1) // Change what digit the variable will display. hide when I start as a clone go to [front v] layer // Stops the player from "walking" on the variable. forever if <(variable)=(1)> then switch costume to (letter(digit)of($)) end if <(variable)=(2)> then switch costume to (letter(digit)of(round(player life))) // You have to round it so it doesn't go and display a decimal value. end if <(variable)=(3)> then switch costume to (letter(digit)of(wave)) end end