This project is the development of a Space Invaders style game. It is some kind of Space Invaders, but, for Microchip PIC platform.
The project includes hardware and software descriptions, using a PIC18F45K22 microcontroller from Microchip.
PIC INVADERS was developed as a personal project when I was between my 3rd and 4th semester of the Electrical Engineering at UFSM. So I would like to make it clear that if I would develop the same code today, certainly a lot of things would be different, improved and optimized.
The project was developed initially using CUSCO-PIC platform, hardware platform developed in Caxias do Sul.
However, it was also mounted in dedicated hardware, and everything worked perfectly.
Still, I will give some tips on how to build your own hardware to run the game. :)
The code was developed specifically for Microchip microcontrollers.
However, with certain changes in initialization configuration files, registers (mainly input and output), and settings of the LCD display, the design can be adapted to other microcontrollers from other manufacturers.
Above all, it was developed with a focus on PIC platforms.
The project was developed entirely in C, using a 18F family microcontroller.
The game consists of an Human Machine Interface (IHM) and some buttons that allow the user to control your ship.
The player ship can go up, down and shoot enemy ships.
The game contains 4 buttons: UP, DOWN, FIRE and SPECIAL.
File types in project:
- The .c files contains the developed software in C
- The .h files are the headers of .c files
- The .asm file contains the code translated to assembly language
- The .hex file is the ready to burn file, containing the code in hexadecimal language.
- Inside /Proteus folder it is the project hardware schematic.
The .c and .h files:
- menu.c e menu.h --> Files responsible for creating function of the game menu.
- naveAtaques.c e naveAtaques.h --> Functions responsible for the creation of enemies.
- gameControle.c e gameControle.h --> Control game functions, like Win, GameOver, etc..
- funcoesAdicionais. e funcoesAdicionais.h --> Extra functions, like CustomChar() and Random()
To simulate the game, just open the workspace on /hardware folder using Proteus software.
Double-click on the microcontroller and import the .hex file.
Bill of materials (considering mounting in an universal board or PCB):
- 1 x PIC18F45K22 microcontroller
- 1 x 40 pins header
- 1 x 7805 Voltage Regulator
- 5 x Push button
- 5 x 1k ohm resitors
- 1 x 20MHz Crystal
- 2 x 22pF Capacitors
- 1 x 100nF Capacitors
- 1 x LCD 2x16
- 1 x 9V battery wired connector
In case of building the circuit:
- Do not forget to feed the microcontroller in its 2 different pins (2xGND e 2xVCC)
- Do not forget to put 0V on the LCD not used pins.
- Do not forget RESET button, or keep the MCLR microcontroller pin in HIGH STATE.
Once the game starts, tells a brief history of the game's plot, then the user can check the control buttons (Help), read on the game development information (About), or take a New Game.
Each button is responsible for accessing different content (New Game, About and Help), and one of the buttons is the "Back" button.
If any enemy ship cross the 16 screen characters or the player's ship is hit by a shot, it's Game Over.
After defeating some random enemies, it appears a final boss, who has a unique way of being defeated and I will not tell here.
When Game Over, the microcontroller RAM is erased, and the game is restarted. (This function may not work in simulation).
Below are some pictures of the hardware mounted in Proteus software, and its operation during simulation.
Hardware mounted in Proteus software:
Welcome screen:
Main screen:
The game is running o/:
You failed! Game Over. :(
What could be enhanced?
- I think that the game could be ported to a larger display, maybe a 4x20 LCD display and then some other hardware that best accommodate the multiple functions of the game.
- The game can be optimized, as I said at the beginning of the document and can be implemented new levels, new enemies, etc ..
- Furthermore, in order to implement more appropriate hardware, it would be interesting to develop new levels and point counting system.
- I do not intend to release many updates to the game. Not now, at least, because I am involved in other projects and this is a very old one. However, if you have any contribution, please, please let me know and I shall be very happy to see. :))
The project can be reproduced without any problems.
However, I only ask you to keep credits to the author.
Enjoy!
Hollweg