Tait Hoyem
b392262824
|
2 years ago | |
---|---|---|
.. | ||
migrations | 2 years ago | |
static/games | 2 years ago | |
templates/games | 2 years ago | |
README.md | 2 years ago | |
__init__.py | 2 years ago | |
admin.py | 2 years ago | |
apps.py | 2 years ago | |
consumers.py | 2 years ago | |
models.py | 2 years ago | |
tests.py | 2 years ago | |
urls.py | 2 years ago | |
views.py | 2 years ago |
README.md
New games
Here is how to create a new game.
Step 1
Before making any changes, try to understand the structure of /skel/
.
Here is what you need to know in simple terms; check out each individual file for more information on how each component works:
- URLs are defined in
skel/urls.py
, this includes HTTP urls as well as WebSocket connection points.
- HTTP responses return from
skel/views.py
. - WebSocket requests return from
skel/consumers.py
.
- WebSockets are connected to from the client in
skel/static/games/skel.js
. - Models are defined in
skel/models.py
. None are included by default, but check out the Django documentation for further information on how these work. - The HTML template used for the game is defined in
skel/templates/games/skel.html
.
Step 2
Let's create a brand new game, disconnected from our "skel" fake game.
For the purposes of this guide xyz
will be the name of our new game.
To create a new game, run the command python manage.py newgame xyz
a new game called xyz
will now be created; change two things to show your game in action:
- Add
xyz
to theINSTALLED_APPS
list inlamegames/settings.py
. - Add
xyz
to theGAMES
list inlamegames/settings.py
.
For 2, check the syntax of how other apps/games are added for an idea of how to do so.
Step 3
Have fun! Look at django guides as well as examples we have created:
rps/
is for Rock-Paper-Scissorsminesweeper/
is for Minesweeperchat/
is for a simple, open-air chat room defined by a room id.
Check how these examples work for more information, and look into how Django, Django channels and Django models work to create more advanced games. Some games (like rock-paper-scissors) will not need such advanced features as models, but they do require knowledge of channels. Others (like Minesweeper) require little knowledge of channels due to their single-player nature, but do require some more models so a game may be saved for a user when they come back.
Step 4
Be creative!
I want to see the following games eventually make it into lamegames:
- Malcana
- (simple) Chess
- Card games: blackjack, poker and "Uno"-like games
- Chinese Chess (where the knight moves 2+2 instead of 2+1)
Make it happen, and be the next contributer!