Coder Social home page Coder Social logo

zerodayarcade / html5_platformer Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 2.91 MB

Building a 2D side-scrolling platform game in HTML5 from scratch.

Home Page: https://zerodayarcade.com/demos/platformer

License: MIT License

HTML 7.77% CSS 0.82% JavaScript 91.41%
2d 2d-platformer-game browser-game built-from-scratch html html-canvas html5 javascript no-engine opengameart platformer vanilla-javascript javascript-gaming

html5_platformer's Introduction

Building an HTML5 Platformer from Scratch

This is a simple example of building a 2D side-scrolling platform game in HTML5 from scratch. No engine, frameworks or third-party libraries are used, just vanilla javascript.

pf-ss2


It could use a bit of performance optimization and variable consolidation, but provides an example of the features you see in many 2D platformers:

  • Sprite Animation
  • Parallax Scrolling
  • Audio / Music
  • Collectable Items
  • Title / Menu Screens
  • Collision Detection
  • Controls / Input
  • Tilemap / Easy Level Creation

This demo contains one small level but illustrates the concepts above. The way it is written makes it easy to add and edit levels using 2D level arrays.

Controls

  • A: Run/Move Left
  • D: Run/Move Right
  • W: Jump / Hold to Hover if Wing Amulet has been collected
  • S: Crouch
  • K: Attack

There are two collectable items in the demo: (1) The Wing Amulet and (2) The Golden Cross. The Wing Amulet will let you hover/fly by holding W once you collect it, and the Golden Cross gives you 10,000 points. I may build out this game at some point in the future into a full game, but for now it serves as an example for anyone interested in building an HTML5 platformer without a pre-made engine.

Running Locally

In most cases you can just download the repo and double-click the index.html file. Note that if you add in features that load assets in the javascript code (rather than the HTML), you may need to instead serve the game locally:

You can serve the game locally by cloning the project and running a local server:

Clone repo:

git clone https://github.com/ZeroDayArcade/HTML5_Platformer.git

cd into project directory:

cd HTML5_Platformer

Run server with python:

python -m http.server 8080

Then navigate to localhost:8080 in your browser.

pf-ss3


Game art

The game art used in this demo was created by Luis Zuno (@ansimuz) and other wonderful contributors to opengameart.org

Hero Sprite: opengameart.org/content/gothicvania-cemetery-pack
Backgrounds: opengameart.org/content/mountain-at-dusk-background
Tiles: opengameart.org/content/dungeon-crawl-32x32-tiles

hero-run hero-idle hero-attack

Tileset
parallax-mountain-mountains

Music by Joth (@Joth_Music)
opengameart.org/content/cyberpunk-moonlight-sonata

html5_platformer's People

Contributors

zerodayarcade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

benderofpixels

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.