The goal of this is to provide an example of what to do (or don't as you see fit) in creating a collection of standalone games using state and Observer patterns. The idea sprang up from the discontinuation of Brain Station and thus the framework is aimed at fulfilling this goal, but it should be flexible enough to allow one to make whatever they please.
In a manner of speaking, yes. There should not be anymore breaking changes to the code. Though the contents of files may alter, I will try and preserve any old functions in order to maintain compatibility. Should a change occur, I will do my best to provide ample warnings before removing old code
You need at least Python 3.10. After that, the steps are as expected, that is:
$git clone https://github.com/Amerikranian/Arcade
$cd Arcade
$pip install -r requirements.txt
If you are planning to contribute, then change the last line to install requirements-dev.txt
, like so
$pip install -r requirements-dev.txt
We use Nuitka for compilation. As of now, only windows is supported, though other operating systems shouldn't be much of a hastle. Execute build_windows.bat
from the main repository as you would any batch script and you should have a working distribution with no necessity for copying anything by hand
- Adding some semblance of word complexity, perhaps based on Scrabble rules
- Adding graceful cleanup upon application errors
- Figuring out a way to unlock games (A shop? Achievements? Something that functions as a mix of the two?)
- Writing a CLI tool that can modify game JSON
- Actually writing games
Game additions occur in three steps
- Adding game definitions to info.json within data/games directory
- Creating the respective file within the games directory. Your game's class name must match the created JSON key! Your class must also take exactly two arguments, game variation and difficulty
- Importing the game into
__init__.py
of the games directory. Said import must result in the actual class being accessible within the games module.
Since we currently lack the ability to unlock games, below is the simplest definition you could have for your game. Said definition must be pasted within info.json under games key.
"SampleGame": {
"unlocked_by_default": true
}
Create a file within the games directory with any desired name and populate it like so:
from .base_game import Game
class SampleGame(Game):
def __init__(self, variation, difficulty):
super().__init__(variation, difficulty)
# Your code below
Keep in mind that you have access to the entirety of the methods within the Screen class. If you wish to use the ObservableGame class, the procedure is almost identical
from .observable_game import ObservableGame, GameObserver
class SampleGame(ObservableGame):
def __init__(self, variation, difficulty):
super().__init__(variation, difficulty)
self.add_observer(YourObserver())
class YourObserver(GameObserver):
def __init__(self):
super().__init__()
# More code below
See GameObserver class for more details
modify __init__.py
in the games directory by adding this line
from .your_sample_game_filename import SampleGame
Regardless of what method you chose (working with the game class directly or using observers) you should be able to play your game now. Look in constants.py to see what kind of data you can alter about the SampleGame, and check out Hangman for a longer observer-oriented example
- Word Builder
- Word Search
- And probably some more as I work on this
Sure. Pull requests and suggestions are welcomed. Discussion is encouraged. Like I said, half of this is me figuring it out. I would appreciate opening issues before opening pull requests. Said requests must also be properly formatted (use black).
Typing will be added... eventually. Bare with me, please.
If there is enough interest I will move them up in priority, but due to having very limited time and no idea if anyone is interested in this they are very sparse.