Move to config folder

This significantly makes it more manageable to add GB files inside a Docker container.
main
Bram van den Heuvel 3 months ago
parent 29f0a84cb7
commit ef765c4c87
  1. 46
      README.md
  2. 6
      config/config-sample.yml
  3. 3
      main.py

@ -1,3 +1,45 @@
# pyboy-to-matrix
# Matrix-gameboy
Bridge between GameBoy emulator and Matrix, written in Python.
Matrix-gameboy is a GameBoy emulator that connects to a
[Matrix](https://matrix.org) room and allows users to control the game from
within the room.
This repository supports the following:
- ✅ Emulate GameBoy games
- ✅ Send control commands to the emulator
- ✅ Get a screenshot posted in the room
- ❌ Emulate GameBoy Advance (GBA) games
## How to run
You can run
```sh
pip install -r requirements.txt && python main.py
```
or using Docker, you can either build the repository yourself or run
```sh
docker run --rm --name "Matrix_Plays_GameBoy" \
-v $(pwd)/config:/usr/src/app/config \
noordstar/matrix-gameboy
```
---
## Why it was made
It was inspired by
[matrix-plays-pokemon](https://github.com/jaller94/matrix-plays-pokemon), which
is a JavaScript implementation that supports both GB and GBA using
[mGBA](https://mgba.io/).
Upon debugging, there were several problems that couldn't be solved, so I
decided to write up an equally short program doing the same thing, but in
Python.
In short, this implementation is a wrapper of the
[PyBoy](https://pypi.org/project/pyboy/) and
[matrix-nio](https://pypi.org/project/matrix-nio/) libraries.

@ -4,20 +4,20 @@ files:
# Filename of the game that you're going to load.
game_save: './game.gb'
# If running in a Docker container, you should use something like
# game_save: '/config/game.gb'
# game_save: '/usr/src/app/config/game.gb'
# Filename of the latest state. This is the game state when a user last gave
# an input. If the program unexpectedly closes, the game will continue from
# this state.
latest_state: './latest.state'
# If running in a Docker container, you should use something like
# latest_state: '/config/latest.state'
# latest_state: '/usr/src/app/config/latest.state'
# Location to temporarily store the screenshots that are sent to Matrix.
# The file permanently shows the last taken screenshot.
screenshot: './screenshot.png'
# If running in a Docker container, you should use something like
# screenshot: '/config/screenshot.png'
# screenshot: '/usr/src/app/config/screenshot.png'
# Config that connects the program to Matrix
matrix:

@ -12,7 +12,7 @@ import yaml
# --------------------------
# Constant definitions
with open('config.yml', 'r', encoding='utf-8') as open_file:
with open('config/config.yml', 'r', encoding='utf-8') as open_file:
config = yaml.safe_load(open_file)
GAME_FILE_NAME = config['files']['game_save']
@ -219,6 +219,7 @@ async def message_callback(room : MatrixRoom, event : RoomMessageText) -> None:
async def setup_matrix_client():
client.add_event_callback(message_callback, RoomMessageText)
await client.join(GAME_ROOM)
await client.sync_forever(timeout=30000)
# --------------------------

Loading…
Cancel
Save