Skip to content

zakariya-ali/p5-JavaScript-Platformer

Repository files navigation

p5.js JavaScript Platformer

An engaging 2D platformer game built with the p5.js framework. Guide your Adventurer through skies, forests, canyons, and castles. Collect coins, avoid enemies, and reach the castle to complete each level.

Features

  • Smooth side-scrolling platformer with physics
  • Multiple environmental elements: mountains, clouds, trees, canyons, raining/sunny weather
  • Interactive platforms and collectible coins
  • Enemy patrols with collision detection
  • Flagpole and castle end-level mechanics
  • Sound effects and background music
  • Lives and score tracking

Installation

  1. Clone or download this repository.
  2. Ensure you have a modern browser (Chrome, Firefox, Edge).
  3. No additional server is required; you can open the game locally.

Running the Game

  1. Open index.html (or sketch.html) in your browser.
  2. The game will start in the intro screen. Press Enter or click to begin.

Controls

  • Left Arrow: Move Adventurer left
  • Right Arrow: Move Adventurer right
  • Up Arrow / Space: Jump

Game Mechanics

  • Collect all coins scattered in each level to increase your score.
  • Avoid or defeat patrolling enemies; collisions cost a life.
  • Falling into a canyon or running out of lives will restart the level.
  • Reach the castle or flagpole to complete the level and advance.

Assets

All game assets (images, sounds, fonts) are located in the assets/ folder:

  • Images: Platforms, background, character sprites, enemies, UI icons
  • Audio: Sound effects (jump, collect, lose life), background music
  • Fonts: Custom TTF fonts for UI

Project Structure

├── assets/          # Images, sounds, fonts
├── sketch.js        # Main game logic and rendering
├── index.html       # HTML wrapper for p5.js sketch
└── README.md        # Project overview and instructions

Customization

  • Modify environmental arrays (clouds, mountains, trees, canyons, platforms) in sketch.js to change layout.
  • Add or replace character/enemy sprites in assets/ and adjust references in preload().
  • Tweak physics parameters (gravity, jump height, enemy speed) for a different feel.

Contribution

Contributions, bug reports, and feature suggestions are welcome. Feel free to open an issue or submit a pull request.

License

This project is released under the MIT License.

About

An engaging 2D platformer game built with the p5.js framework.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published