Code Monkey home page Code Monkey logo

pygame-ce-web-boilerplate's Introduction

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

pygame-ce-web-boilerplate's People

Contributors

hubertrex avatar gitbutler-client avatar

Stargazers

XORandom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.