2D Arduino Game: Alien Invasion
by AlexAndAmigos in Circuits > Arduino
1114 Views, 4 Favorites, 0 Comments
2D Arduino Game: Alien Invasion
This is meant to be a fun little game about destroying aliens. When an alien appears you need to press the button to "zap" it with a blue LED. It may seem easy but it is actually slightly hard, due to the fact that you need to process the fact that an alien has appeared and you need to press the button and some people do not have very fast reflexes.
This uses an arduino UNO and skills learnt from the arduino class but mostly my brother.
Electronics
- 4x 220 - 1k resistors
- 2x Blue(or other color) LEDS
- 2x Red LEDS
- 1x small pushbutton(4 leads)
Various breadboard wires
1x Arduino UNO
- 1x 10k ohm resistor
The Hardware
First attach a standard power system as in Fig.1. Then, put the button inbetween both the sides, and attach it to the power as in fig.2 and fig.3. Attach the button to pin 2. Set up the four 220k resistors to rows 1 and 20, 2 on each row as in fig.4. Then attach the blue LEDS, bent over to row 1, and the red ones to row 20. Attach the blue led on the left to pin 13 and the one on the right to pin 12, the left "alien" to pin 11, and the right one to pin 10. Make sure the leds are properly hooked up and the the negative end is attached to the resistor which is attached to the ground.
The Code
Download the file, and copy it over to your Arduino. The left "shooter" should flash and then after a random time one of the "aliens" will flash on. Press the button to "shoot" it. If the red LEDs flash, you have lost, if the blue leds flash you have won. It will take some "shots" for the blue LEDs to flash, And if you do not press the button quick enough you will lose and the game will automatically start over. Everything is randomly generated, so there is no telling where an alien will next pop up.