GithubHelp home page GithubHelp logo

adamfk / littlejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from killedbyapixel/littlejs

0.0 0.0 0.0 6.92 MB

LittleJS is a fast HTML5 game engine with many features and no dependencies. ๐Ÿš‚ Choo-Choo!

License: MIT License

JavaScript 99.98% Batchfile 0.02%

littlejs's Introduction

LittleJS - The Tiny Fast JavaScript Game Engine

LittleJS Screenshot

NPM Package Build Size NPM Downloads DeepScan Discord

๐Ÿš‚ All aboard!

LittleJS is a fast lightweight open source HTML5 game engine for modern web development. Its small footprint is packed with a comprehensive feature set including hybrid rendering, physics, particles, sound effects, music, and input handling. The code is very clean and well documented with some fun examples to get you started. Choo-Choo!

๐Ÿš€ Join the First Ever LittleJS Game Jam

The LittleJS Game Jam will take place From Nov 11 to Dec 12! Unleash your creativity and develop amazing games using the LittleJS game engine. ๐Ÿ•น๏ธ๐ŸŽฎ Sign up today and get more info about the jam on itch.io!

LittleJS Screenshot

About LittleJS

LittleJS is a small but powerful game engine with many features and no dependencies.

โœจ Graphics

  • Super fast sprite and tile map rendering engine with WebGL
  • Update and render 100,000+ sprites at a solid 60fps
  • Apply Shadertoy compatible shaders for post-processing effects
  • Robust particle effect system and effect design tool

๐Ÿ”Š Audio

  • Positional sound effects with wave files or ZzFX
  • Use ZzFX sound effect generator to play sounds without asset files
  • Music with mp3, ogg, wave, or ZzFXM

๐ŸŽฎ Input

  • Comprehensive input handling for keyboard, mouse, gamepad, and touch
  • On screen touch gamepad designed for mobile devices

๐Ÿ’ฅ Physics

  • Robust arcade physics system with collision handling
  • Very fast collision and raycasting for tile maps

๐Ÿš€ Flexibility

  • Compatible with all modern web browsers and on mobile devices
  • Support for TypeScript and Modules with example projects for both
  • Ideal for size coding competitions like js13kGames, starter project builds to a 7KB zip
  • Builds to an executable with Electron for distribution on Windows, macOS, and Linux
  • Open Source with the MIT license so it can be used for anything you want forever

๐Ÿ› ๏ธ And more...

  • Node.js build system
  • 2D vector math library
  • Debug primitive rendering system
  • Particle effects system and design tool
  • Bitmap font rendering and includes a built in engine font
  • Medal system tracks and displays achievements with Newgrounds integration

How to use LittleJS

To get started download the latest LittleJS package from GitHub or install via npm: npm install littlejsengine

Learn how to make a simple game from scratch with The Breakout Tutorial.

LittleJS Engine Quick Reference Sheet - This cheat sheet can help you get started.

Watch this GitNation talk to hear more about LittleJS works and get some tips on how to use it.

Join our vibrant community on Discord to get help, share your projects, and collaborate with others!

Demos

These examples are for both learning and using as starter projects to create your own games.

Builds

To easily include LittleJS in your game, you can use one of the pre-built js files.

To rebuild the engine you must first run npm install to setup the necessary npm dependencies. Then call npm run build to build the engine.

The starter example project includes a node js file build.js that compresses everything into a tiny zip file using Google Closure, UglifyJS, and ECT Zip.

LittleJS Setup

To start LittleJS, you need to create these 5 functions and pass them to engineInit.

function gameInit()
{
    // called once after the engine starts up
    // setup the game
}

function gameUpdate()
{
    // called every frame at 60 frames per second
    // handle input and update the game state
}

function gameUpdatePost()
{
    // called after physics and objects are updated
    // setup camera and prepare for render
}

function gameRender()
{
    // called before objects are rendered
    // draw any background effects that appear behind objects
}

function gameRenderPost()
{
    // called after objects are rendered
    // draw effects or hud that appear above all objects
}

// Startup LittleJS Engine
engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost);

LittleJS Objects

LittleJS can be used as an object oriented system by extending the base class EngineObject with your own. This lightweight class provides many useful features including physics, collision, parent/child system, and sorted rendering. These objects are added to the global list of objects where they will automatically be updated and rendered until destroyed.

Here is a template you can use to make objects that behave however you want. See the examples for a complete demonstration.

class MyObject extends EngineObject 
{
    constructor(pos, size, tileInfo, angle)
    {
        super(pos, size, tileInfo, angle);
        // setup object
    }

    update()
    {
        // update object physics and position
        super.update(); 
    }

    render()
    {
        // draw object as a sprite
        super.render();
    }
}

Debugging

Debug builds of LittleJS have a special menu that can be opened by pressing the Esc key.

  • Esc: Debug Overlay
  • 1: Debug Physics
  • 2: Debug Particles
  • 3: Debug Gamepads
  • 4: Debug Raycasts
  • 5: Save Screenshot

Games Made With LittleJS

Here are a few of the amazing games people made using LittleJS...

LittleJS Logo

littlejs's People

Contributors

killedbyapixel avatar clementcariou avatar codyebberson avatar lukenickerson avatar jwigert avatar paxperscientiam avatar thatonebro avatar bajuba avatar lopis avatar matthijsgroen avatar pebutler3 avatar someunusualgames avatar moreiramirakulo avatar tzwel 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.