How to Make Space Invaders on Micro Bit.

Introduction: How to Make Space Invaders on Micro Bit.

So the first step is to create our ship. You go to "Basic" and add a "On start" block. Then you go to "Variables" and you create a variable called "SHIP" and select a block from the "Variables" tab that says "Set sprite to 0". Then you put "SHIP" instead of "sprite". Then you go the the "Game" tab and select "create sprite at x 2 y 2" and you put that instead of "0" in the "set SHIP to 0". After that you chance the "y" to 4 instead of 4. Also, the score counter is optional. But there you go, we got our ship, and the next step will be the movement of our ship.

Step 1: Movement of the Ship.

You go to the input tab and take the blocks "on button B pressed" and "on button A pressed". Then you go to the Game and select "sprite move by 1" and change to sprite to SHIP. Put it on the "On B button pressed" block. And you do the same thing for A but instead of moving by 1 you put -1.

Step 2: Shoot Variable.

So first you will go to "Input" then select "On button A+B pressed" and add it to the code. Then you make a variable called "SHOOT", then go to variable again the add "set SHOOT to 0" and change the "0" to "create sprite at x:_ y:_" then select "ship x:" in the game section then put it on "create sprite at x: ship x:". It's very confusing but you can understand it better from the image. Then you do the same step for "y". Then you go to the game tab and add " SHOOT change brightness by 88". Then you go to the loop tab and select "repeat 4 times and ad that to the code. Then inside that tab you put "SHOOT change y by -1, then still in the "repeat" code, add "pause 150 ms" for the speed of the "SHOOT" variable, then still inside the loop thing, you go to logic and select "if______ then" and add it to the logic thing. In the blank space of the logic block you put "is____touching___". Then you add the variables "SHOOT" and "ENEMY" (create a variable called "ENEMY", and we'll define it later). Then inside the logic block add "delete ENEMY" and "delete SHOOT", then if you want you can add some music or sound effect when you destroy an enemy, then you add a block "change score by 1". Then outside the loop and logic block, you add another "if________ then". Then you go to logic and add the block that has "0 ≤ 0" on the blank space. Then on the first 0, you put "SHOOT y". Then inside the logic block you put "delete SHOOT"

Step 3: Making the Enemy Variable.

FIrst add a "forever" block and create a variable named "ENEMY", the go to the variable tab and add "set ENEMY to __", and in the blank space put "create sprite at x:__ y:____". Then in the blank space of the "create sprite" block, add "pick random from 0 to 4" in the "math" tab. Then under that, you add "ENEMY set brightness to 150" from the "game" tab and then add "pause 100 ms" under it. After the "pause" block, you add "ENEMY turn right by 90 degrees", which is located in the "game" tab. Then you go the "loop" tab and add "repeat 4 times" and inside of the "loop" block, you add "ENEMY move ny 1" and "pause 500 ms". Now we go over to the logic tab and add 2 blocks of "if____ then". And inside the first blank space, you add "is ____ touching ___" and add "ENEMY" in the first blank space and "SHIP" in the second blank space, and inside the logic block, you add "game over". Now in the other logic block, we add "is ____ touching edge" and in the blank space we add "ENEMY", and inside the logiv block we add "delete ENEMY"

Step 4: This Is How It Should Look Like

Hopefully I wasn't so bad at explaining how to make this and hopefully you enjoyed the game:)

2 People Made This Project!

Recommendations

  • Tinkercad Student Design Contest

    Tinkercad Student Design Contest
  • Back to School: Student Design Challenge

    Back to School: Student Design Challenge
  • Robots Contest

    Robots Contest

4 Comments

0
dobidoalt
dobidoalt

Question 1 year ago on Step 4

My shots keep spawning on the edge how do I fix this?

F8E91E94-A732-4048-BD98-786D084109FB.png
0
juda.aurum.260
juda.aurum.260

Answer 4 months ago

you forgot the move y by -1

0
nasaboy08
nasaboy08

5 months ago on Step 4

my enemy's dissapear at the third line:(
what can i do?