Welcome to the poki-pixijs-template! This is a quick and dirty template to help developers swiftly build hypercasual PixiJS games.
The idea behind this template is to support short-term projects that span a couple of months. The aim is to maintain a high project velocity. You should be able to keep everything in mind without heavily structuring your code. Think of it as "move fast and maybe break things", but with fun.
- Progressive Loading: The game menu loads first, making initial user interaction swift.
- Optimized Assets: The template supports various image and audio formats, ensuring the smallest asset size.
- Image Spritesheet: The template leverages TexturePacker to combine all images into a spritesheet.
- HTML UI: By default, the game uses HTML for the menu and in-game UI. However, PixiJS can also be utilized for this.
- Audio Integration: howler.js is used for game sounds and a native Audio element for music streaming.
The example game from this template can be found here: https://inspector.poki.dev/?game=external-erikdubbelboer.github.io%252Fpoki-pixijs-template%252F
Here's a brief overview of the project's file structure:
- Configuration:
.babelrc
,.browserslistrc
,.eslint*
,.prettier*
,.stylelintrc.json
,rollup.config.mjs
,package.json
- Art Assets: Inside the
images/
directory. - Web Assets: Housed in the
public/
directory. - Game Logic & Modules: All
.js
files within thesrc/
directory. - Helpers:
updateimages.sh
,updatesouds.sh
- Dependencies:
yarn.lock
Before diving in, let's familiarize ourselves with the main files and their responsibilities:
-
menu.js:
- Purpose: Manages the game's HTML menu functionality.
- Execution: Loaded before the game itself. When
startGameMenu()
is invoked, it checks if the game has loaded. If it's loaded, it directly callsstartGame()
. If not, it shows the loading progress before eventually launchingstartGame()
.
-
index.js:
- Purpose: Serves as the primary gateway to the game.
- Execution: Initiates a
Loader
(sourced fromloader.js
) and subsequently generates aGame
object (fromgame.js
) to kick off the game.
-
loader.js:
- Purpose: Responsible for loading visuals and other resources.
- Execution: Constructs the
PIXI.Application
object which is consistently employed by allGame
objects.
-
sounds.js:
- Purpose: Handles sound resources, from loading to playback.
- Execution: Once all primary loading is finished, it silently loads sound assets in the background, ensuring that gameplay isn't held up waiting for sound resources.
-
game.js:
- Purpose: Manages the central game mechanics, from game state to event handling.
- Execution: Contains the primary game loop, reacting to user input and updating game states.
-
Clone this repository:
git clone git@github.com:erikdubbelboer/poki-pixijs-template.git cd poki-pixijs-topdown-template
-
Install dependencies:
yarn install
-
Start the development server:
yarn watch
This will start a local server at
http://localhost:8080/
to serve thepublic/
directory and watch for changes in thesrc/
directory.You can now test your game by opening the Poki Inspector or localhost in your browser.
-
For production, build the game:
yarn build
This will produce a
dist
directory that can be uploaded to the Poki Inspector or Poki for Developers.
Feel free to dive in! Open an issue, submit a PR, or provide suggestions to improve the template.
Please check credits.txt
for the example game assets' credits. The codebase itself is under the MIT License.
Happy game building! Hope this template helps streamline your development process and lets you focus on making games fun.