Skip to content

Boilerplate pygame-ce project for a top-down tiles sheet based RPG game that can run in the browser.

License

Notifications You must be signed in to change notification settings

HubertReX/pygame-ce-web-boilerplate

Repository files navigation

Introduction

This is a template for a game using Pygame-CE that can run on both desktop and browser.

screenshot

You can play an online demo here.

TOC

Features

  • runs on the web browser (itch.io and GitHub Pages) thanks to pygbag
  • implemented finite state machine
  • usage of menus pygame-menu (patched - gfxdraw not working in WEB)
  • mouse support (player control and in menus)
  • Tiled map loading pytmx
  • map live reloading, scrolling, and zooming pyscroll
  • configurable transition between maps (custom properties in Tiled maps)
  • map with layers (walls, markers for start and exits)
  • procedurally generated mazes with randomly places decors
  • semi-transparent panels and text with background (alpha blending)
  • full-screen color filter (alpha blending, e.g.: warm sunny light, dark blue at night)
  • particle system (falling leaves, more to come)
  • postprocessing OpenGL/WebGL shaders (zengl): saturated, black&white, retro CRT monitor
  • game auto pause (if the game window is out of focus)
  • pixel style monospace font
  • a custom mouse cursor
  • animated sprites with shadows and different
  • NPCs states (Idle, Bored, Walk, Run, Jump, Fly)
  • NPCs path finding with different step cost depending on surface type (road speeds up, water slows down)
  • NPCs follow individual lists of waypoints or moving target (e.g. Player)
  • separation of key bindings from actions
  • scene transitions (fade in/out, round shutter)
  • automatic screenshots saving

Ideas for future

Features:

  • list key bindings - ✅ done
  • create global config json with schema - ⏳ WIP
  • add UI (health bar ✅, stats)
  • add particles system ✅ (leafs ✅, wind ✅, rain, footsteps, smoke) - ⏳ WIP
  • add day/night cycle and weather (rain)
  • add fog of war and/or line of sight
  • add light sources (camp fire, torch, houses)
  • add NPC, enemies and animals with movements (add shadows)
  • add movable objects
  • add object destruction
  • add item drop/pickup and inventory system
  • add procedurally generated animations/movements (using Second Order Dynamics) - ⏳ WIP
  • add fighting system - ⏳ WIP
  • add dialog system
  • add merchants
  • add cutscenes
  • add game save/load system
  • add game highscore table
  • add game achievements
  • add music and sfx
  • add better menus
  • add dungeons (generated procedurally) - ✅ done
  • add path finding algorithm - ✅ done
  • make more maps

Bugs:

  • screenshot of menu not working (showing only part of menu)
  • some key events are lost (action is repeated even key is not pressed in menus)
  • continuing game after exiting menu causes loosing player's position on small map (works on grassland though)
  • should new map be a new game state?

Installation

# create venv
python3 -m venv .venv
# activate it
# on Linux/MacOS
source .venv/bin/activate
# on Windows
.venv\Scripts\activate

# install packages
pip install -r requirements.txt

Run

Desktop mode:

cd project
python main.py

Browser mode:

# from top level folder
pygbag --ume_block 0 project

open http://localhost:8000/ in browser

use http://localhost:8000#debug to show Python repl terminal in browser - useful for troubleshooting

Deploying

full instruction here

in short:

pygbag --ume_block 0 --archive project

upload 'build/web.zip' to itch.io or any other hosted site.


To GitHub pages

full instruction here

Contribution

This project is based on Matt Owen's tutorial:

Pygame ARPG Tutorial Series

Ninja Sprite is from the same author:

Monochrome ninja

Cursor by:

Precision icons created by redempticon - Flaticon

About

Boilerplate pygame-ce project for a top-down tiles sheet based RPG game that can run in the browser.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published