An Odd Way to Implement Simple Android Games in Python 3

by Trevor Lee in Design > Software

63 Views, 1 Favorites, 0 Comments

An Odd Way to Implement Simple Android Games in Python 3

an-odd-way-1600x1200.png

Unlike normal way of implementing games with game engines like Godot, the odd way introduced here to implement simple Android games in Python 3 needs some little helps from DumbDisplay Python library as well as DumbDisplay Android app

  1. The DumbDisplay Python/MicroPython library is used to implement the game logic in Python 3, as a simple personal game server
  2. The DumbDisplay Android app is used to render the game graphical components, as well to get input from the users. Note that no separate work from you on this part -- the logics are driven by the Python game server.
  3. The connection protocol between the game server and the DumbDisplay Android app is TCP/IP over WIFI
  4. No, DumbDisplay is not a game engine

Examples

dd-tetris-one-block.jpg
dd-tetris-two-block.jpg
dd-tetris-classic.jpg

For example, a simple "Tetris One Block" implementation bundled with the library as one of the examples. Please note that this "Tetris One Block" example was adapted from TETRIS ONE BLOCK/tetris_one_block.py of the GitHub Repository Python-Games

As mentioned, the example game "Tetris One Block" is bundled with the DumbDisplay Python/MicroPython Library, which you can install in your Python 3 environment like

pip install git+https://github.com/trevorwslee/MicroPython-DumbDisplay

If during installation you see error like ModuleNotFoundError: No module named 'setuptools.config.expand'; 'setuptools.config' is not a package , please try to upgrade your setuptools package first like

pip install --upgrade setuptools

then try installing again.

Assuming DumbDisplay Python/MicroPython library is installed, you can run the example game "Tetris One Block" like

python -m dumbdisplay example.tetris_one_block

When the example game [server] starts, the console should show output like

*** Running TETRIS ONE BLOCK ***
connecting socket ... listing on 192.168.0.46:10201 ...

Then, go ahead to your Android mobile phone, bring up the DumbDisplay Android app and connect it with the game server, with the IP shown in your console output as above.

With your DumbDisplay Android app connected to the game server, whatever game it is running, can be played with the DumbDisplay Android app as the UI for the game.

Another Example -- Space Shooting

dd-space-shooting.jpg
dd-space-shooting-landscape.jpg

Another more exciting example game adapted from Python-Games is the "Space Shooting" game. Like the Tetris games, the "Space Shooting" game can also be played with the DumbDisplay Android app as the UI, with a user-friendly virtual joystick to control the movement of the space-fighter.

You can start the "Space Shooting" game serve like

python -m dumbdisplay example.space_shooting

If you prefer to play the game with no sound, you can disable sound by providing the --no-sound command-line argument like

python -m dumbdisplay example.space_shooting --no-sound


Enjoy!

dd-sliding-puzzle.jpg

Can DumbDisplay be used for other purposes, like for the purpose of playing with simple AI concepts? Arr ... you might be interested in what I described in my past post -- PyTorch Introductory Experiments

BTW, in the above-mentioned post, a simple Python implementation of the old-timer game -- Sliding Puzzle -- can be run like

python -m dumbdisplay example.sliding_puzzle

Moreover, the game can be run with a little "AI assistant", as described in PyTorch Introductory Experiments


Enjoy!


Peace be with you! May God bless you! Jesus loves you! Amazing Grace!