-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Increasing access
This new example, Survive the Horde, helps make p5.js more accessible to learners who want to understand how to create small games and interactive projects.
It demonstrates several key p5.js concepts in a fun and engaging way:
- Using keyboard input for player control
- Spawning and animating multiple enemies
- Implementing collision detection between objects
- Adding a score and game-over system
- Using p5.sound for shooting and effects
By including this example in the official p5.js examples, beginners can learn how to combine rendering, events, and logic to build interactive gameplay with real-time feedback.
It provides a hands-on reference for creative coding and game logic using p5.js.
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
Feature request details
Summary
Add a new example game named "Survive the Horde" under the examples/javascript_game/ directory.
Description
This example demonstrates how to create a simple 2D survival game using p5.js, showing how to integrate animation, input handling, and interaction in one project.
Players can move their character, shoot at incoming enemies, and survive as long as possible while avoiding collisions. The example also includes scoring, restarting, and game-over mechanics.
Educational Purpose
This game helps beginners understand:
- How to use the draw loop for continuous animation
- How to manage user input with the keyboard
- How to detect and respond to collisions
- How to use arrays or objects to manage multiple entities (like enemies and bullets)
- How to use basic game logic in p5.js
Implementation Details
- Folder:
examples/javascript_game/ - Files:
index.html– game entry pointgame.js– main logic and drawing codegame.css– styling and layoutREADME.md– instructions and gameplay notes
Related Pull Request
PR: #8248