Compare commits
11 Commits
b3bd1e0c3a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c99027912 | |||
| 5a60777a73 | |||
| 39ec99fd1f | |||
| e87c977c6f | |||
| c96b3b803d | |||
| fe5d3a3de4 | |||
| 7b502f27ff | |||
| 593488f73c | |||
| 43768f4fed | |||
| 856e0b46a9 | |||
| 744df971fc |
179
.gitignore
vendored
Normal file
179
.gitignore
vendored
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
# ---> Python
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
.pybuilder/
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# .python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# UV
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
#uv.lock
|
||||||
|
|
||||||
|
# poetry
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
|
# commonly ignored for libraries.
|
||||||
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
|
#poetry.lock
|
||||||
|
|
||||||
|
# pdm
|
||||||
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
|
#pdm.lock
|
||||||
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
|
# in version control.
|
||||||
|
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||||
|
.pdm.toml
|
||||||
|
.pdm-python
|
||||||
|
.pdm-build/
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
# pytype static type analyzer
|
||||||
|
.pytype/
|
||||||
|
|
||||||
|
# Cython debug symbols
|
||||||
|
cython_debug/
|
||||||
|
|
||||||
|
# PyCharm
|
||||||
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
|
#.idea/
|
||||||
|
|
||||||
|
# Ruff stuff:
|
||||||
|
.ruff_cache/
|
||||||
|
|
||||||
|
# PyPI configuration file
|
||||||
|
.pypirc
|
||||||
|
|
||||||
|
# ---> Other
|
||||||
|
/test.py
|
||||||
|
/.vscode/
|
||||||
17
.vscode/launch.json
vendored
Normal file
17
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python Debugger",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "launch",
|
||||||
|
"python": "../PainJamLauncher/.venv/Scripts/python.exe",
|
||||||
|
"program": "../PainJamLauncher/__main__.py",
|
||||||
|
"args": ["CHANGE ME TO YOUR GAME ID"],
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
27
README.md
27
README.md
@ -1,19 +1,28 @@
|
|||||||
# BaseGame
|
# BaseGame
|
||||||
|
|
||||||
A template that all games should be based on.
|
The boilerplate code that all games are based on.
|
||||||
|
|
||||||
The idea is this will make it easier to integrate with [The Pain Jam Launcher](https://git.personal.imadumbass.dog/PainJam/PainJamLauncher).
|
This makes it possible for the [The Pain Jam Launcher](https://git.personal.imadumbass.dog/PainJam/PainJamLauncher) to run your game properly.
|
||||||
|
|
||||||
I have no idea how templates work so we just kinda balling with this one, team.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This template contains the following files:
|
This template contains the following files:
|
||||||
|
- `game.py`: Your actual game code.
|
||||||
|
- `game.toml`: Stores information about your game.
|
||||||
|
- `requirements.txt`: Base requirements each game needs.
|
||||||
|
- `.vscode/launch.json`: An example `launch.json` for use in VSCode. Change the arguments to use your game ID.
|
||||||
|
|
||||||
`__init__.py`: Your actual game code.
|
Make sure to edit / delete:
|
||||||
|
- `README.md`: To contain information about your game, rather than this.
|
||||||
`__main__.py`: The standalone launcher. This should not be changed as this file is not ran when using an external launcher.
|
- `TODO.md`: To contain your own TODOs.
|
||||||
|
|
||||||
`game.toml`: Stores information about your game
|
|
||||||
|
|
||||||
For more information about how to use each of these files, check the documentation within each file.
|
For more information about how to use each of these files, check the documentation within each file.
|
||||||
|
|
||||||
|
In order to develop a game, you must base your game off this file, and require the following directory layout:
|
||||||
|
- `YourGame` (Based on [BaseGame](https://git.personal.imadumbass.dog/PainJam/BaseGame))
|
||||||
|
- [`GameUtils`](https://git.personal.imadumbass.dog/PainJam/GameUtils)
|
||||||
|
- [`NoPELib`](https://git.personal.imadumbass.dog/Brosef/NoPELib)
|
||||||
|
- [`PDOLib`](https://git.personal.imadumbass.dog/Brosef/PDOLib)
|
||||||
|
- [`PainJamLauncher`](https://git.personal.imadumbass.dog/PainJam/PainJamLauncher)
|
||||||
|
|
||||||
|
Once you have all of those, run `setup.py` located in the `PainJamLauncher`. This will automatically configure a virtual environment and install all dependancies.
|
||||||
5
TODO.md
Normal file
5
TODO.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# TODO
|
||||||
|
|
||||||
|
- Add optional Discord rich presence
|
||||||
|
- Add base NoPE-lib integration
|
||||||
|
- Add base PDO integration
|
||||||
58
__main__.py
58
__main__.py
@ -1,58 +0,0 @@
|
|||||||
# Import the game code
|
|
||||||
import __init__
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import tomllib
|
|
||||||
import pathlib
|
|
||||||
import pygame
|
|
||||||
import os
|
|
||||||
|
|
||||||
# Store the current working directory
|
|
||||||
# This is used to revert the cd change
|
|
||||||
originalCWD = os.getcwd()
|
|
||||||
|
|
||||||
# Get the path of the game
|
|
||||||
basePath = pathlib.Path(__file__).parent.resolve()
|
|
||||||
|
|
||||||
# Set the current working directory
|
|
||||||
# to the base path of the game
|
|
||||||
os.chdir(basePath)
|
|
||||||
|
|
||||||
# Load the game.toml data
|
|
||||||
with open('game.toml', 'r') as f:
|
|
||||||
gameData = tomllib.loads(f.read())
|
|
||||||
|
|
||||||
# Parse command line arguments
|
|
||||||
parser = argparse.ArgumentParser(prog=gameData['name'])
|
|
||||||
parser.add_argument('-sw', '--width', type=int, default=1280)
|
|
||||||
parser.add_argument('-sh', '--height', type=int, default=720)
|
|
||||||
parser.add_argument('-f', '--fullscreen', action='store_true')
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Initialise screen
|
|
||||||
flags = 0
|
|
||||||
if args.fullscreen: flags |= pygame.FULLSCREEN
|
|
||||||
screen = pygame.display.set_mode((args.width, args.height), flags)
|
|
||||||
pygame.display.set_caption(gameData['name'])
|
|
||||||
|
|
||||||
# Initialise game
|
|
||||||
game = __init__.Game(screen, screen.size)
|
|
||||||
|
|
||||||
# Set to False when the game should exit
|
|
||||||
run = True
|
|
||||||
|
|
||||||
while run:
|
|
||||||
# Event loop
|
|
||||||
for event in pygame.event.get():
|
|
||||||
if event.type == pygame.QUIT:
|
|
||||||
run = False
|
|
||||||
|
|
||||||
game.onEvent(event)
|
|
||||||
|
|
||||||
# Draw loop
|
|
||||||
game.draw()
|
|
||||||
|
|
||||||
# Clean up
|
|
||||||
os.chdir(originalCWD)
|
|
||||||
game.close()
|
|
||||||
pygame.quit()
|
|
||||||
@ -4,18 +4,18 @@ import gameUtils
|
|||||||
import NoPELib
|
import NoPELib
|
||||||
|
|
||||||
class Game(gameUtils.Game):
|
class Game(gameUtils.Game):
|
||||||
def __init__(self, surface, size):
|
def __init__(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Ran when the game starts.
|
Ran when the game starts.
|
||||||
|
|
||||||
Args:
|
You have access to the following variables:
|
||||||
surface (pygame.Surface): The surface you draw to.
|
self.surf (pygame.Surface): This is the surface you draw onto.
|
||||||
size (list[int, int]): The size of the surface.
|
self.pm (NoPELib.PlayerManager): This is where your players are stored.
|
||||||
|
self.cfg (dict): Everything from the `game.toml` file. You can access it like this: self.details['title']
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pygame.init()
|
# Don't remove this. It does important things. :3
|
||||||
self.surface = surface
|
super().__init__(*args, **kwargs)
|
||||||
self.size = size
|
|
||||||
|
|
||||||
def onEvent(self, event):
|
def onEvent(self, event):
|
||||||
"""
|
"""
|
||||||
@ -31,7 +31,9 @@ class Game(gameUtils.Game):
|
|||||||
Ran once per frame, put your drawing code and any
|
Ran once per frame, put your drawing code and any
|
||||||
game logic that should be ran once per frame in here.
|
game logic that should be ran once per frame in here.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
# Don't remove this. It does important things. :3
|
||||||
|
super().update()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
Reference in New Issue
Block a user