When UNIHIKER came onto the market, I had worked already with PyGame myself and developed games for other devices and environments. I found a very good resource online to learn PyGame. Since UNIHIKER is somewhat limited in terms of hardware, I have adapted the example for UNIHIKER in this project.
In this project, we're diving into the exciting realm of Python game development using PyGame on the versatile UNIHIKER device! We'll connect an DFRobot analog joystick and craft a fun, simple shooter game.
The Gravity: Joystick Module is very easy to connect to the UNIHIKER device. In the de-energized state, connect 'X' to 'P21', 'Y' to 'P22' and 'Z' to 'P23'. When you're done, you can turn on UNIHIKER. X and Y are used for movement and Z for shooting.
Download the ZIP file to your local environment and unzip everything. If this first step was successful, the whole thing should look something like this for you.
# list all files and folders (optional)
$ tree UniShooter/
UniShooter/
|-- img
| |-- background
| | |-- intro.jpg
| | `-- sky.png
| |-- enemy
| | |-- death
| | | |-- 0.png
| | | |-- 1.png
| | | |-- 2.png
| | | |-- 3.png
| | | |-- 4.png
| | | |-- 5.png
| | | |-- 6.png
| | | `-- 7.png
| | |-- idle
| | | |-- 0.png
| | | |-- 1.png
| | | |-- 2.png
| | | |-- 3.png
| | | `-- 4.png
| | |-- jump
| | | `-- 0.png
| | `-- run
| | |-- 0.png
| | |-- 1.png
| | |-- 2.png
| | |-- 3.png
| | |-- 4.png
| | `-- 5.png
| |-- icons
| | |-- bullet.png
| | `-- health_box.png
| |-- player
| | |-- death
| | | |-- 0.png
| | | |-- 1.png
| | | |-- 2.png
| | | |-- 3.png
| | | |-- 4.png
| | | |-- 5.png
| | | |-- 6.png
| | | `-- 7.png
| | |-- idle
| | | |-- 0.png
| | | |-- 1.png
| | | |-- 2.png
| | | |-- 3.png
| | | `-- 4.png
| | |-- jump
| | | `-- 0.png
| | `-- run
| | |-- 0.png
| | |-- 1.png
| | |-- 2.png
| | |-- 3.png
| | |-- 4.png
| | `-- 5.png
| `-- tiles
| |-- 0.png
| |-- 10.png
| |-- 11.png
| |-- 12.png
| |-- 13.png
| |-- 14.png
| |-- 15.png
| |-- 16.png
| |-- 17.png
| |-- 18.png
| |-- 1.png
| |-- 2.png
| |-- 3.png
| |-- 4.png
| |-- 5.png
| |-- 6.png
| |-- 7.png
| |-- 8.png
| `-- 9.png
|-- levels
| `-- level_1.csv
|-- lib
| |-- controller.py
| |-- display.py
| `-- world.py
`-- main.py
The file 'main.py' is the entry point for the game. The 'lib' folder contains the classes for the necessary objects of the game. The 'levels' folder contains *.csv files which contain the levels/worlds (currently only the 1st level). The images used in the game are located in the 'img' folder.
There are various ways to transfer files and folders to the UNIHIKER! You can find these options with a description in the online documentation. Since I prefer SCP, here is an example:
# upload all to UNIHIKER (password: dfrobot)
$ scp -r UniShooter [email protected]:/root/
That's actually it! Via touch screen menu or command line, you can start the game now.
Now develop the game independently! For example, you can add sounds, additional levels and/or features. Here are more examples for UNIHIKER/PyGame: