AI_project / data /littlejs_docs.csv
Eoin McGrath
initial commit
257dcc1
title,text,url
Home,"LittleJS - The Tiny Fast JavaScript Game Engine🚂 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 JamThe 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!Demo | Docs | Trailer | Discord | Tutorial | Quick ReferenceAbout LittleJSLittleJS is a small but powerful game engine with many features and no dependencies.✨ GraphicsSuper fast sprite and tile map rendering engine with WebGLUpdate and render 100,000+ sprites at a solid 60fpsApply Shadertoy compatible shaders for post-processing effectsRobust particle effect system and effect design tool🔊 AudioPositional sound effects with wave files or ZzFXUse ZzFX sound effect generator to play sounds without asset filesMusic with mp3, ogg, wave, or ZzFXM🎮 InputComprehensive input handling for keyboard, mouse, gamepad, and touchOn screen touch gamepad designed for mobile devices💥 PhysicsRobust arcade physics system with collision handlingVery fast collision and raycasting for tile mapsFull Box2d support using super fast wasm build of box2d.js🚀 FlexibilityCompatible with all modern web browsers and on mobile devicesSupport for TypeScript and Modules with example projects for bothIdeal for size coding competitions like js13kGames, starter project builds to a 7KB zipBuilds to an executable with Electron for distribution on Windows, macOS, and LinuxOpen Source with the MIT license so it can be used for anything you want forever🛠️ And more...Node.js build system2D vector math libraryDebug primitive rendering systemParticle effects system and design toolBitmap font rendering and includes a built in engine fontMedal system tracks and displays achievements with Newgrounds integrationHow to use LittleJSTo get started download the latest LittleJS package from GitHub or install via npm: npm install littlejsengineYou will need to run a local web server to run LittleJS games!This is because web browsers just have protection from loading local files. You may see a console error like ""The image element contains cross-origin data."" Don't panic, it's easy to fix! If you are using Visual Studio Code there is a Live Preview Extension that will handle this for you automatically. Another option is to setup a simple local web server like http-server via npm.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!ExamplesThese demos are for both learning and using as starter projects to create your own games.Starter Project - Clean example with only a few things to get you startedBreakout - Block breaking game with post-processing effectsPuzzle Game - Match 3 puzzle game with HD rendering and high score trackingPlatformer - Platformer/shooter with level data from Tiled EditorBox2D Demo - Box2D plugin demonstration and testbedStress Test - Max sprite/object test and music system demoParticle System Designer - Particle system editor and visualizerBuildsTo easily include LittleJS in your game, you can use one of the pre-built js files.littlejs.js - The full game engine with debug mode availablelittlejs.release.js - The engine optimized for release buildslittlejs.min.js - The engine in release mode and minifiedlittlejs.esm.js - The engine exported as a module with debug mode availablelittlejs.esm.min.js - The engine exported as a minified module in release modeTo 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 SetupTo 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 ObjectsLittleJS 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();
}
}
DebuggingDebug builds of LittleJS have a special menu that can be opened by pressing the Esc key.Esc: Debug Overlay1: Debug Physics2: Debug Particles3: Debug Gamepads4: Debug Raycasts5: Save ScreenshotGames Made With LittleJSHere are a few of the amazing games people made using LittleJS...Space Huggers - Original js13k game with source code by KilledByAPixelUndergrowth - An interactive music videogame for the band Squid by KilledByAPixelIsletopia - Relaxing strategy game of greenifying barren islands by Gamex StudioDead Again - Top down survial horror by sanojian & repsejHel's Trial - Turn based RPG by Sebastian DornBit Butcher - Survival crafting game by Deathray GamesNecrotic Commander - Tower defense game by Daniel JefferyBoxing up Bamboo - Challenging puzzle game by Patrick TraynorSamurai Sam - Fruit Ninja inspired rhythm game by John Edvardbrrr! - Base defense and shooting game by SnowfrogWands of Triskaidekai - Platformer with experimental gameplay by gregwoodsfrontierData Warrior: 13kb limit - Vampire Survivors-like game by rndDThe Way of the Dodo - Single button platformer by repsejWendol Village - Warcraft-like RTS game by sanojianUnblock - Retro style space shooter by Isaac Benitez",https://killedbyapixel.github.io/LittleJS/docs/
Class: Color,"ColorColor object (red, green, blue, alpha) with some helpful functionsConstructornew Color(ropt, gopt, bopt, aopt)Create a color with the rgba components passed in, white by defaultParameters:NameTypeAttributesDefaultDescriptionrNumber<optional>1redgNumber<optional>1greenbNumber<optional>1blueaNumber<optional>1alphaSourceengineUtilities.js, line 594Examplelet a = new Color; // white let b = new Color(1, 0, 0); // red let c = new Color(0, 0, 0, 0); // transparent black let d = rgb(0, 0, 1); // blue using rgb color let e = hsl(.3, 1, .5); // green using hsl colorMembersaPropertiesTypeDescriptionNumberAlphaSourceengineUtilities.js, line 610bPropertiesTypeDescriptionNumberBlueSourceengineUtilities.js, line 608gPropertiesTypeDescriptionNumberGreenSourceengineUtilities.js, line 606rPropertiesTypeDescriptionNumberRedSourceengineUtilities.js, line 604MethodsHSLA() → {Array}Returns this color expressed in hsla formatSourceengineUtilities.js, line 717Returns:Type: Arrayadd(c) → {Color}Returns a copy of this color plus the color passed inParameters:NameTypeDescriptioncColorother colorSourceengineUtilities.js, line 637Returns:Type: Colorclamp() → {Color}Returns a copy of this color clamped to the valid range between 0 and 1SourceengineUtilities.js, line 679Returns:Type: Colorcopy() → {Color}Returns a new color that is a copy of thisSourceengineUtilities.js, line 632Returns:Type: Colordivide(c) → {Color}Returns a copy of this color divided by the color passed inParameters:NameTypeDescriptioncColorother colorSourceengineUtilities.js, line 664Returns:Type: ColorisValid() → {Boolean}Checks if this is a valid colorSourceengineUtilities.js, line 808Returns:Type: Booleanlerp(c, percent) → {Color}Returns a new color that is p percent between this and the color passed inParameters:NameTypeDescriptioncColorother colorpercentNumberSourceengineUtilities.js, line 685Returns:Type: Colormultiply(c) → {Color}Returns a copy of this color times the color passed inParameters:NameTypeDescriptioncColorother colorSourceengineUtilities.js, line 655Returns:Type: Colormutate(amountopt, alphaAmountopt) → {Color}Returns a new color that has each component randomly adjustedParameters:NameTypeAttributesDefaultDescriptionamountNumber<optional>0.05alphaAmountNumber<optional>0SourceengineUtilities.js, line 746Returns:Type: ColorrgbaInt() → {Number}Returns this color expressed as 32 bit RGBA valueSourceengineUtilities.js, line 797Returns:Type: Numberscale(scale, alphaScaleopt) → {Color}Returns a copy of this color scaled by the value passed in, alpha can be scaled separatelyParameters:NameTypeAttributesDefaultDescriptionscaleNumberalphaScaleNumber<optional>scaleSourceengineUtilities.js, line 674Returns:Type: Colorset(ropt, gopt, bopt, aopt) → {Color}Sets values of this color and returns selfParameters:NameTypeAttributesDefaultDescriptionrNumber<optional>1redgNumber<optional>1greenbNumber<optional>1blueaNumber<optional>1alphaSourceengineUtilities.js, line 620Returns:Type: ColorsetHSLA(hopt, sopt, lopt, aopt) → {Color}Sets this color given a hue, saturation, lightness, and alphaParameters:NameTypeAttributesDefaultDescriptionhNumber<optional>0huesNumber<optional>0saturationlNumber<optional>1lightnessaNumber<optional>1alphaSourceengineUtilities.js, line 697Returns:Type: ColorsetHex(hex) → {Color}Set this color from a hex codeParameters:NameTypeDescriptionhexStringhtml hex codeSourceengineUtilities.js, line 769Returns:Type: Colorsubtract(c) → {Color}Returns a copy of this color minus the color passed inParameters:NameTypeDescriptioncColorother colorSourceengineUtilities.js, line 646Returns:Type: ColortoString(useAlphaopt) → {String}Returns this color expressed as a hex color codeParameters:NameTypeAttributesDefaultDescriptionuseAlphaBoolean<optional>trueif alpha should be included in resultSourceengineUtilities.js, line 760Returns:Type: String",https://killedbyapixel.github.io/LittleJS/docs/Color.html
Class: EngineObject,"EngineObjectLittleJS Object Base Object ClassTop level object class used by the engineAutomatically adds self to object listWill be updated and rendered each frameRenders as a sprite from a tilesheet by defaultCan have color and additive color applied2D Physics and collision systemSorted by renderOrderObjects can have children attachedParents are updated before children, and set child transformCall destroy() to get rid of objectsThe physics system used by objects is simple and fast with some caveats...Collision uses the axis aligned size, the object's rotation angle is only for renderingObjects are guaranteed to not intersect tile collision from physicsIf an object starts or is moved inside tile collision, it will not collide with that tileCollision for objects can be set to be solid to block other objectsObjects may get pushed into overlapping other solid objects, if so they will push awaySolid objects are more performance intensive and should be used sparinglyConstructornew EngineObject(posopt, sizeopt, tileInfoopt, angleopt, coloropt, renderOrderopt)Create an engine object and adds it to the list of objectsParameters:NameTypeAttributesDefaultDescriptionposVector2<optional>(0,0)World space position of the objectsizeVector2<optional>(1,1)World space size of the objecttileInfoTileInfo<optional>Tile info to render object (undefined is untextured)angleNumber<optional>0Angle the object is rotated bycolorColor<optional>(1,1,1,1)Color to apply to tile when renderedrenderOrderNumber<optional>0Objects sorted by renderOrder before being renderedSourceengineObject.js, line 32Example// create an engine object, normally you would first extend the class with your own const pos = vec2(2,3); const object = new EngineObject(pos); MembersadditiveColorPropertiesTypeDescriptionColorAdditive color to apply when renderedSourceengineObject.js, line 61anglePropertiesTypeDescriptionNumberAngle to rotate the objectSourceengineObject.js, line 57angleDampingPropertiesNameTypeAttributesDefaultDescriptionangleDampingNumber<optional>objectDefaultAngleDampingHow much to slow down rotation each frame (0-1)SourceengineObject.js, line 71angleVelocityPropertiesTypeDescriptionNumberAngular velocity of the objectSourceengineObject.js, line 83childrenPropertiesTypeDescriptionArrayList of children of this objectSourceengineObject.js, line 87clampSpeedLinearPropertiesTypeDescriptionBooleanLimit object speed using linear or circular mathSourceengineObject.js, line 89collideRaycastPropertiesTypeDescriptionBooleanObject collides with raycastsSourceengineObject.js, line 107collideSolidObjectsPropertiesTypeDescriptionBooleanObject collides with solid objectsSourceengineObject.js, line 103collideTilesPropertiesTypeDescriptionBooleanObject collides with the tile collisionSourceengineObject.js, line 101colorPropertiesTypeDescriptionColorColor to apply when renderedSourceengineObject.js, line 59dampingPropertiesNameTypeAttributesDefaultDescriptiondampingNumber<optional>objectDefaultDampingHow much to slow down velocity each frame (0-1)SourceengineObject.js, line 69drawSizePropertiesTypeDescriptionVector2Size of object used for drawing, uses size if not setSourceengineObject.js, line 53elasticityPropertiesNameTypeAttributesDefaultDescriptionelasticityNumber<optional>objectDefaultElasticityHow bouncy the object is when colliding (0-1)SourceengineObject.js, line 73frictionPropertiesNameTypeAttributesDefaultDescriptionfrictionNumber<optional>objectDefaultFrictionHow much friction to apply when sliding (0-1)SourceengineObject.js, line 75gravityScalePropertiesTypeDescriptionNumberHow much to scale gravity by for this objectSourceengineObject.js, line 77isSolidPropertiesTypeDescriptionBooleanObject collides with and blocks other objectsSourceengineObject.js, line 105localAnglePropertiesTypeDescriptionNumberLocal angle if childSourceengineObject.js, line 97localPosPropertiesTypeDescriptionVector2Local position if childSourceengineObject.js, line 95massPropertiesNameTypeAttributesDefaultDescriptionmassNumber<optional>objectDefaultMassHow heavy the object is, static if 0SourceengineObject.js, line 67mirrorPropertiesTypeDescriptionBooleanShould it flip along y axis when renderedSourceengineObject.js, line 63parentPropertiesTypeDescriptionEngineObjectParent of object if in local spaceSourceengineObject.js, line 93posPropertiesTypeDescriptionVector2World space position of the objectSourceengineObject.js, line 49renderOrderPropertiesTypeDescriptionNumberObjects are sorted by render orderSourceengineObject.js, line 79sizePropertiesTypeDescriptionVector2World space width and height of the objectSourceengineObject.js, line 51spawnTimePropertiesTypeDescriptionNumberTrack when object was createdSourceengineObject.js, line 85tileInfoPropertiesTypeDescriptionTileInfoTile info to render object (undefined is untextured)SourceengineObject.js, line 55velocityPropertiesTypeDescriptionVector2Velocity of the objectSourceengineObject.js, line 81MethodsaddChild(child, localPosopt, localAngleopt)Attaches a child to this with a given local transformParameters:NameTypeAttributesDefaultDescriptionchildEngineObjectlocalPosVector2<optional>(0,0)localAngleNumber<optional>0SourceengineObject.js, line 387applyAcceleration(acceleration)Apply acceleration to this object (adjust velocity, not affected by mass)Parameters:NameTypeDescriptionaccelerationVector2SourceengineObject.js, line 373applyForce(force)Apply force to this object (adjust velocity, affected by mass)Parameters:NameTypeDescriptionforceVector2SourceengineObject.js, line 377collideWithObject(object) → {Boolean}Called to check if a object collision should be resolvedParameters:NameTypeDescriptionobjectEngineObjectthe object to test againstSourceengineObject.js, line 365Returns:true if the collision should be resolvedType: BooleancollideWithTile(tileData, pos) → {Boolean}Called to check if a tile collision should be resolvedParameters:NameTypeDescriptiontileDataNumberthe value of the tile at the positionposVector2tile where the collision occurredSourceengineObject.js, line 359Returns:true if the collision should be resolvedType: Booleandestroy()Destroy this object, destroy it's children, detach it's parent, and mark it for removalSourceengineObject.js, line 327getAliveTime() → {Number}How long since the object was createdSourceengineObject.js, line 369Returns:Type: NumbergetMirrorSign() → {Number}Get the direction of the mirrorSourceengineObject.js, line 381Returns:-1 if this.mirror is true, or 1 if not mirroredType: NumberlocalToWorld(pos)Convert from local space to world spaceParameters:NameTypeDescriptionposVector2local space pointSourceengineObject.js, line 341localToWorldVector(vec)Convert from local space to world space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2local space vectorSourceengineObject.js, line 349removeChild(child)Removes a child from this oneParameters:NameTypeDescriptionchildEngineObjectSourceengineObject.js, line 398render()Render the object, draws a tile by default, automatically called each frame, sorted by renderOrderSourceengineObject.js, line 320renderDebugInfo()Render debug info for this objectSourceengineObject.js, line 442setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt, collideRaycastopt)Set how this object collidesParameters:NameTypeAttributesDefaultDescriptioncollideSolidObjectsBoolean<optional>trueDoes it collide with solid objects?isSolidBoolean<optional>trueDoes it collide with and block other objects? (expensive in large numbers)collideTilesBoolean<optional>trueDoes it collide with the tile collision?collideRaycastBoolean<optional>trueDoes it collide with raycasts?SourceengineObject.js, line 410toString() → {String}Returns string containing info about this object for debuggingSourceengineObject.js, line 422Returns:Type: Stringupdate()Update the object physics, called automatically by engine once each frameSourceengineObject.js, line 131updateTransforms()Update the object transform, called automatically by engine even when pausedSourceengineObject.js, line 114worldToLocal(pos)Convert from world space to local spaceParameters:NameTypeDescriptionposVector2world space pointSourceengineObject.js, line 345worldToLocalVector(vec)Convert from world space to local space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2world space vectorSourceengineObject.js, line 353",https://killedbyapixel.github.io/LittleJS/docs/EngineObject.html
Class: FontImage,"FontImageFont Image Object - Draw text on a 2D canvas by using characters in an image96 characters (from space to tilde) are stored in an imageUses a default 8x8 font if none is suppliedYou can also use fonts from the main tile sheetConstructornew FontImage(imageopt, tileSizeopt, paddingSizeopt, contextopt)Create an image fontParameters:NameTypeAttributesDefaultDescriptionimageHTMLImageElement<optional>Image for the font, if undefined default font is usedtileSizeVector2<optional>(8,8)Size of the font source tilespaddingSizeVector2<optional>(0,1)How much extra space to add between characterscontextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>overlayContextcontext to draw toSourceengineDraw.js, line 501Example// use built in font const font = new FontImage; // draw text font.drawTextScreen(""LittleJS\nHello World!"", vec2(200, 50));MethodsdrawText(text, pos, scaleopt, centeropt)Draw text in world space using the image fontParameters:NameTypeAttributesDefaultDescriptiontextStringposVector2scaleNumber<optional>.25centerBoolean<optional>SourceengineDraw.js, line 527drawTextScreen(text, pos, scaleopt, centeropt)Draw text in screen space using the image fontParameters:NameTypeAttributesDefaultDescriptiontextStringposVector2scaleNumber<optional>4centerBoolean<optional>SourceengineDraw.js, line 538",https://killedbyapixel.github.io/LittleJS/docs/FontImage.html
Class: Medal,"MedalMedal - Tracks an unlockable medalConstructornew Medal(id, name, descriptionopt, iconopt, srcopt)Create a medal object and adds it to the list of medalsParameters:NameTypeAttributesDefaultDescriptionidNumberThe unique identifier of the medalnameStringName of the medaldescriptionString<optional>Description of the medaliconString<optional>🏆Icon for the medalsrcString<optional>Image location for the medalSourceengineMedals.js, line 82Example// create a medal const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️'); // initialize medals medalsInit('Example Game'); // unlock the medal medal_example.unlock();MembersdescriptionPropertiesTypeDescriptionStringDescription of the medalSourceengineMedals.js, line 102iconPropertiesTypeDescriptionStringIcon for the medalSourceengineMedals.js, line 105idPropertiesTypeDescriptionNumberThe unique identifier of the medalSourceengineMedals.js, line 96namePropertiesTypeDescriptionStringName of the medalSourceengineMedals.js, line 99unlockedPropertiesTypeDescriptionBooleanIs the medal unlocked?SourceengineMedals.js, line 108Methodsrender(hidePercentopt)Render a medalParameters:NameTypeAttributesDefaultDescriptionhidePercentNumber<optional>0How much to slide the medal off screenSourceengineMedals.js, line 133renderIcon(pos, sizeopt)Render the icon for a medalParameters:NameTypeAttributesDefaultDescriptionposVector2Screen space positionsizeNumber<optional>medalDisplayIconSizeScreen space sizeSourceengineMedals.js, line 164unlock()Unlocks a medal if not already unlockedSourceengineMedals.js, line 119",https://killedbyapixel.github.io/LittleJS/docs/Medal.html
Class: Music,"MusicMusic Object - Stores a zzfx music track for later useCreate music with the ZzFXM tracker.Constructornew Music(zzfxMusic)Create a music object and cache the zzfx music samples for later useParameters:NameTypeDescriptionzzfxMusicSourceengineAudio.js, line 241Example// create some music const music_example = new Music( [ [ // instruments [,0,400] // simple note ], [ // patterns [ // pattern 1 [ // channel 0 0, -1, // instrument 0, left speaker 1, 0, 9, 1 // channel notes ], [ // channel 1 0, 1, // instrument 0, right speaker 0, 12, 17, -1 // channel notes ] ], ], [0, 0, 0, 0], // sequence, play pattern 0 four times 90 // BPM ]); // play the music music_example.play();MethodsplayMusic(volumeopt, loopopt) → {AudioBufferSourceNode}Play the musicParameters:NameTypeAttributesDefaultDescriptionvolumeNumber<optional>1How much to scale volume byloopBoolean<optional>falseTrue if the music should loopSourceengineAudio.js, line 261Returns:The audio source nodeType: AudioBufferSourceNode",https://killedbyapixel.github.io/LittleJS/docs/Music.html
Class: Particle,"ParticleParticle Object - Created automatically by Particle EmittersConstructornew Particle(position, tileInfo, angle, colorStart, colorEnd, lifeTime, sizeStart, sizeEnd, fadeRate, additive, trailScale, localSpaceEmitteropt, destroyCallbackopt)Create a particle with the passed in settings Typically this is created automatically by a ParticleEmitterParameters:NameTypeAttributesDescriptionpositionVector2World space position of the particletileInfoTileInfoTile info to render particlesangleNumberAngle to rotate the particlecolorStartColorColor at start of lifecolorEndColorColor at end of lifelifeTimeNumberHow long to live forsizeStartNumberSize at start of lifesizeEndNumberSize at end of lifefadeRateNumberHow quick to fade in/outadditiveBooleanDoes it use additive blend modetrailScaleNumberIf a trail, how long to make itlocalSpaceEmitterParticleEmitter<optional>Parent emitter if local spacedestroyCallbackfunction<optional>Callback when particle diesSourceengineParticles.js, line 233ExtendsEngineObjectMembersadditivePropertiesTypeDescriptionBooleanIs it additiveSourceengineParticles.js, line 270additiveColorPropertiesTypeDescriptionColorAdditive color to apply when renderedOverridesEngineObject#additiveColorSourceengineObject.js, line 61anglePropertiesTypeDescriptionNumberAngle to rotate the objectOverridesEngineObject#angleSourceengineObject.js, line 57angleDampingPropertiesNameTypeAttributesDefaultDescriptionangleDampingNumber<optional>objectDefaultAngleDampingHow much to slow down rotation each frame (0-1)OverridesEngineObject#angleDampingSourceengineObject.js, line 71angleVelocityPropertiesTypeDescriptionNumberAngular velocity of the objectOverridesEngineObject#angleVelocitySourceengineObject.js, line 83childrenPropertiesTypeDescriptionArrayList of children of this objectOverridesEngineObject#childrenSourceengineObject.js, line 87clampSpeedLinearPropertiesTypeDescriptionBooleanLimit object speed using linear or circular mathOverridesEngineObject#clampSpeedLinearSourceengineObject.js, line 89collideRaycastPropertiesTypeDescriptionBooleanObject collides with raycastsOverridesEngineObject#collideRaycastSourceengineObject.js, line 107collideSolidObjectsPropertiesTypeDescriptionBooleanObject collides with solid objectsOverridesEngineObject#collideSolidObjectsSourceengineObject.js, line 103collideTilesPropertiesTypeDescriptionBooleanObject collides with the tile collisionOverridesEngineObject#collideTilesSourceengineObject.js, line 101colorPropertiesTypeDescriptionColorColor to apply when renderedOverridesEngineObject#colorSourceengineObject.js, line 59colorEndDeltaPropertiesTypeDescriptionColorCalculated change in colorSourceengineParticles.js, line 260colorStartPropertiesTypeDescriptionColorColor at start of lifeSourceengineParticles.js, line 258dampingPropertiesNameTypeAttributesDefaultDescriptiondampingNumber<optional>objectDefaultDampingHow much to slow down velocity each frame (0-1)OverridesEngineObject#dampingSourceengineObject.js, line 69destroyCallbackPropertiesTypeDescriptionfunctionCalled when particle diesSourceengineParticles.js, line 276drawSizePropertiesTypeDescriptionVector2Size of object used for drawing, uses size if not setOverridesEngineObject#drawSizeSourceengineObject.js, line 53elasticityPropertiesNameTypeAttributesDefaultDescriptionelasticityNumber<optional>objectDefaultElasticityHow bouncy the object is when colliding (0-1)OverridesEngineObject#elasticitySourceengineObject.js, line 73fadeRatePropertiesTypeDescriptionNumberHow quick to fade in/outSourceengineParticles.js, line 268frictionPropertiesNameTypeAttributesDefaultDescriptionfrictionNumber<optional>objectDefaultFrictionHow much friction to apply when sliding (0-1)OverridesEngineObject#frictionSourceengineObject.js, line 75gravityScalePropertiesTypeDescriptionNumberHow much to scale gravity by for this objectOverridesEngineObject#gravityScaleSourceengineObject.js, line 77isSolidPropertiesTypeDescriptionBooleanObject collides with and blocks other objectsOverridesEngineObject#isSolidSourceengineObject.js, line 105lifeTimePropertiesTypeDescriptionNumberHow long to live forSourceengineParticles.js, line 262localAnglePropertiesTypeDescriptionNumberLocal angle if childOverridesEngineObject#localAngleSourceengineObject.js, line 97localPosPropertiesTypeDescriptionVector2Local position if childOverridesEngineObject#localPosSourceengineObject.js, line 95localSpaceEmitterPropertiesTypeDescriptionParticleEmitterParent emitter if local spaceSourceengineParticles.js, line 274massPropertiesNameTypeAttributesDefaultDescriptionmassNumber<optional>objectDefaultMassHow heavy the object is, static if 0OverridesEngineObject#massSourceengineObject.js, line 67mirrorPropertiesTypeDescriptionBooleanShould it flip along y axis when renderedOverridesEngineObject#mirrorSourceengineObject.js, line 63parentPropertiesTypeDescriptionEngineObjectParent of object if in local spaceOverridesEngineObject#parentSourceengineObject.js, line 93posPropertiesTypeDescriptionVector2World space position of the objectOverridesEngineObject#posSourceengineObject.js, line 49renderOrderPropertiesTypeDescriptionNumberObjects are sorted by render orderOverridesEngineObject#renderOrderSourceengineObject.js, line 79sizePropertiesTypeDescriptionVector2World space width and height of the objectOverridesEngineObject#sizeSourceengineObject.js, line 51sizeEndDeltaPropertiesTypeDescriptionNumberCalculated change in sizeSourceengineParticles.js, line 266sizeStartPropertiesTypeDescriptionNumberSize at start of lifeSourceengineParticles.js, line 264spawnTimePropertiesTypeDescriptionNumberTrack when object was createdOverridesEngineObject#spawnTimeSourceengineObject.js, line 85tileInfoPropertiesTypeDescriptionTileInfoTile info to render object (undefined is untextured)OverridesEngineObject#tileInfoSourceengineObject.js, line 55trailScalePropertiesTypeDescriptionNumberIf a trail, how long to make itSourceengineParticles.js, line 272velocityPropertiesTypeDescriptionVector2Velocity of the objectOverridesEngineObject#velocitySourceengineObject.js, line 81MethodsaddChild(child, localPosopt, localAngleopt)Attaches a child to this with a given local transformParameters:NameTypeAttributesDefaultDescriptionchildEngineObjectlocalPosVector2<optional>(0,0)localAngleNumber<optional>0OverridesEngineObject#addChildSourceengineObject.js, line 387applyAcceleration(acceleration)Apply acceleration to this object (adjust velocity, not affected by mass)Parameters:NameTypeDescriptionaccelerationVector2OverridesEngineObject#applyAccelerationSourceengineObject.js, line 373applyForce(force)Apply force to this object (adjust velocity, affected by mass)Parameters:NameTypeDescriptionforceVector2OverridesEngineObject#applyForceSourceengineObject.js, line 377collideWithObject(object) → {Boolean}Called to check if a object collision should be resolvedParameters:NameTypeDescriptionobjectEngineObjectthe object to test againstOverridesEngineObject#collideWithObjectSourceengineObject.js, line 365Returns:true if the collision should be resolvedType: BooleancollideWithTile(tileData, pos) → {Boolean}Called to check if a tile collision should be resolvedParameters:NameTypeDescriptiontileDataNumberthe value of the tile at the positionposVector2tile where the collision occurredOverridesEngineObject#collideWithTileSourceengineObject.js, line 359Returns:true if the collision should be resolvedType: Booleandestroy()Destroy this object, destroy it's children, detach it's parent, and mark it for removalOverridesEngineObject#destroySourceengineObject.js, line 327getAliveTime() → {Number}How long since the object was createdOverridesEngineObject#getAliveTimeSourceengineObject.js, line 369Returns:Type: NumbergetMirrorSign() → {Number}Get the direction of the mirrorOverridesEngineObject#getMirrorSignSourceengineObject.js, line 381Returns:-1 if this.mirror is true, or 1 if not mirroredType: NumberlocalToWorld(pos)Convert from local space to world spaceParameters:NameTypeDescriptionposVector2local space pointOverridesEngineObject#localToWorldSourceengineObject.js, line 341localToWorldVector(vec)Convert from local space to world space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2local space vectorOverridesEngineObject#localToWorldVectorSourceengineObject.js, line 349removeChild(child)Removes a child from this oneParameters:NameTypeDescriptionchildEngineObjectOverridesEngineObject#removeChildSourceengineObject.js, line 398render()Render the particle, automatically called each frame, sorted by renderOrderOverridesEngineObject#renderSourceengineParticles.js, line 283renderDebugInfo()Render debug info for this objectOverridesEngineObject#renderDebugInfoSourceengineObject.js, line 442setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt, collideRaycastopt)Set how this object collidesParameters:NameTypeAttributesDefaultDescriptioncollideSolidObjectsBoolean<optional>trueDoes it collide with solid objects?isSolidBoolean<optional>trueDoes it collide with and block other objects? (expensive in large numbers)collideTilesBoolean<optional>trueDoes it collide with the tile collision?collideRaycastBoolean<optional>trueDoes it collide with raycasts?OverridesEngineObject#setCollisionSourceengineObject.js, line 410toString() → {String}Returns string containing info about this object for debuggingOverridesEngineObject#toStringSourceengineObject.js, line 422Returns:Type: Stringupdate()Update the object physics, called automatically by engine once each frameOverridesEngineObject#updateSourceengineObject.js, line 131updateTransforms()Update the object transform, called automatically by engine even when pausedOverridesEngineObject#updateTransformsSourceengineObject.js, line 114worldToLocal(pos)Convert from world space to local spaceParameters:NameTypeDescriptionposVector2world space pointOverridesEngineObject#worldToLocalSourceengineObject.js, line 345worldToLocalVector(vec)Convert from world space to local space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2world space vectorOverridesEngineObject#worldToLocalVectorSourceengineObject.js, line 353",https://killedbyapixel.github.io/LittleJS/docs/Particle.html
Class: ParticleEmitter,"ParticleEmitterParticle Emitter - Spawns particles with the given settingsConstructornew ParticleEmitter(position, angleopt, emitSizeopt, emitTimeopt, emitRateopt, emitConeAngleopt, tileInfoopt, colorStartAopt, colorStartBopt, colorEndAopt, colorEndBopt, particleTimeopt, sizeStartopt, sizeEndopt, speedopt, angleSpeedopt, dampingopt, angleDampingopt, gravityScaleopt, particleConeAngleopt, fadeRateopt, randomnessopt, collideTilesopt, additiveopt, randomColorLinearopt, renderOrderopt, localSpaceopt)Create a particle system with the given settingsParameters:NameTypeAttributesDefaultDescriptionpositionVector2World space position of the emitterangleNumber<optional>Angle to emit the particlesemitSizeNumber | Vector2<optional>0World space size of the emitter (float for circle diameter, vec2 for rect)emitTimeNumber<optional>0How long to stay alive (0 is forever)emitRateNumber<optional>100How many particles per second to spawn, does not emit if 0emitConeAngleNumber<optional>PILocal angle to apply velocity to particles from emittertileInfoTileInfo<optional>Tile info to render particles (undefined is untextured)colorStartAColor<optional>(1,1,1,1)Color at start of life 1, randomized between start colorscolorStartBColor<optional>(1,1,1,1)Color at start of life 2, randomized between start colorscolorEndAColor<optional>(1,1,1,0)Color at end of life 1, randomized between end colorscolorEndBColor<optional>(1,1,1,0)Color at end of life 2, randomized between end colorsparticleTimeNumber<optional>0.5How long particles livesizeStartNumber<optional>0.1How big are particles at startsizeEndNumber<optional>1How big are particles at endspeedNumber<optional>0.1How fast are particles when spawnedangleSpeedNumber<optional>0.05How fast are particles rotatingdampingNumber<optional>1How much to dampen particle speedangleDampingNumber<optional>1How much to dampen particle angular speedgravityScaleNumber<optional>0How much gravity effect particlesparticleConeAngleNumber<optional>Cone for start particle anglefadeRateNumber<optional>0.1How quick to fade particles at start/end in percent of liferandomnessNumber<optional>0.2Apply extra randomness percentcollideTilesBoolean<optional>falseDo particles collide against tilesadditiveBoolean<optional>falseShould particles use additive blendrandomColorLinearBoolean<optional>trueShould color be randomized linearly or across each componentrenderOrderNumber<optional>Render order for particles (additive is above other stuff by default)localSpaceBoolean<optional>falseShould it be in local space of emitter (world space is default)SourceengineParticles.js, line 24Example// create a particle emitter let pos = vec2(2,3); let particleEmitter = new ParticleEmitter ( pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emitCone tile(0, 16), // tileInfo rgb(1,1,1), rgb(0,0,0), // colorStartA, colorStartB rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate, .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder );ExtendsEngineObjectMembersadditivePropertiesTypeDescriptionBooleanShould particles use additive blendSourceengineParticles.js, line 136additiveColorPropertiesTypeDescriptionColorAdditive color to apply when renderedOverridesEngineObject#additiveColorSourceengineObject.js, line 61anglePropertiesTypeDescriptionNumberAngle to rotate the objectOverridesEngineObject#angleSourceengineObject.js, line 57angleDampingPropertiesTypeDescriptionNumberHow much to dampen particle angular speedOverridesEngineObject#angleDampingSourceengineParticles.js, line 124angleSpeedPropertiesTypeDescriptionNumberHow fast are particles rotatingSourceengineParticles.js, line 120angleVelocityPropertiesTypeDescriptionNumberAngular velocity of the objectOverridesEngineObject#angleVelocitySourceengineObject.js, line 83childrenPropertiesTypeDescriptionArrayList of children of this objectOverridesEngineObject#childrenSourceengineObject.js, line 87clampSpeedLinearPropertiesTypeDescriptionBooleanLimit object speed using linear or circular mathOverridesEngineObject#clampSpeedLinearSourceengineObject.js, line 89collideRaycastPropertiesTypeDescriptionBooleanObject collides with raycastsOverridesEngineObject#collideRaycastSourceengineObject.js, line 107collideSolidObjectsPropertiesTypeDescriptionBooleanObject collides with solid objectsOverridesEngineObject#collideSolidObjectsSourceengineObject.js, line 103collideTilesPropertiesTypeDescriptionBooleanDo particles collide against tilesOverridesEngineObject#collideTilesSourceengineParticles.js, line 134colorPropertiesTypeDescriptionColorColor to apply when renderedOverridesEngineObject#colorSourceengineObject.js, line 59colorEndAPropertiesTypeDescriptionColorColor at end of life 1, randomized between end colorsSourceengineParticles.js, line 104colorEndBPropertiesTypeDescriptionColorColor at end of life 2, randomized between end colorsSourceengineParticles.js, line 106colorStartAPropertiesTypeDescriptionColorColor at start of life 1, randomized between start colorsSourceengineParticles.js, line 100colorStartBPropertiesTypeDescriptionColorColor at start of life 2, randomized between start colorsSourceengineParticles.js, line 102dampingPropertiesTypeDescriptionNumberHow much to dampen particle speedOverridesEngineObject#dampingSourceengineParticles.js, line 122drawSizePropertiesTypeDescriptionVector2Size of object used for drawing, uses size if not setOverridesEngineObject#drawSizeSourceengineObject.js, line 53elasticityPropertiesNameTypeAttributesDefaultDescriptionelasticityNumber<optional>objectDefaultElasticityHow bouncy the object is when colliding (0-1)OverridesEngineObject#elasticitySourceengineObject.js, line 73emitConeAnglePropertiesTypeDescriptionNumberLocal angle to apply velocity to particles from emitterSourceengineParticles.js, line 96emitRatePropertiesTypeDescriptionNumberHow many particles per second to spawn, does not emit if 0SourceengineParticles.js, line 94emitSizePropertiesTypeDescriptionNumber | Vector2World space size of the emitter (float for circle diameter, vec2 for rect)SourceengineParticles.js, line 90emitTimePropertiesTypeDescriptionNumberHow long to stay alive (0 is forever)SourceengineParticles.js, line 92emitTimeBufferPropertiesTypeDescriptionNumberTrack particle emit timeSourceengineParticles.js, line 146fadeRatePropertiesTypeDescriptionNumberHow quick to fade in particles at start/end in percent of lifeSourceengineParticles.js, line 130frictionPropertiesNameTypeAttributesDefaultDescriptionfrictionNumber<optional>objectDefaultFrictionHow much friction to apply when sliding (0-1)OverridesEngineObject#frictionSourceengineObject.js, line 75gravityScalePropertiesTypeDescriptionNumberHow much does gravity effect particlesOverridesEngineObject#gravityScaleSourceengineParticles.js, line 126isSolidPropertiesTypeDescriptionBooleanObject collides with and blocks other objectsOverridesEngineObject#isSolidSourceengineObject.js, line 105localAnglePropertiesTypeDescriptionNumberLocal angle if childOverridesEngineObject#localAngleSourceengineObject.js, line 97localPosPropertiesTypeDescriptionVector2Local position if childOverridesEngineObject#localPosSourceengineObject.js, line 95localSpacePropertiesTypeDescriptionBooleanShould it be in local space of emitterSourceengineParticles.js, line 138massPropertiesNameTypeAttributesDefaultDescriptionmassNumber<optional>objectDefaultMassHow heavy the object is, static if 0OverridesEngineObject#massSourceengineObject.js, line 67mirrorPropertiesTypeDescriptionBooleanShould it flip along y axis when renderedOverridesEngineObject#mirrorSourceengineObject.js, line 63parentPropertiesTypeDescriptionEngineObjectParent of object if in local spaceOverridesEngineObject#parentSourceengineObject.js, line 93particleConeAnglePropertiesTypeDescriptionNumberCone for start particle angleSourceengineParticles.js, line 128particleCreateCallbackPropertiesTypeDescriptionfunctionCallback when particle is createdSourceengineParticles.js, line 144particleDestroyCallbackPropertiesTypeDescriptionfunctionCallback when particle is destroyedSourceengineParticles.js, line 142particleTimePropertiesTypeDescriptionNumberHow long particles liveSourceengineParticles.js, line 112posPropertiesTypeDescriptionVector2World space position of the objectOverridesEngineObject#posSourceengineObject.js, line 49randomColorLinearPropertiesTypeDescriptionBooleanShould color be randomized linearly or across each componentSourceengineParticles.js, line 108randomnessPropertiesTypeDescriptionNumberApply extra randomness percentSourceengineParticles.js, line 132renderOrderPropertiesTypeDescriptionNumberObjects are sorted by render orderOverridesEngineObject#renderOrderSourceengineObject.js, line 79sizePropertiesTypeDescriptionVector2World space width and height of the objectOverridesEngineObject#sizeSourceengineObject.js, line 51sizeEndPropertiesTypeDescriptionNumberHow big are particles at endSourceengineParticles.js, line 116sizeStartPropertiesTypeDescriptionNumberHow big are particles at startSourceengineParticles.js, line 114spawnTimePropertiesTypeDescriptionNumberTrack when object was createdOverridesEngineObject#spawnTimeSourceengineObject.js, line 85speedPropertiesTypeDescriptionNumberHow fast are particles when spawnedSourceengineParticles.js, line 118tileInfoPropertiesTypeDescriptionTileInfoTile info to render object (undefined is untextured)OverridesEngineObject#tileInfoSourceengineObject.js, line 55trailScalePropertiesTypeDescriptionNumberIf non zero the particle is drawn as a trail, stretched in the direction of velocitySourceengineParticles.js, line 140velocityPropertiesTypeDescriptionVector2Velocity of the objectOverridesEngineObject#velocitySourceengineObject.js, line 81MethodsaddChild(child, localPosopt, localAngleopt)Attaches a child to this with a given local transformParameters:NameTypeAttributesDefaultDescriptionchildEngineObjectlocalPosVector2<optional>(0,0)localAngleNumber<optional>0OverridesEngineObject#addChildSourceengineObject.js, line 387applyAcceleration(acceleration)Apply acceleration to this object (adjust velocity, not affected by mass)Parameters:NameTypeDescriptionaccelerationVector2OverridesEngineObject#applyAccelerationSourceengineObject.js, line 373applyForce(force)Apply force to this object (adjust velocity, affected by mass)Parameters:NameTypeDescriptionforceVector2OverridesEngineObject#applyForceSourceengineObject.js, line 377collideWithObject(object) → {Boolean}Called to check if a object collision should be resolvedParameters:NameTypeDescriptionobjectEngineObjectthe object to test againstOverridesEngineObject#collideWithObjectSourceengineObject.js, line 365Returns:true if the collision should be resolvedType: BooleancollideWithTile(tileData, pos) → {Boolean}Called to check if a tile collision should be resolvedParameters:NameTypeDescriptiontileDataNumberthe value of the tile at the positionposVector2tile where the collision occurredOverridesEngineObject#collideWithTileSourceengineObject.js, line 359Returns:true if the collision should be resolvedType: Booleandestroy()Destroy this object, destroy it's children, detach it's parent, and mark it for removalOverridesEngineObject#destroySourceengineObject.js, line 327emitParticle() → {Particle}Spawn one particleSourceengineParticles.js, line 174Returns:Type: ParticlegetAliveTime() → {Number}How long since the object was createdOverridesEngineObject#getAliveTimeSourceengineObject.js, line 369Returns:Type: NumbergetMirrorSign() → {Number}Get the direction of the mirrorOverridesEngineObject#getMirrorSignSourceengineObject.js, line 381Returns:-1 if this.mirror is true, or 1 if not mirroredType: NumberlocalToWorld(pos)Convert from local space to world spaceParameters:NameTypeDescriptionposVector2local space pointOverridesEngineObject#localToWorldSourceengineObject.js, line 341localToWorldVector(vec)Convert from local space to world space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2local space vectorOverridesEngineObject#localToWorldVectorSourceengineObject.js, line 349removeChild(child)Removes a child from this oneParameters:NameTypeDescriptionchildEngineObjectOverridesEngineObject#removeChildSourceengineObject.js, line 398render()Render the object, draws a tile by default, automatically called each frame, sorted by renderOrderOverridesEngineObject#renderSourceengineObject.js, line 320renderDebugInfo()Render debug info for this objectOverridesEngineObject#renderDebugInfoSourceengineObject.js, line 442setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt, collideRaycastopt)Set how this object collidesParameters:NameTypeAttributesDefaultDescriptioncollideSolidObjectsBoolean<optional>trueDoes it collide with solid objects?isSolidBoolean<optional>trueDoes it collide with and block other objects? (expensive in large numbers)collideTilesBoolean<optional>trueDoes it collide with the tile collision?collideRaycastBoolean<optional>trueDoes it collide with raycasts?OverridesEngineObject#setCollisionSourceengineObject.js, line 410toString() → {String}Returns string containing info about this object for debuggingOverridesEngineObject#toStringSourceengineObject.js, line 422Returns:Type: Stringupdate()Update the emitter to spawn particles, called automatically by engine once each frameOverridesEngineObject#updateSourceengineParticles.js, line 150updateTransforms()Update the object transform, called automatically by engine even when pausedOverridesEngineObject#updateTransformsSourceengineObject.js, line 114worldToLocal(pos)Convert from world space to local spaceParameters:NameTypeDescriptionposVector2world space pointOverridesEngineObject#worldToLocalSourceengineObject.js, line 345worldToLocalVector(vec)Convert from world space to local space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2world space vectorOverridesEngineObject#worldToLocalVectorSourceengineObject.js, line 353",https://killedbyapixel.github.io/LittleJS/docs/ParticleEmitter.html
Class: RandomGenerator,"RandomGeneratorSeeded random number generatorCan be used to create a deterministic random number sequenceConstructornew RandomGenerator(seed)Create a random number generator with the seed passed inParameters:NameTypeDescriptionseedNumberStarting seedSourceengineUtilities.js, line 255Examplelet r = new RandomGenerator(123); // random number generator with seed 123 let a = r.float(); // random value between 0 and 1 let b = r.int(10); // random integer between 0 and 9 r.seed = 123; // reset the seed let c = r.float(); // the same value as aMembersseedPropertiesTypeDescriptionNumberrandom seedSourceengineUtilities.js, line 262Methodsfloat(valueAopt, valueBopt) → {Number}Returns a seeded random value between the two values passed inParameters:NameTypeAttributesDefaultDescriptionvalueANumber<optional>1valueBNumber<optional>0SourceengineUtilities.js, line 269Returns:Type: Numberint(valueA, valueBopt) → {Number}Returns a floored seeded random value the two values passed inParameters:NameTypeAttributesDefaultDescriptionvalueANumbervalueBNumber<optional>0SourceengineUtilities.js, line 282Returns:Type: Numbersign() → {Number}Randomly returns either -1 or 1 deterministicallySourceengineUtilities.js, line 286Returns:Type: Number",https://killedbyapixel.github.io/LittleJS/docs/RandomGenerator.html
Class: Sound,"SoundSound Object - Stores a sound for later use and can be played positionallyCreate sounds using the ZzFX Sound Designer.Constructornew Sound(zzfxSound, rangeopt, taperopt)Create a sound object and cache the zzfx samples for later useParameters:NameTypeAttributesDefaultDescriptionzzfxSoundArrayArray of zzfx parameters, ex. [.5,.5]rangeNumber<optional>soundDefaultRangeWorld space max range of sound, will not play if camera is farther awaytaperNumber<optional>soundDefaultTaperAt what percentage of range should it start taperingSourceengineAudio.js, line 47Example// create a sound const sound_example = new Sound([.5,.5]); // play the sound sound_example.play();MembersrandomnessPropertiesTypeDescriptionNumberHow much to randomize frequency each time sound playsSourceengineAudio.js, line 65rangePropertiesTypeDescriptionNumberWorld space max range of sound, will not play if camera is farther awaySourceengineAudio.js, line 59taperPropertiesTypeDescriptionNumberAt what percentage of range should it start tapering offSourceengineAudio.js, line 62MethodsgetDuration() → {Number}Get how long this sound is in secondsSourceengineAudio.js, line 151Returns:How long the sound is in seconds (undefined if loading)Type: NumbergetSource() → {AudioBufferSourceNode}Get source of most recent instance of this sound that was playedSourceengineAudio.js, line 137Returns:Type: AudioBufferSourceNodeisLoading() → {Boolean}Check if sound is loading, for sounds fetched from a urlSourceengineAudio.js, line 157Returns:True if sound is loading and not ready to playType: Booleanplay(posopt, volumeopt, pitchopt, randomnessScaleopt, loopopt) → {AudioBufferSourceNode}Play the soundParameters:NameTypeAttributesDefaultDescriptionposVector2<optional>World space position to play the sound, sound is not attenuated if nullvolumeNumber<optional>1How much to scale volume by (in addition to range fade)pitchNumber<optional>1How much to scale pitch by (also adjusted by this.randomness)randomnessScaleNumber<optional>1How much to scale randomnessloopBoolean<optional>falseShould the sound loopSourceengineAudio.js, line 86Returns:The audio source nodeType: AudioBufferSourceNodeplayNote(semitoneOffset, posopt, volumeopt) → {AudioBufferSourceNode}Play the sound as a note with a semitone offsetParameters:NameTypeAttributesDefaultDescriptionsemitoneOffsetNumberHow many semitones to offset pitchposVector2<optional>World space position to play the sound, sound is not attenuated if nullvolumeNumber<optional>1How much to scale volume by (in addition to range fade)SourceengineAudio.js, line 145Returns:The audio source nodeType: AudioBufferSourceNodesetVolume(volumeopt)Set the sound volume of the most recently played instance of this soundParameters:NameTypeAttributesDefaultDescriptionvolumeNumber<optional>1How much to scale volume bySourceengineAudio.js, line 120stop()Stop the last instance of this sound that was playedSourceengineAudio.js, line 127",https://killedbyapixel.github.io/LittleJS/docs/Sound.html
Class: SoundWave,"SoundWaveSound Wave Object - Stores a wave sound for later use and can be played positionallythis can be used to play wave, mp3, and ogg filesConstructornew SoundWave(filename, randomnessopt, rangeopt, taperopt, onloadCallbackopt)Create a sound object and cache the wave file for later useParameters:NameTypeAttributesDefaultDescriptionfilenameStringFilename of audio file to loadrandomnessNumber<optional>0How much to randomize frequency each time sound playsrangeNumber<optional>soundDefaultRangeWorld space max range of sound, will not play if camera is farther awaytaperNumber<optional>soundDefaultTaperAt what percentage of range should it start tapering offonloadCallbackfunction<optional>callback function to call when sound is loadedSourceengineAudio.js, line 170Example// create a sound const sound_example = new SoundWave('sound.mp3'); // play the sound sound_example.play();",https://killedbyapixel.github.io/LittleJS/docs/SoundWave.html
Class: TextureInfo,"TextureInfoTexture Info - Stores info about each textureConstructornew TextureInfo(image)Create a TextureInfo, called automatically by the engineParameters:NameTypeDescriptionimageHTMLImageElementSourceengineDraw.js, line 149MembersglTexturePropertiesTypeDescriptionWebGLTexturewebgl textureSourceengineDraw.js, line 162imagePropertiesTypeDescriptionHTMLImageElementimage sourceSourceengineDraw.js, line 158sizePropertiesTypeDescriptionVector2size of the imageSourceengineDraw.js, line 160",https://killedbyapixel.github.io/LittleJS/docs/TextureInfo.html
Class: TileInfo,"TileInfoTile Info - Stores info about how to draw a tileConstructornew TileInfo(posopt, sizeopt, textureIndexopt, paddingopt)Create a tile info objectParameters:NameTypeAttributesDefaultDescriptionposVector2<optional>(0,0)Top left corner of tile in pixelssizeVector2<optional>tileSizeDefaultSize of tile in pixelstextureIndexNumber<optional>0Texture index to usepaddingNumber<optional>0How many pixels padding around tilesSourceengineDraw.js, line 104MemberspaddingPropertiesTypeDescriptionNumberHow many pixels padding around tilesSourceengineDraw.js, line 121posPropertiesTypeDescriptionVector2Top left corner of tile in pixelsSourceengineDraw.js, line 115sizePropertiesTypeDescriptionVector2Size of tile in pixelsSourceengineDraw.js, line 117textureIndexPropertiesTypeDescriptionNumberTexture index to useSourceengineDraw.js, line 119Methodsframe(frame) → {TileInfo}Returns a copy of this tile offset by a number of animation framesParameters:NameTypeDescriptionframeNumberOffset to apply in animation framesSourceengineDraw.js, line 135Returns:Type: TileInfogetTextureInfo() → {TextureInfo}Returns the texture info for this tileSourceengineDraw.js, line 144Returns:Type: TextureInfooffset(offset) → {TileInfo}Returns a copy of this tile offset by a vectorParameters:NameTypeDescriptionoffsetVector2Offset to apply in pixelsSourceengineDraw.js, line 128Returns:Type: TileInfo",https://killedbyapixel.github.io/LittleJS/docs/TileInfo.html
Class: TileLayer,"TileLayerTile Layer - cached rendering system for tile layersEach Tile layer is rendered to an off screen canvasTo allow dynamic modifications, layers are rendered using canvas 2dSome devices like mobile phones are limited to 4k texture resolutionSo with 16x16 tiles this limits layers to 256x256 on mobile devicesConstructornew TileLayer(positionopt, sizeopt, tileInfoopt, scaleopt, renderOrderopt)Create a tile layer objectParameters:NameTypeAttributesDefaultDescriptionpositionVector2<optional>(0,0)World space positionsizeVector2<optional>tileCollisionSizeWorld space sizetileInfoTileInfo<optional>Tile info for layerscaleVector2<optional>(1,1)How much to scale this layer when renderedrenderOrderNumber<optional>0Objects are sorted by renderOrderSourceengineTileLayer.js, line 171Example// create tile collision and visible tile layer initTileCollision(vec2(200,100)); const tileLayer = new TileLayer();ExtendsEngineObjectMembersadditiveColorPropertiesTypeDescriptionColorAdditive color to apply when renderedOverridesEngineObject#additiveColorSourceengineObject.js, line 61anglePropertiesTypeDescriptionNumberAngle to rotate the objectOverridesEngineObject#angleSourceengineObject.js, line 57angleDampingPropertiesNameTypeAttributesDefaultDescriptionangleDampingNumber<optional>objectDefaultAngleDampingHow much to slow down rotation each frame (0-1)OverridesEngineObject#angleDampingSourceengineObject.js, line 71angleVelocityPropertiesTypeDescriptionNumberAngular velocity of the objectOverridesEngineObject#angleVelocitySourceengineObject.js, line 83canvasPropertiesTypeDescriptionHTMLCanvasElementThe canvas used by this tile layerSourceengineTileLayer.js, line 185childrenPropertiesTypeDescriptionArrayList of children of this objectOverridesEngineObject#childrenSourceengineObject.js, line 87clampSpeedLinearPropertiesTypeDescriptionBooleanLimit object speed using linear or circular mathOverridesEngineObject#clampSpeedLinearSourceengineObject.js, line 89collideRaycastPropertiesTypeDescriptionBooleanObject collides with raycastsOverridesEngineObject#collideRaycastSourceengineObject.js, line 107collideSolidObjectsPropertiesTypeDescriptionBooleanObject collides with solid objectsOverridesEngineObject#collideSolidObjectsSourceengineObject.js, line 103collideTilesPropertiesTypeDescriptionBooleanObject collides with the tile collisionOverridesEngineObject#collideTilesSourceengineObject.js, line 101colorPropertiesTypeDescriptionColorColor to apply when renderedOverridesEngineObject#colorSourceengineObject.js, line 59contextPropertiesTypeDescriptionCanvasRenderingContext2D | OffscreenCanvasRenderingContext2DThe 2D canvas context used by this tile layerSourceengineTileLayer.js, line 187dampingPropertiesNameTypeAttributesDefaultDescriptiondampingNumber<optional>objectDefaultDampingHow much to slow down velocity each frame (0-1)OverridesEngineObject#dampingSourceengineObject.js, line 69drawSizePropertiesTypeDescriptionVector2Size of object used for drawing, uses size if not setOverridesEngineObject#drawSizeSourceengineObject.js, line 53elasticityPropertiesNameTypeAttributesDefaultDescriptionelasticityNumber<optional>objectDefaultElasticityHow bouncy the object is when colliding (0-1)OverridesEngineObject#elasticitySourceengineObject.js, line 73frictionPropertiesNameTypeAttributesDefaultDescriptionfrictionNumber<optional>objectDefaultFrictionHow much friction to apply when sliding (0-1)OverridesEngineObject#frictionSourceengineObject.js, line 75gravityScalePropertiesTypeDescriptionNumberHow much to scale gravity by for this objectOverridesEngineObject#gravityScaleSourceengineObject.js, line 77isOverlayPropertiesTypeDescriptionBooleanIf true this layer will render to overlay canvas and appear above all objectsSourceengineTileLayer.js, line 191isSolidPropertiesTypeDescriptionBooleanObject collides with and blocks other objectsOverridesEngineObject#isSolidSourceengineObject.js, line 105localAnglePropertiesTypeDescriptionNumberLocal angle if childOverridesEngineObject#localAngleSourceengineObject.js, line 97localPosPropertiesTypeDescriptionVector2Local position if childOverridesEngineObject#localPosSourceengineObject.js, line 95massPropertiesNameTypeAttributesDefaultDescriptionmassNumber<optional>objectDefaultMassHow heavy the object is, static if 0OverridesEngineObject#massSourceengineObject.js, line 67mirrorPropertiesTypeDescriptionBooleanShould it flip along y axis when renderedOverridesEngineObject#mirrorSourceengineObject.js, line 63parentPropertiesTypeDescriptionEngineObjectParent of object if in local spaceOverridesEngineObject#parentSourceengineObject.js, line 93posPropertiesTypeDescriptionVector2World space position of the objectOverridesEngineObject#posSourceengineObject.js, line 49renderOrderPropertiesTypeDescriptionNumberObjects are sorted by render orderOverridesEngineObject#renderOrderSourceengineObject.js, line 79savedRenderSettingsSourceengineTileLayer.js, line 267scalePropertiesTypeDescriptionVector2How much to scale this layer when renderedSourceengineTileLayer.js, line 189sizePropertiesTypeDescriptionVector2World space width and height of the objectOverridesEngineObject#sizeSourceengineObject.js, line 51spawnTimePropertiesTypeDescriptionNumberTrack when object was createdOverridesEngineObject#spawnTimeSourceengineObject.js, line 85tileInfoPropertiesTypeDescriptionTileInfoTile info to render object (undefined is untextured)OverridesEngineObject#tileInfoSourceengineObject.js, line 55velocityPropertiesTypeDescriptionVector2Velocity of the objectOverridesEngineObject#velocitySourceengineObject.js, line 81MethodsaddChild(child, localPosopt, localAngleopt)Attaches a child to this with a given local transformParameters:NameTypeAttributesDefaultDescriptionchildEngineObjectlocalPosVector2<optional>(0,0)localAngleNumber<optional>0OverridesEngineObject#addChildSourceengineObject.js, line 387applyAcceleration(acceleration)Apply acceleration to this object (adjust velocity, not affected by mass)Parameters:NameTypeDescriptionaccelerationVector2OverridesEngineObject#applyAccelerationSourceengineObject.js, line 373applyForce(force)Apply force to this object (adjust velocity, affected by mass)Parameters:NameTypeDescriptionforceVector2OverridesEngineObject#applyForceSourceengineObject.js, line 377collideWithObject(object) → {Boolean}Called to check if a object collision should be resolvedParameters:NameTypeDescriptionobjectEngineObjectthe object to test againstOverridesEngineObject#collideWithObjectSourceengineObject.js, line 365Returns:true if the collision should be resolvedType: BooleancollideWithTile(tileData, pos) → {Boolean}Called to check if a tile collision should be resolvedParameters:NameTypeDescriptiontileDataNumberthe value of the tile at the positionposVector2tile where the collision occurredOverridesEngineObject#collideWithTileSourceengineObject.js, line 359Returns:true if the collision should be resolvedType: Booleandestroy()Destroy this object, destroy it's children, detach it's parent, and mark it for removalOverridesEngineObject#destroySourceengineObject.js, line 327drawCanvas2D(pos, size, angle, mirror, drawFunction)Draw directly to the 2D canvas in world space (bypass webgl)Parameters:NameTypeDescriptionposVector2sizeVector2angleNumbermirrorBooleandrawFunctionfunctionSourceengineTileLayer.js, line 335drawRect(pos, sizeopt, coloropt, angleopt)Draw a rectangle directly onto the layer canvas in world spaceParameters:NameTypeAttributesDefaultDescriptionposVector2sizeVector2<optional>(1,1)colorColor<optional>(1,1,1,1)angleNumber<optional>0SourceengineTileLayer.js, line 382drawTile(pos, sizeopt, tileInfoopt, coloropt, angleopt, mirroropt)Draw a tile directly onto the layer canvas in world spaceParameters:NameTypeAttributesDefaultDescriptionposVector2sizeVector2<optional>(1,1)tileInfoTileInfo<optional>colorColor<optional>(1,1,1,1)angleNumber<optional>0mirrorBoolean<optional>0SourceengineTileLayer.js, line 355drawTileData(layerPos, clearopt)Draw the tile at a given position in the tile grid This can be used to clear out tiles when they are destroyed Tiles can also be redrawn if inside a redrawStart/End blockParameters:NameTypeAttributesDefaultDescriptionlayerPosVector2clearBoolean<optional>trueshould the old tile be cleared outSourceengineTileLayer.js, line 308getAliveTime() → {Number}How long since the object was createdOverridesEngineObject#getAliveTimeSourceengineObject.js, line 369Returns:Type: NumbergetData(layerPos) → {TileLayerData}Get data at a given position in the arrayParameters:NameTypeDescriptionlayerPosVector2Local position in arraySourceengineTileLayer.js, line 226Returns:Type: TileLayerDatagetMirrorSign() → {Number}Get the direction of the mirrorOverridesEngineObject#getMirrorSignSourceengineObject.js, line 381Returns:-1 if this.mirror is true, or 1 if not mirroredType: NumberlocalToWorld(pos)Convert from local space to world spaceParameters:NameTypeDescriptionposVector2local space pointOverridesEngineObject#localToWorldSourceengineObject.js, line 341localToWorldVector(vec)Convert from local space to world space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2local space vectorOverridesEngineObject#localToWorldVectorSourceengineObject.js, line 349redraw()Draw all the tile data to an offscreen canvasThis may be slow in some browsers but only needs to be done onceSourceengineTileLayer.js, line 251redrawEnd()Call to end the redraw processSourceengineTileLayer.js, line 292redrawStart(clearopt)Call to start the redraw processThis can be used to manually update small parts of the levelParameters:NameTypeAttributesDefaultDescriptionclearBoolean<optional>falseShould it clear the canvas before drawingSourceengineTileLayer.js, line 263removeChild(child)Removes a child from this oneParameters:NameTypeDescriptionchildEngineObjectOverridesEngineObject#removeChildSourceengineObject.js, line 398render()Render the object, draws a tile by default, automatically called each frame, sorted by renderOrderOverridesEngineObject#renderSourceengineObject.js, line 320renderDebugInfo()Render debug info for this objectOverridesEngineObject#renderDebugInfoSourceengineObject.js, line 442setCollision(collideSolidObjectsopt, isSolidopt, collideTilesopt, collideRaycastopt)Set how this object collidesParameters:NameTypeAttributesDefaultDescriptioncollideSolidObjectsBoolean<optional>trueDoes it collide with solid objects?isSolidBoolean<optional>trueDoes it collide with and block other objects? (expensive in large numbers)collideTilesBoolean<optional>trueDoes it collide with the tile collision?collideRaycastBoolean<optional>trueDoes it collide with raycasts?OverridesEngineObject#setCollisionSourceengineObject.js, line 410setData(layerPos, data, redrawopt)Set data at a given position in the arrayParameters:NameTypeAttributesDefaultDescriptionlayerPosVector2Local position in arraydataTileLayerDataData to setredrawBoolean<optional>falseForce the tile to redraw if trueSourceengineTileLayer.js, line 214toString() → {String}Returns string containing info about this object for debuggingOverridesEngineObject#toStringSourceengineObject.js, line 422Returns:Type: Stringupdate()Update the object physics, called automatically by engine once each frameOverridesEngineObject#updateSourceengineObject.js, line 131updateTransforms()Update the object transform, called automatically by engine even when pausedOverridesEngineObject#updateTransformsSourceengineObject.js, line 114worldToLocal(pos)Convert from world space to local spaceParameters:NameTypeDescriptionposVector2world space pointOverridesEngineObject#worldToLocalSourceengineObject.js, line 345worldToLocalVector(vec)Convert from world space to local space for a vector (rotation only)Parameters:NameTypeDescriptionvecVector2world space vectorOverridesEngineObject#worldToLocalVectorSourceengineObject.js, line 353",https://killedbyapixel.github.io/LittleJS/docs/TileLayer.html
Class: TileLayerData,"TileLayerDataTile layer data object stores info about how to render a tileConstructornew TileLayerData(tileopt, directionopt, mirroropt, coloropt)Create a tile layer data object, one for each tile in a TileLayerParameters:NameTypeAttributesDefaultDescriptiontileNumber<optional>The tile to use, untextured if undefineddirectionNumber<optional>0Integer direction of tile, in 90 degree incrementsmirrorBoolean<optional>falseIf the tile should be mirrored along the x axiscolorColor<optional>Color of the tileSourceengineTileLayer.js, line 136Example// create tile layer data with tile index 0 and random orientation and color const tileIndex = 0; const direction = randInt(4) const mirror = randInt(2); const color = randColor(); const data = new TileLayerData(tileIndex, direction, mirror, color);MemberscolorPropertiesTypeDescriptionColorColor of the tileSourceengineTileLayer.js, line 152directionPropertiesTypeDescriptionNumberInteger direction of tile, in 90 degree incrementsSourceengineTileLayer.js, line 148mirrorPropertiesTypeDescriptionBooleanIf the tile should be mirrored along the x axisSourceengineTileLayer.js, line 150tilePropertiesTypeDescriptionNumberThe tile to use, untextured if undefinedSourceengineTileLayer.js, line 146Methodsclear()Set this tile to clear, it will not be renderedSourceengineTileLayer.js, line 156",https://killedbyapixel.github.io/LittleJS/docs/TileLayerData.html
Class: Timer,"TimerTimer object tracks how long has passed since it was setConstructornew Timer(timeLeftopt)Create a timer object set time passed inParameters:NameTypeAttributesDescriptiontimeLeftNumber<optional>How much time left before the timer elapses in secondsSourceengineUtilities.js, line 886Examplelet a = new Timer; // creates a timer that is not set a.set(3); // sets the timer to 3 seconds let b = new Timer(1); // creates a timer with 1 second left b.unset(); // unset the timerMethodsactive() → {Boolean}Returns true if set and has not elapsedSourceengineUtilities.js, line 905Returns:Type: Booleanelapsed() → {Boolean}Returns true if set and elapsedSourceengineUtilities.js, line 909Returns:Type: Booleanget() → {Number}Get how long since elapsed, returns 0 if not set (returns negative if currently active)SourceengineUtilities.js, line 913Returns:Type: NumbergetPercent() → {Number}Get percentage elapsed based on time it was set to, returns 0 if not setSourceengineUtilities.js, line 917Returns:Type: NumberisSet() → {Boolean}Returns true if setSourceengineUtilities.js, line 901Returns:Type: Booleanset(timeLeftopt)Set the timer with seconds passed inParameters:NameTypeAttributesDefaultDescriptiontimeLeftNumber<optional>0How much time left before the timer is elapsed in secondsSourceengineUtilities.js, line 894toString() → {String}Returns this timer expressed as a stringSourceengineUtilities.js, line 921Returns:Type: Stringunset()Unset the timerSourceengineUtilities.js, line 897valueOf() → {Number}Get how long since elapsed, returns 0 if not set (returns negative if currently active)SourceengineUtilities.js, line 925Returns:Type: Number",https://killedbyapixel.github.io/LittleJS/docs/Timer.html
Class: Vector2,"Vector22D Vector object with vector math libraryFunctions do not change this so they can be chained togetherConstructornew Vector2(xopt, yopt)Create a 2D vector with the x and y passed in, can also be created with vec2()Parameters:NameTypeAttributesDefaultDescriptionxNumber<optional>0X axis locationyNumber<optional>0Y axis locationSourceengineUtilities.js, line 327Examplelet a = new Vector2(2, 3); // vector with coordinates (2, 3) let b = new Vector2; // vector with coordinates (0, 0) let c = vec2(4, 2); // use the vec2 function to make a Vector2 let d = a.add(b).scale(5); // operators can be chainedMembersxPropertiesTypeDescriptionNumberX axis locationSourceengineUtilities.js, line 335yPropertiesTypeDescriptionNumberY axis locationSourceengineUtilities.js, line 337Methodsadd(v) → {Vector2}Returns a copy of this vector plus the vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 360Returns:Type: Vector2angle() → {Number}Returns the angle of this vector, up is angle 0SourceengineUtilities.js, line 466Returns:Type: Numberarea() → {Number}Returns the area this vector covers as a rectangleSourceengineUtilities.js, line 514Returns:Type: NumberarrayCheck(arraySize) → {Boolean}Returns true if this vector is within the bounds of an array size passed inParameters:NameTypeDescriptionarraySizeVector2SourceengineUtilities.js, line 529Returns:Type: BooleanclampLength(lengthopt) → {Vector2}Returns a new vector clamped to length passed inParameters:NameTypeAttributesDefaultDescriptionlengthNumber<optional>1SourceengineUtilities.js, line 440Returns:Type: Vector2copy() → {Vector2}Returns a new vector that is a copy of thisSourceengineUtilities.js, line 355Returns:Type: Vector2cross(v) → {Number}Returns the cross product of this and the vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 458Returns:Type: Numberdirection() → {Number}Returns the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)SourceengineUtilities.js, line 501Returns:Type: Numberdistance(v) → {Number}Returns the distance from this vector to vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 413Returns:Type: NumberdistanceSquared(v) → {Number}Returns the distance squared from this vector to vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 422Returns:Type: Numberdivide(v) → {Vector2}Returns a copy of this vector divided by the vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 387Returns:Type: Vector2dot(v) → {Number}Returns the dot product of this and the vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 449Returns:Type: Numberfloor() → {Vector2}Returns a copy of this vector with each axis flooredSourceengineUtilities.js, line 510Returns:Type: Vector2invert() → {Vector2}Returns a copy of this vector that has been invertedSourceengineUtilities.js, line 506Returns:Type: Vector2isValid() → {Boolean}Checks if this is a valid vectorSourceengineUtilities.js, line 546Returns:Type: Booleanlength() → {Number}Returns the length of this vectorSourceengineUtilities.js, line 404Returns:Type: NumberlengthSquared() → {Number}Returns the length of this vector squaredSourceengineUtilities.js, line 408Returns:Type: Numberlerp(v, percent) → {Vector2}Returns a new vector that is p percent between this and the vector passed inParameters:NameTypeDescriptionvVector2other vectorpercentNumberSourceengineUtilities.js, line 520Returns:Type: Vector2multiply(v) → {Vector2}Returns a copy of this vector times the vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 378Returns:Type: Vector2normalize(lengthopt) → {Vector2}Returns a new vector in same direction as this one with the length passed inParameters:NameTypeAttributesDefaultDescriptionlengthNumber<optional>1SourceengineUtilities.js, line 431Returns:Type: Vector2rotate(angle) → {Vector2}Returns copy of this vector rotated by the angle passed inParameters:NameTypeDescriptionangleNumberSourceengineUtilities.js, line 482Returns:Type: Vector2scale(s) → {Vector2}Returns a copy of this vector scaled by the vector passed inParameters:NameTypeDescriptionsNumberscaleSourceengineUtilities.js, line 396Returns:Type: Vector2set(xopt, yopt) → {Vector2}Sets values of this vector and returns selfParameters:NameTypeAttributesDefaultDescriptionxNumber<optional>0X axis locationyNumber<optional>0Y axis locationSourceengineUtilities.js, line 345Returns:Type: Vector2setAngle(angleopt, lengthopt) → {Vector2}Sets this vector with angle and length passed inParameters:NameTypeAttributesDefaultDescriptionangleNumber<optional>0lengthNumber<optional>1SourceengineUtilities.js, line 472Returns:Type: Vector2setDirection(directionopt, lengthopt)Set the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)Parameters:NameTypeAttributesDefaultDescriptiondirectionNumber<optional>lengthNumber<optional>1SourceengineUtilities.js, line 491subtract(v) → {Vector2}Returns a copy of this vector minus the vector passed inParameters:NameTypeDescriptionvVector2other vectorSourceengineUtilities.js, line 369Returns:Type: Vector2toString(digits) → {String}Returns this vector expressed as a stringParameters:NameTypeDefaultDescriptiondigitsNumber3precision to displaySourceengineUtilities.js, line 538Returns:Type: String",https://killedbyapixel.github.io/LittleJS/docs/Vector2.html
Namespace: Audio,"AudioLittleJS Audio SystemZzFX Sound Effects - ZzFX Sound Effect GeneratorZzFXM Music - ZzFXM Music SystemCaches sounds and music for fast playbackCan attenuate and apply stereo panning to soundsAbility to play mp3, ogg, and wave filesSpeech synthesis functionsSourceengineAudio.js, line 1Members(static) audioContext :AudioContextAudio context used by the engineType:AudioContextSourceengineAudio.js, line 17(static) audioGainNode :GainNodeMaster gain node for all audio to pass throughType:GainNodeSourceengineAudio.js, line 22(static, constant) zzfxRSample rate used for all ZzFX soundsDefault Value44100SourceengineAudio.js, line 368Methods(static) getNoteFrequency(semitoneOffset, rootFrequencyopt) → {Number}Get frequency of a note on a musical scaleParameters:NameTypeAttributesDefaultDescriptionsemitoneOffsetNumberHow many semitones away from the root noterootFrequencyNumber<optional>220Frequency at semitone offset 0SourceengineAudio.js, line 301Returns:The frequency of the noteType: Number(static) playAudioFile(filename, volumeopt, loopopt) → {SoundWave}Play an mp3, ogg, or wav audio from a local file or urlParameters:NameTypeAttributesDefaultDescriptionfilenameStringLocation of sound file to playvolumeNumber<optional>1How much to scale volume byloopBoolean<optional>falseTrue if the music should loopSourceengineAudio.js, line 204Returns:The sound object for this fileType: SoundWave(static) playSamples(sampleChannels, volumeopt, rateopt, panopt, loopopt, sampleRateopt, gainNodeopt) → {AudioBufferSourceNode}Play cached audio samples with given settingsParameters:NameTypeAttributesDefaultDescriptionsampleChannelsArrayArray of arrays of samples to play (for stereo playback)volumeNumber<optional>1How much to scale volume byrateNumber<optional>1The playback rate to usepanNumber<optional>0How much to apply stereo panningloopBoolean<optional>falseTrue if the sound should loop when it reaches the endsampleRateNumber<optional>44100Sample rate for the soundgainNodeGainNode<optional>Optional gain node for volume control while playingSourceengineAudio.js, line 316Returns:The audio node of the sound playedType: AudioBufferSourceNode(static) speak(text, languageopt, volumeopt, rateopt, pitchopt) → {SpeechSynthesisUtterance}Speak text with passed in settingsParameters:NameTypeAttributesDefaultDescriptiontextStringThe text to speaklanguageString<optional>The language/accent to use (examples: en, it, ru, ja, zh)volumeNumber<optional>1How much to scale volume byrateNumber<optional>1How quickly to speakpitchNumber<optional>1How much to change the pitch bySourceengineAudio.js, line 273Returns:The utterance that was spokenType: SpeechSynthesisUtterance(static) speakStop()Stop all queued speechSourceengineAudio.js, line 294(static) zzfx(…zzfxSound) → {AudioBufferSourceNode}Generate and play a ZzFX soundCreate sounds using the ZzFX Sound Designer.Parameters:NameTypeAttributesDescriptionzzfxSoundArray<repeatable>Array of ZzFX parameters, ex. [.5,.5]SourceengineAudio.js, line 363Returns:The audio node of the sound playedType: AudioBufferSourceNode(static) zzfxG(volumeopt, randomnessopt, frequencyopt, attackopt, sustainopt, releaseopt, shapeopt, shapeCurveopt, slideopt, deltaSlideopt, pitchJumpopt, pitchJumpTimeopt, repeatTimeopt, noiseopt, modulationopt, bitCrushopt, delayopt, sustainVolumeopt, decayopt, tremoloopt, filteropt) → {Array}Generate samples for a ZzFX soundParameters:NameTypeAttributesDefaultDescriptionvolumeNumber<optional>1Volume scale (percent)randomnessNumber<optional>0.05How much to randomize frequency (percent Hz)frequencyNumber<optional>220Frequency of sound (Hz)attackNumber<optional>0Attack time, how fast sound starts (seconds)sustainNumber<optional>0Sustain time, how long sound holds (seconds)releaseNumber<optional>0.1Release time, how fast sound fades out (seconds)shapeNumber<optional>0Shape of the sound waveshapeCurveNumber<optional>1Squareness of wave (0=square, 1=normal, 2=pointy)slideNumber<optional>0How much to slide frequency (kHz/s)deltaSlideNumber<optional>0How much to change slide (kHz/s/s)pitchJumpNumber<optional>0Frequency of pitch jump (Hz)pitchJumpTimeNumber<optional>0Time of pitch jump (seconds)repeatTimeNumber<optional>0Resets some parameters periodically (seconds)noiseNumber<optional>0How much random noise to add (percent)modulationNumber<optional>0Frequency of modulation wave, negative flips phase (Hz)bitCrushNumber<optional>0Resamples at a lower frequency in (samples*100)delayNumber<optional>0Overlap sound with itself for reverb and flanger effects (seconds)sustainVolumeNumber<optional>1Volume level for sustain (percent)decayNumber<optional>0Decay time, how long to reach sustain after attack (seconds)tremoloNumber<optional>0Trembling effect, rate controlled by repeat time (percent)filterNumber<optional>0Filter cutoff frequency, positive for HPF, negative for LPF (Hz)SourceengineAudio.js, line 395Returns:Array of audio samplesType: Array(static) zzfxM(instruments, patterns, sequence, BPMopt) → {Array}Generate samples for a ZzFM song with given parametersParameters:NameTypeAttributesDefaultDescriptioninstrumentsArrayArray of ZzFX sound parameterspatternsArrayArray of pattern datasequenceArrayArray of pattern indexesBPMNumber<optional>125Playback speed of the song in BPMSourceengineAudio.js, line 500Returns:Left and right channel sample dataType: Array",https://killedbyapixel.github.io/LittleJS/docs/Audio.html
Namespace: Debug,"DebugLittleJS Debug SystemPress Esc to show debug overlay with mouse pickNumber keys toggle debug functions+/- apply time scaleDebug primitive renderingSave a 2d canvas as a png imageSourceengineDebug.js, line 1Members(static, constant) debug :BooleanTrue if debug is enabledType:BooleanDefault ValuetrueSourceengineDebug.js, line 17(static) debugKey :StringKey code used to toggle debug mode, Esc by defaultType:StringDefault ValueEscapeSourceengineDebug.js, line 41(static) debugOverlay :BooleanTrue if the debug overlay is active, always false in release buildsType:BooleanSourceengineDebug.js, line 47(static, constant) debugPointSize :NumberSize to render debug points by defaultType:NumberDefault Value0.5SourceengineDebug.js, line 29(static, constant) enableAsserts :BooleanTrue if asserts are enabledType:BooleanDefault ValuetrueSourceengineDebug.js, line 23(static) showWatermark :BooleanTrue if watermark with FPS should be shown, false in release buildsType:BooleanDefault ValuetrueSourceengineDebug.js, line 35Methods(static) ASSERT(assert, outputopt)Asserts if the expression is false, does not do anything in release buildsParameters:NameTypeAttributesDescriptionassertBooleanoutputObject<optional>SourceengineDebug.js, line 59(static) debugCircle(pos, radiusopt, coloropt, timeopt, fillopt)Draw a debug circle in world spaceParameters:NameTypeAttributesDefaultDescriptionposVector2radiusNumber<optional>0colorString<optional>#ffftimeNumber<optional>0fillBoolean<optional>falseSourceengineDebug.js, line 100(static) debugClear()Clear all debug primitives in the listSourceengineDebug.js, line 163(static) debugLine(posA, posB, coloropt, thicknessopt, timeopt)Draw a debug line in world spaceParameters:NameTypeAttributesDefaultDescriptionposAVector2posBVector2colorString<optional>thicknessNumber<optional>0.1timeNumber<optional>SourceengineDebug.js, line 125(static) debugOverlap(pA, sA, pB, sB, coloropt)Draw a debug combined axis aligned bounding box in world spaceParameters:NameTypeAttributesDescriptionpAVector2position AsAVector2size ApBVector2position BsBVector2size BcolorString<optional>SourceengineDebug.js, line 139(static) debugPoint(pos, coloropt, timeopt, angleopt)Draw a debug point in world spaceParameters:NameTypeAttributesDescriptionposVector2colorString<optional>timeNumber<optional>angleNumber<optional>SourceengineDebug.js, line 112(static) debugPoly(pos, points, coloropt, timeopt, angleopt, fillopt)Draw a debug poly in world spaceParameters:NameTypeAttributesDefaultDescriptionposVector2pointsArraycolorString<optional>#ffftimeNumber<optional>0angleNumber<optional>0fillBoolean<optional>falseSourceengineDebug.js, line 87(static) debugRect(pos, sizeopt, coloropt, timeopt, angleopt, fillopt)Draw a debug rectangle in world spaceParameters:NameTypeAttributesDefaultDescriptionposVector2sizeVector2<optional>Vector2()colorString<optional>#ffftimeNumber<optional>0angleNumber<optional>0fillBoolean<optional>falseSourceengineDebug.js, line 73(static) debugSaveCanvas(canvas, filenameopt, typeopt)Save a canvas to diskParameters:NameTypeAttributesDefaultDescriptioncanvasHTMLCanvasElementfilenameString<optional>screenshottypeString<optional>image/pngSourceengineDebug.js, line 170(static) debugSaveDataURL(dataURL, filename)Save a data url to diskParameters:NameTypeDescriptiondataURLStringfilenameStringSourceengineDebug.js, line 185(static) debugSaveText(text, filenameopt, typeopt)Save a text file to diskParameters:NameTypeAttributesDefaultDescriptiontextStringfilenameString<optional>texttypeString<optional>text/plainSourceengineDebug.js, line 178(static) debugShowErrors()Show error as full page of red textSourceengineDebug.js, line 194(static) debugText(text, pos, sizeopt, coloropt, timeopt, angleopt, fontopt)Draw a debug axis aligned bounding box in world spaceParameters:NameTypeAttributesDefaultDescriptiontextStringposVector2sizeNumber<optional>1colorString<optional>#ffftimeNumber<optional>0angleNumber<optional>0fontString<optional>monospaceSourceengineDebug.js, line 155(static) setDebugKey(key)Set key code used to toggle debug mode, Esc by defaultParameters:NameTypeDescriptionkeyStringSourceengineSettings.js, line 493(static) setShowWatermark(show)Set if watermark with FPS should be shownParameters:NameTypeDescriptionshowBooleanSourceengineSettings.js, line 488",https://killedbyapixel.github.io/LittleJS/docs/Debug.html
Namespace: Draw,"DrawLittleJS Drawing SystemHybrid system with both Canvas2D and WebGL availableSuper fast tile sheet rendering with WebGLCan apply rotation, mirror, color and additive colorFont rendering system with built in engine fontMany useful utility functionsLittleJS uses a hybrid rendering solution with the best of both Canvas2D and WebGL. There are 3 canvas/contexts available to draw to... mainCanvas - 2D background canvas, non WebGL stuff like tile layers are drawn here. glCanvas - Used by the accelerated WebGL batch rendering system. overlayCanvas - Another 2D canvas that appears on top of the other 2 canvases.The WebGL rendering system is very fast with some caveats...Switching blend modes (additive) or textures causes another draw call which is expensive in excessGroup additive rendering together using renderOrder to mitigate this issueThe LittleJS rendering solution is intentionally simple, feel free to adjust it for your needs!SourceengineDraw.js, line 1Members(static) mainCanvas :HTMLCanvasElementThe primary 2D canvas visible to the userType:HTMLCanvasElementSourceengineDraw.js, line 28(static) mainCanvasSize :Vector2The size of the main canvas (and other secondary canvases)Type:Vector2SourceengineDraw.js, line 48(static) mainContext :CanvasRenderingContext2D2d context for mainCanvasType:CanvasRenderingContext2DSourceengineDraw.js, line 33(static) overlayCanvas :HTMLCanvasElementA canvas that appears on top of everything the same size as mainCanvasType:HTMLCanvasElementSourceengineDraw.js, line 38(static) overlayContext :CanvasRenderingContext2D2d context for overlayCanvasType:CanvasRenderingContext2DSourceengineDraw.js, line 43(static) textureInfos :Array.<TextureInfo>Array containing texture info for batch rendering systemType:Array.<TextureInfo>SourceengineDraw.js, line 53Methods(static) drawCanvas2D(pos, size, angle, mirror, drawFunction, screenSpaceopt, contextopt)Draw directly to a 2d canvas context in world spaceParameters:NameTypeAttributesDefaultDescriptionposVector2sizeVector2angleNumbermirrorBooleandrawFunctionfunctionscreenSpaceBoolean<optional>falsecontextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>mainContextSourceengineDraw.js, line 384(static) drawCircle(pos, radiusopt, coloropt, lineWidthopt, lineColoropt, screenSpaceopt, contextopt)Draw colored circle using passed in pointParameters:NameTypeAttributesDefaultDescriptionposVector2radiusNumber<optional>1colorColor<optional>(1,1,1,1)lineWidthNumber<optional>0lineColorColor<optional>(0,0,0,1)screenSpaceBoolean<optional>falsecontextCanvasRenderingContext2D<optional>mainContextSourceengineDraw.js, line 372(static) drawEllipse(pos, widthopt, heightopt, angleopt, coloropt, lineWidthopt, lineColoropt, screenSpaceopt, contextopt)Draw colored ellipse using passed in pointParameters:NameTypeAttributesDefaultDescriptionposVector2widthNumber<optional>1heightNumber<optional>1angleNumber<optional>0colorColor<optional>(1,1,1,1)lineWidthNumber<optional>0lineColorColor<optional>(0,0,0,1)screenSpaceBoolean<optional>falsecontextCanvasRenderingContext2D<optional>mainContextSourceengineDraw.js, line 342(static) drawLine(posA, posB, thicknessopt, coloropt, useWebGLopt, screenSpaceopt, contextopt)Draw colored line between two pointsParameters:NameTypeAttributesDefaultDescriptionposAVector2posBVector2thicknessNumber<optional>0.1colorColor<optional>(1,1,1,1)useWebGLBoolean<optional>glEnablescreenSpaceBoolean<optional>falsecontextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>SourceengineDraw.js, line 300(static) drawPoly(points, coloropt, lineWidthopt, lineColoropt, screenSpaceopt, contextopt)Draw colored polygon using passed in pointsParameters:NameTypeAttributesDefaultDescriptionpointsArrayArray of Vector2 pointscolorColor<optional>(1,1,1,1)lineWidthNumber<optional>0lineColorColor<optional>(0,0,0,1)screenSpaceBoolean<optional>falsecontextCanvasRenderingContext2D<optional>mainContextSourceengineDraw.js, line 315(static) drawRect(pos, sizeopt, coloropt, angleopt, useWebGLopt, screenSpaceopt, contextopt)Draw colored rect centered on posParameters:NameTypeAttributesDefaultDescriptionposVector2sizeVector2<optional>(1,1)colorColor<optional>(1,1,1,1)angleNumber<optional>useWebGLBoolean<optional>glEnablescreenSpaceBoolean<optional>falsecontextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>SourceengineDraw.js, line 286(static) drawText(text, pos, sizeopt, coloropt, lineWidthopt, lineColoropt, textAlignopt, fontopt, maxWidthopt, contextopt)Draw text on main canvas in world space Automatically splits new lines into rowsParameters:NameTypeAttributesDefaultDescriptiontextStringposVector2sizeNumber<optional>1colorColor<optional>(1,1,1,1)lineWidthNumber<optional>0lineColorColor<optional>(0,0,0,1)textAlignCanvasTextAlign<optional>'center'fontString<optional>fontDefaultmaxWidthNumber<optional>contextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>mainContextSourceengineDraw.js, line 431(static) drawTextOverlay(text, pos, sizeopt, coloropt, lineWidthopt, lineColoropt, textAlignopt, fontopt, maxWidthopt)Draw text on overlay canvas in world space Automatically splits new lines into rowsParameters:NameTypeAttributesDefaultDescriptiontextStringposVector2sizeNumber<optional>1colorColor<optional>(1,1,1,1)lineWidthNumber<optional>0lineColorColor<optional>(0,0,0,1)textAlignCanvasTextAlign<optional>'center'fontString<optional>fontDefaultmaxWidthNumber<optional>SourceengineDraw.js, line 448(static) drawTextScreen(text, pos, sizeopt, coloropt, lineWidthopt, lineColoropt, textAlignopt, fontopt, maxWidthopt, contextopt)Draw text on overlay canvas in screen space Automatically splits new lines into rowsParameters:NameTypeAttributesDefaultDescriptiontextStringposVector2sizeNumber<optional>1colorColor<optional>(1,1,1,1)lineWidthNumber<optional>0lineColorColor<optional>(0,0,0,1)textAlignCanvasTextAlign<optional>centerfontString<optional>fontDefaultmaxWidthNumber<optional>contextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>overlayContextSourceengineDraw.js, line 466(static) drawTile(pos, sizeopt, tileInfoopt, coloropt, angleopt, mirroropt, additiveColoropt, useWebGLopt, screenSpaceopt, contextopt)Draw textured tile centered in world space, with color applied if using WebGLParameters:NameTypeAttributesDefaultDescriptionposVector2Center of the tile in world spacesizeVector2<optional>(1,1)Size of the tile in world spacetileInfoTileInfo<optional>Tile info to use, untextured if undefinedcolorColor<optional>(1,1,1,1)Color to modulate withangleNumber<optional>0Angle to rotate bymirrorBoolean<optional>If true image is flipped along the Y axisadditiveColorColor<optional>(0,0,0,0)Additive color to be applieduseWebGLBoolean<optional>glEnableUse accelerated WebGL renderingscreenSpaceBoolean<optional>falseIf true the pos and size are in screen spacecontextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>Canvas 2D context to draw toSourceengineDraw.js, line 211(static) getCameraSize() → {Vector2}Get the camera's visible area in world spaceSourceengineDraw.js, line 197Returns:Type: Vector2(static) isFullscreen() → {Boolean}Returns true if fullscreen mode is activeSourceengineDraw.js, line 576Returns:Type: Boolean(static) screenToWorld(screenPos) → {Vector2}Convert from screen to world space coordinatesParameters:NameTypeDescriptionscreenPosVector2SourceengineDraw.js, line 172Returns:Type: Vector2(static) setBlendMode(additiveopt, useWebGLopt, contextopt)Enable normal or additive blend modeParameters:NameTypeAttributesDefaultDescriptionadditiveBoolean<optional>useWebGLBoolean<optional>glEnablecontextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2D<optional>mainContextSourceengineDraw.js, line 405(static) setCursor(cursorStyle)Set the cursor styleParameters:NameTypeDefaultDescriptioncursorStyleStringautoCSS cursor style (auto, none, crosshair, etc)SourceengineDraw.js, line 595(static) tile(posopt, sizeopt, textureIndexopt, paddingopt) → {TileInfo}Create a tile info object using a grid based systemThis can take vecs or floats for easier use and conversionIf an index is passed in, the tile size and index will determine the positionParameters:NameTypeAttributesDefaultDescriptionposNumber | Vector2<optional>0Index of tile in sheetsizeNumber | Vector2<optional>tileSizeDefaultSize of tile in pixelstextureIndexNumber<optional>0Texture index to usepaddingNumber<optional>0How many pixels padding around tilesSourceengineDraw.js, line 76Returns:Type: TileInfoExampletile(2) // a tile at index 2 using the default tile size of 16 tile(5, 8) // a tile at index 5 using a tile size of 8 tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3 tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)(static) toggleFullscreen()Toggle fullscreen modeSourceengineDraw.js, line 580(static) worldToScreen(worldPos) → {Vector2}Convert from world to screen space coordinatesParameters:NameTypeDescriptionworldPosVector2SourceengineDraw.js, line 185Returns:Type: Vector2",https://killedbyapixel.github.io/LittleJS/docs/Draw.html
Namespace: Engine,"EngineLittleJS - The Tiny Fast JavaScript Game Engine MIT License - Copyright 2021 Frank ForceEngine FeaturesObject oriented system with base class engine objectBase class object handles update, physics, collision, rendering, etcEngine helper classes and functions like Vector2, Color, and TimerSuper fast rendering system for tile sheetsSound effects audio with zzfx and music with zzfxmInput processing system with gamepad and touchscreen supportTile layer rendering and collision systemParticle effect systemMedal system tracks and displays achievementsDebug tools and debug rendering systemPost processing effectsCall engineInit() to start it up!Sourceengine.js, line 1Members(static, constant) engineName :StringName of engineType:StringDefault ValueLittleJSSourceengine.js, line 27(static) engineObjects :ArrayArray containing all engine objectsType:ArraySourceengine.js, line 50(static) engineObjectsCollide :ArrayArray with only objects set to collide with other objects this frame (for optimization)Type:ArraySourceengine.js, line 55(static, constant) engineVersion :StringVersion of engineType:StringDefault Value1.11.3Sourceengine.js, line 33(static) frame :NumberCurrent update frame, used to calculate timeType:NumberSourceengine.js, line 60(static, constant) frameRate :NumberFrames per second to updateType:NumberDefault Value60Sourceengine.js, line 39(static) paused :BooleanIs the game paused? Causes time and objects to not be updatedType:BooleanDefault ValuefalseSourceengine.js, line 76(static) time :NumberCurrent engine time since start in secondsType:NumberSourceengine.js, line 65(static, constant) timeDelta :NumberHow many seconds each frame lasts, engine uses a fixed time stepType:NumberDefault Value1/60Sourceengine.js, line 45(static) timeReal :NumberActual clock time since start in seconds (not affected by pause or frame rate clamping)Type:NumberSourceengine.js, line 70Methods(static) engineAddPlugin(updateFunctionopt, renderFunctionopt)Add a new update function for a pluginParameters:NameTypeAttributesDescriptionupdateFunctionfunction<optional>renderFunctionfunction<optional>Sourceengine.js, line 94(static) engineInit(gameInit, gameUpdate, gameUpdatePost, gameRender, gameRenderPost, imageSourcesopt, rootElementopt)Startup LittleJS engine with your callback functionsParameters:NameTypeAttributesDefaultDescriptiongameInitfunction | functionCalled once after the engine starts upgameUpdatefunctionCalled every frame before objects are updatedgameUpdatePostfunctionCalled after physics and objects are updated, even when pausedgameRenderfunctionCalled before objects are rendered, for drawing the backgroundgameRenderPostfunctionCalled after objects are rendered, useful for drawing UIimageSourcesArray<optional>[]List of images to loadrootElementHTMLElement<optional>Root element to attach to, the document body by defaultSourceengine.js, line 114(static) engineObjectsCallback(posopt, sizeopt, callbackFunctionopt, objectsopt)Triggers a callback for each object within a given areaParameters:NameTypeAttributesDefaultDescriptionposVector2<optional>Center of test area, or undefined for all objectssizeNumber | Vector2<optional>Radius of circle if float, rectangle size if Vector2callbackFunctionfunction<optional>Calls this function on every object that passes the testobjectsArray<optional>engineObjectsList of objects to checkSourceengine.js, line 426(static) engineObjectsCollect(posopt, sizeopt, objectsopt) → {Array}Collects all object within a given areaParameters:NameTypeAttributesDefaultDescriptionposVector2<optional>Center of test area, or undefined for all objectssizeNumber | Vector2<optional>Radius of circle if float, rectangle size if Vector2objectsArray<optional>engineObjectsList of objects to checkSourceengine.js, line 398Returns:List of collected objectsType: Array(static) engineObjectsDestroy()Destroy and remove all objectsSourceengine.js, line 385(static) engineObjectsRaycast(start, end, objectsopt) → {Array}Return a list of objects intersecting a rayParameters:NameTypeAttributesDefaultDescriptionstartVector2endVector2objectsArray<optional>engineObjectsList of objects to checkSourceengine.js, line 435Returns:List of objects hitType: Array(static) engineObjectsUpdate()Update each engine object, remove destroyed objects, and update timeSourceengine.js, line 354(static) setPaused(isPaused)Set if game is pausedParameters:NameTypeDescriptionisPausedBooleanSourceengine.js, line 80",https://killedbyapixel.github.io/LittleJS/docs/Engine.html
Namespace: Input,"InputLittleJS Input SystemTracks keyboard down, pressed, and releasedTracks mouse buttons, position, and wheelTracks multiple analog gamepadsTouch input is handled as mouse inputVirtual gamepad for touch devicesSourceengineInput.js, line 1Members(static, constant) isTouchDeviceTrue if a touch device has been detectedSourceengineInput.js, line 344(static) isUsingGamepad :BooleanReturns true if user is using gamepad (has more recently pressed a gamepad button)Type:BooleanSourceengineInput.js, line 89(static) mousePos :Vector2Mouse pos in world spaceType:Vector2SourceengineInput.js, line 74(static) mousePosScreen :Vector2Mouse pos in screen spaceType:Vector2SourceengineInput.js, line 79(static) mouseWheel :NumberMouse wheel delta this frameType:NumberSourceengineInput.js, line 84(static) preventDefaultInput :BooleanPrevents input continuing to the default browser handling (false by default)Type:BooleanSourceengineInput.js, line 94Methods(static) clearInput()Clears all inputSourceengineInput.js, line 48(static) gamepadIsDown(button, gamepadopt) → {Boolean}Returns true if gamepad button is downParameters:NameTypeAttributesDefaultDescriptionbuttonNumbergamepadNumber<optional>0SourceengineInput.js, line 101Returns:Type: Boolean(static) gamepadStick(stick, gamepadopt) → {Vector2}Returns gamepad stick valueParameters:NameTypeAttributesDefaultDescriptionstickNumbergamepadNumber<optional>0SourceengineInput.js, line 125Returns:Type: Vector2(static) gamepadWasPressed(button, gamepadopt) → {Boolean}Returns true if gamepad button was pressedParameters:NameTypeAttributesDefaultDescriptionbuttonNumbergamepadNumber<optional>0SourceengineInput.js, line 109Returns:Type: Boolean(static) gamepadWasReleased(button, gamepadopt) → {Boolean}Returns true if gamepad button was releasedParameters:NameTypeAttributesDefaultDescriptionbuttonNumbergamepadNumber<optional>0SourceengineInput.js, line 117Returns:Type: Boolean(static) keyIsDown(key, deviceopt) → {Boolean}Returns true if device key is downParameters:NameTypeAttributesDefaultDescriptionkeyString | NumberdeviceNumber<optional>0SourceengineInput.js, line 18Returns:Type: Boolean(static) keyWasPressed(key, deviceopt) → {Boolean}Returns true if device key was pressed this frameParameters:NameTypeAttributesDefaultDescriptionkeyString | NumberdeviceNumber<optional>0SourceengineInput.js, line 29Returns:Type: Boolean(static) keyWasReleased(key, deviceopt) → {Boolean}Returns true if device key was released this frameParameters:NameTypeAttributesDefaultDescriptionkeyString | NumberdeviceNumber<optional>0SourceengineInput.js, line 40Returns:Type: Boolean(static) mouseIsDown(button) → {Boolean}Returns true if mouse button is downParameters:NameTypeDescriptionbuttonNumberSourceengineInput.js, line 55Returns:Type: Boolean(static) mouseWasPressed(button) → {Boolean}Returns true if mouse button was pressedParameters:NameTypeDescriptionbuttonNumberSourceengineInput.js, line 62Returns:Type: Boolean(static) mouseWasReleased(button) → {Boolean}Returns true if mouse button was releasedParameters:NameTypeDescriptionbuttonNumberSourceengineInput.js, line 69Returns:Type: Boolean(static) vibrate(patternopt)Pulse the vibration hardware if it existsParameters:NameTypeAttributesDefaultDescriptionpatternNumber | Array<optional>100single value in ms or vibration interval arraySourceengineInput.js, line 332(static) vibrateStop()Cancel any ongoing vibrationSourceengineInput.js, line 337",https://killedbyapixel.github.io/LittleJS/docs/Input.html
Namespace: Medals,"MedalsLittleJS Medal SystemTracks and displays medalsSaves medals to local storageNewgrounds integrationSourceengineMedals.js, line 1Members(static, constant) medals :ObjectList of all medalsType:ObjectSourceengineMedals.js, line 14Methods(static) medalsForEach(callback)Calls a function for each medalParameters:NameTypeDescriptioncallbackfunctionSourceengineMedals.js, line 65(static) medalsInit(saveName)Initialize medals with a save name used for storageCall this after creating all medalsChecks if medals are unlockedParameters:NameTypeDescriptionsaveNameStringSourceengineMedals.js, line 26",https://killedbyapixel.github.io/LittleJS/docs/Medals.html
Namespace: Random,"RandomRandom global functionsSourceengineUtilities.js, line 194Methods(static) rand(valueAopt, valueBopt) → {Number}Returns a random value between the two values passed inParameters:NameTypeAttributesDefaultDescriptionvalueANumber<optional>1valueBNumber<optional>0SourceengineUtilities.js, line 202Returns:Type: Number(static) randColor(colorAopt, colorBopt, linearopt) → {Color}Returns a random color between the two passed in colors, combine components if linearParameters:NameTypeAttributesDefaultDescriptioncolorAColor<optional>(1,1,1,1)colorBColor<optional>(0,0,0,1)linearBoolean<optional>falseSourceengineUtilities.js, line 237Returns:Type: Color(static) randInCircle(radiusopt, minRadiusopt) → {Vector2}Returns a random Vector2 within a circular shapeParameters:NameTypeAttributesDefaultDescriptionradiusNumber<optional>1minRadiusNumber<optional>0SourceengineUtilities.js, line 228Returns:Type: Vector2(static) randInt(valueA, valueBopt) → {Number}Returns a floored random value between the two values passed in The upper bound is exclusive. (If 2 is passed in, result will be 0 or 1)Parameters:NameTypeAttributesDefaultDescriptionvalueANumbervalueBNumber<optional>0SourceengineUtilities.js, line 210Returns:Type: Number(static) randSign() → {Number}Randomly returns either -1 or 1SourceengineUtilities.js, line 215Returns:Type: Number(static) randVector(lengthopt) → {Vector2}Returns a random Vector2 with the passed in lengthParameters:NameTypeAttributesDefaultDescriptionlengthNumber<optional>1SourceengineUtilities.js, line 221Returns:Type: Vector2",https://killedbyapixel.github.io/LittleJS/docs/Random.html
Namespace: Settings,"SettingsLittleJS Engine SettingsAll settings for the engine are hereSourceengineSettings.js, line 1Members(static) cameraPos :Vector2Position of camera in world spaceType:Vector2Default ValueVector2()SourceengineSettings.js, line 16(static) cameraScale :NumberScale of camera in world spaceType:NumberDefault Value32SourceengineSettings.js, line 22(static) canvasFixedSize :Vector2Fixed size of the canvas, if enabled canvas size never changesyou may also need to set mainCanvasSize if using screen space coords in startupType:Vector2Default ValueVector2()SourceengineSettings.js, line 38(static) canvasMaxSize :Vector2The max size of the canvas, centered if window is largerType:Vector2Default ValueVector2(1920,1080)SourceengineSettings.js, line 31(static) canvasPixelated :BooleanUse nearest neighbor scaling algorithm for canvas for more pixelated lookType:BooleanDefault ValuetrueSourceengineSettings.js, line 44(static) enablePhysicsSolver :BooleanEnable physics solver for collisions between objectsType:BooleanDefault ValuetrueSourceengineSettings.js, line 107(static) fontDefault :StringDefault font used for text renderingType:StringDefault ValuearialSourceengineSettings.js, line 56(static) gamepadDirectionEmulateStick :BooleanIf true, the dpad input is also routed to the left analog stick (for better accessability)Type:BooleanDefault ValuetrueSourceengineSettings.js, line 170(static) gamepadsEnable :BooleanShould gamepads be allowedType:BooleanDefault ValuetrueSourceengineSettings.js, line 164(static) glEnable :BooleanEnable webgl rendering, webgl can be disabled and removed from build (with some features disabled)Type:BooleanDefault ValuetrueSourceengineSettings.js, line 77(static) glOverlay :BooleanFixes slow rendering in some browsers by not compositing the WebGL canvasType:BooleanDefault ValuetrueSourceengineSettings.js, line 83(static) gravity :NumberHow much gravity to apply to objects along the Y axis, negative is downType:NumberSourceengineSettings.js, line 149(static) headlessMode :BooleanDisables all rendering, audio, and input for serversType:BooleanSourceengineSettings.js, line 68(static) inputWASDEmulateDirection :BooleanIf true the WASD keys are also routed to the direction keys (for better accessability)Type:BooleanDefault ValuetrueSourceengineSettings.js, line 176(static) medalDisplayIconSize :NumberSize of icon in medal displayType:NumberDefault Value50SourceengineSettings.js, line 269(static) medalDisplaySize :Vector2Size of medal displayType:Vector2Default ValueVector2(640,80)SourceengineSettings.js, line 263(static) medalDisplaySlideTime :NumberHow quickly to slide on/off medals in secondsType:NumberDefault Value0.5SourceengineSettings.js, line 257(static) medalDisplayTime :NumberHow long to show medals for in secondsType:NumberDefault Value5SourceengineSettings.js, line 251(static) medalsPreventUnlock :BooleanSet to stop medals from being unlockable (like if cheats are enabled)Type:BooleanSourceengineSettings.js, line 275(static) objectDefaultAngleDamping :NumberHow much to slow angular velocity each frame (0-1)Type:NumberDefault Value1SourceengineSettings.js, line 125(static) objectDefaultDamping :NumberHow much to slow velocity by each frame (0-1)Type:NumberDefault Value1SourceengineSettings.js, line 119(static) objectDefaultElasticity :NumberHow much to bounce when a collision occurs (0-1)Type:NumberSourceengineSettings.js, line 131(static) objectDefaultFriction :NumberHow much to slow when touching (0-1)Type:NumberDefault Value0.8SourceengineSettings.js, line 137(static) objectDefaultMass :NumberDefault object mass for collision calculations (how heavy objects are)Type:NumberDefault Value1SourceengineSettings.js, line 113(static) objectMaxSpeed :NumberClamp max speed to avoid fast objects missing collisionsType:NumberDefault Value1SourceengineSettings.js, line 143(static) particleEmitRateScale :NumberScales emit rate of particles, useful for low graphics mode (0 disables particle emitters)Type:NumberDefault Value1SourceengineSettings.js, line 155(static) showSplashScreen :BooleanEnable to show the LittleJS splash screen be shown on startupType:BooleanSourceengineSettings.js, line 62(static) soundDefaultRange :NumberDefault range where sound no longer playsType:NumberDefault Value40SourceengineSettings.js, line 236(static) soundDefaultTaper :NumberDefault range percent to start tapering off sound (0-1)Type:NumberDefault Value0.7SourceengineSettings.js, line 242(static) soundEnable :BooleanAll audio code can be disabled and removed from buildType:BooleanDefault ValuetrueSourceengineSettings.js, line 224(static) soundVolume :NumberVolume scale to apply to all sound, music and speechType:NumberDefault Value0.3SourceengineSettings.js, line 230(static) tileFixBleedScale :NumberHow many pixels smaller to draw tiles to prevent bleeding from neighborsType:NumberSourceengineSettings.js, line 98(static) tileSizeDefault :Vector2Default size of tiles in pixelsType:Vector2Default ValueVector2(16,16)SourceengineSettings.js, line 92(static) tilesPixelated :BooleanDisables texture filtering for crisper pixel artType:BooleanDefault ValuetrueSourceengineSettings.js, line 50(static) touchGamepadAlpha :NumberTransparency of touch gamepad overlayType:NumberDefault Value0.3SourceengineSettings.js, line 209(static) touchGamepadAnalog :BooleanTrue if touch gamepad should be analog stick or false to use if 8 way dpadType:BooleanDefault ValuetrueSourceengineSettings.js, line 197(static) touchGamepadEnable :BooleanTrue if touch gamepad should appear on mobile devicesSupports left analog stick, 4 face buttons and start button (button 9)Must be set by end of gameInit to be activatedType:BooleanSourceengineSettings.js, line 191(static) touchGamepadSize :NumberSize of virtual gamepad for touch devices in pixelsType:NumberDefault Value99SourceengineSettings.js, line 203(static) touchInputEnable :BooleanTrue if touch input is enabled for mobile devicesTouch events will be routed to mouse eventsType:BooleanDefault ValuetrueSourceengineSettings.js, line 183(static) vibrateEnable :BooleanAllow vibration hardware if it existsType:BooleanDefault ValuetrueSourceengineSettings.js, line 215Methods(static) setCameraPos(pos)Set position of camera in world spaceParameters:NameTypeDescriptionposVector2SourceengineSettings.js, line 283(static) setCameraScale(scale)Set scale of camera in world spaceParameters:NameTypeDescriptionscaleNumberSourceengineSettings.js, line 288(static) setCanvasFixedSize(size)Set fixed size of the canvasParameters:NameTypeDescriptionsizeVector2SourceengineSettings.js, line 298(static) setCanvasMaxSize(size)Set max size of the canvasParameters:NameTypeDescriptionsizeVector2SourceengineSettings.js, line 293(static) setCanvasPixelated(pixelated)Use nearest neighbor scaling algorithm for canvas for more pixelated lookParameters:NameTypeDescriptionpixelatedBooleanSourceengineSettings.js, line 303(static) setEnablePhysicsSolver(enable)Set if collisions between objects are enabledParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 348(static) setFontDefault(font)Set default font used for text renderingParameters:NameTypeDescriptionfontStringSourceengineSettings.js, line 313(static) setGamepadDirectionEmulateStick(enable)Set if the dpad input is also routed to the left analog stickParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 398(static) setGamepadsEnable(enable)Set if gamepads are enabledParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 393(static) setGlEnable(enable)Set if webgl rendering is enabledParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 328(static) setGlOverlay(overlay)Set to not composite the WebGL canvasParameters:NameTypeDescriptionoverlayBooleanSourceengineSettings.js, line 333(static) setGravity(newGravity)Set how much gravity to apply to objects along the Y axisParameters:NameTypeDescriptionnewGravityNumberSourceengineSettings.js, line 383(static) setHeadlessMode(headless)Set to disable rendering, audio, and input for serversParameters:NameTypeDescriptionheadlessBooleanSourceengineSettings.js, line 323(static) setInputWASDEmulateDirection(enable)Set if true the WASD keys are also routed to the direction keysParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 403(static) setMedalDisplayIconSize(size)Set size of icon in medal displayParameters:NameTypeDescriptionsizeNumberSourceengineSettings.js, line 478(static) setMedalDisplaySize(size)Set size of medal displayParameters:NameTypeDescriptionsizeVector2SourceengineSettings.js, line 473(static) setMedalDisplaySlideTime(time)Set how quickly to slide on/off medals in secondsParameters:NameTypeDescriptiontimeNumberSourceengineSettings.js, line 468(static) setMedalDisplayTime(time)Set how long to show medals for in secondsParameters:NameTypeDescriptiontimeNumberSourceengineSettings.js, line 463(static) setMedalsPreventUnlock(preventUnlock)Set to stop medals from being unlockableParameters:NameTypeDescriptionpreventUnlockBooleanSourceengineSettings.js, line 483(static) setObjectDefaultAngleDamping(damp)Set how much to slow angular velocity each frameParameters:NameTypeDescriptiondampNumberSourceengineSettings.js, line 363(static) setObjectDefaultDamping(damp)Set how much to slow velocity by each frameParameters:NameTypeDescriptiondampNumberSourceengineSettings.js, line 358(static) setObjectDefaultElasticity(elasticity)Set how much to bounce when a collision occurParameters:NameTypeDescriptionelasticityNumberSourceengineSettings.js, line 368(static) setObjectDefaultFriction(friction)Set how much to slow when touchingParameters:NameTypeDescriptionfrictionNumberSourceengineSettings.js, line 373(static) setObjectDefaultMass(mass)Set default object mass for collision calculationsParameters:NameTypeDescriptionmassNumberSourceengineSettings.js, line 353(static) setObjectMaxSpeed(speed)Set max speed to avoid fast objects missing collisionsParameters:NameTypeDescriptionspeedNumberSourceengineSettings.js, line 378(static) setParticleEmitRateScale(scale)Set to scales emit rate of particlesParameters:NameTypeDescriptionscaleNumberSourceengineSettings.js, line 388(static) setShowSplashScreen(show)Set if the LittleJS splash screen be shown on startupParameters:NameTypeDescriptionshowBooleanSourceengineSettings.js, line 318(static) setSoundDefaultRange(range)Set default range where sound no longer playsParameters:NameTypeDescriptionrangeNumberSourceengineSettings.js, line 453(static) setSoundDefaultTaper(taper)Set default range percent to start tapering off soundParameters:NameTypeDescriptiontaperNumberSourceengineSettings.js, line 458(static) setSoundEnable(enable)Set to disable all audio codeParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 438(static) setSoundVolume(volume)Set volume scale to apply to all sound, music and speechParameters:NameTypeDescriptionvolumeNumberSourceengineSettings.js, line 443(static) setTileFixBleedScale(scale)Set to prevent tile bleeding from neighbors in pixelsParameters:NameTypeDescriptionscaleNumberSourceengineSettings.js, line 343(static) setTileSizeDefault(size)Set default size of tiles in pixelsParameters:NameTypeDescriptionsizeVector2SourceengineSettings.js, line 338(static) setTilesPixelated(pixelated)Disables texture filtering for crisper pixel artParameters:NameTypeDescriptionpixelatedBooleanSourceengineSettings.js, line 308(static) setTouchGamepadAlpha(alpha)Set transparency of touch gamepad overlayParameters:NameTypeDescriptionalphaNumberSourceengineSettings.js, line 428(static) setTouchGamepadAnalog(analog)Set if touch gamepad should be analog stick or 8 way dpadParameters:NameTypeDescriptionanalogBooleanSourceengineSettings.js, line 418(static) setTouchGamepadEnable(enable)Set if touch gamepad should appear on mobile devicesParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 413(static) setTouchGamepadSize(size)Set size of virtual gamepad for touch devices in pixelsParameters:NameTypeDescriptionsizeNumberSourceengineSettings.js, line 423(static) setTouchInputEnable(enable)Set if touch input is allowedParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 408(static) setVibrateEnable(enable)Set to allow vibration hardware if it existsParameters:NameTypeDescriptionenableBooleanSourceengineSettings.js, line 433",https://killedbyapixel.github.io/LittleJS/docs/Settings.html
Namespace: TileCollision,"TileCollisionLittleJS Tile Layer SystemCaches arrays of tiles to off screen canvas for fast renderingUnlimited numbers of layers, allocates canvases as neededInterfaces with EngineObject for collisionCollision layer is separate from visible layersIt is recommended to have a visible layer that matches the collisionTile layers can be drawn to using their context with canvas2dDrawn directly to the main canvas without using WebGLSourceengineTileLayer.js, line 1Members(static) tileCollision :ArrayThe tile collision layer grid, use setTileCollisionData and getTileCollisionData to accessType:ArraySourceengineTileLayer.js, line 18(static) tileCollisionSize :Vector2Size of the tile collision layer 2d gridType:Vector2SourceengineTileLayer.js, line 23Methods(static) getTileCollisionData(pos) → {Number}Get tile collision data for a given cell in the gridParameters:NameTypeDescriptionposVector2SourceengineTileLayer.js, line 49Returns:Type: Number(static) initTileCollision(size)Clear and initialize tile collisionParameters:NameTypeDescriptionsizeVector2width and height of tile collision 2d gridSourceengineTileLayer.js, line 28(static) setTileCollisionData(pos, dataopt)Set tile collision data for a given cell in the gridParameters:NameTypeAttributesDefaultDescriptionposVector2dataNumber<optional>0SourceengineTileLayer.js, line 40(static) tileCollisionRaycast(posStart, posEnd, objectopt) → {Vector2}Return the center of first tile hit, undefined if nothing was hit. This does not return the exact intersection, but the center of the tile hit.Parameters:NameTypeAttributesDescriptionposStartVector2posEndVector2objectEngineObject<optional>SourceengineTileLayer.js, line 83Returns:Type: Vector2(static) tileCollisionTest(pos, sizeopt, objectopt) → {Boolean}Check if collision with another object should occurParameters:NameTypeAttributesDefaultDescriptionposVector2sizeVector2<optional>(0,0)objectEngineObject<optional>SourceengineTileLayer.js, line 60Returns:Type: Boolean",https://killedbyapixel.github.io/LittleJS/docs/TileCollision.html
Namespace: Utilities,"UtilitiesLittleJS Utility Classes and FunctionsGeneral purpose math libraryVector2 - fast, simple, easy 2D vector classColor - holds a rgba color with some math functionsTimer - tracks time automaticallyRandomGenerator - seeded random number generatorSourceengineUtilities.js, line 1Members(static, constant) BLACK :ColorColor - BlackType:ColorSourceengineUtilities.js, line 828(static, constant) BLUE :ColorColor - BlueType:ColorSourceengineUtilities.js, line 863(static, constant) CYAN :ColorColor - CyanType:ColorSourceengineUtilities.js, line 858(static, constant) GRAY :ColorColor - GrayType:ColorSourceengineUtilities.js, line 833(static, constant) GREEN :ColorColor - GreenType:ColorSourceengineUtilities.js, line 853(static, constant) MAGENTA :ColorColor - MagentaType:ColorSourceengineUtilities.js, line 873(static, constant) ORANGE :ColorColor - OrangeType:ColorSourceengineUtilities.js, line 843(static, constant) PI :NumberA shortcut to get Math.PIType:NumberDefault ValueMath.PISourceengineUtilities.js, line 17(static, constant) PURPLE :ColorColor - PurpleType:ColorSourceengineUtilities.js, line 868(static, constant) RED :ColorColor - RedType:ColorSourceengineUtilities.js, line 838(static, constant) WHITE :ColorColor - WhiteType:ColorSourceengineUtilities.js, line 823(static, constant) YELLOW :ColorColor - YellowType:ColorSourceengineUtilities.js, line 848Methods(static) abs(value) → {Number}Returns absolute value of value passed inParameters:NameTypeDescriptionvalueNumberSourceengineUtilities.js, line 23Returns:Type: Number(static) clamp(value, minopt, maxopt) → {Number}Clamps the value between max and minParameters:NameTypeAttributesDefaultDescriptionvalueNumberminNumber<optional>0maxNumber<optional>1SourceengineUtilities.js, line 58Returns:Type: Number(static) distanceAngle(angleA, angleB) → {Number}Returns signed wrapped distance between the two angles passed inParameters:NameTypeDescriptionangleANumberangleBNumberSourceengineUtilities.js, line 101Returns:Type: Number(static) distanceWrap(valueA, valueB, wrapSizeopt) → {Number}Returns signed wrapped distance between the two values passed inParameters:NameTypeAttributesDefaultDescriptionvalueANumbervalueBNumberwrapSizeNumber<optional>1SourceengineUtilities.js, line 83Returns:Type: Number(static) formatTime(t) → {String}Formats seconds to mm:ss style for display purposesParameters:NameTypeDescriptiontNumbertime in secondsSourceengineUtilities.js, line 190Returns:Type: String(static) hsl(hopt, sopt, lopt, aopt) → {Color}Create a color object with HSLA values, white by defaultParameters:NameTypeAttributesDefaultDescriptionhNumber<optional>0huesNumber<optional>0saturationlNumber<optional>1lightnessaNumber<optional>1alphaSourceengineUtilities.js, line 575Returns:Type: Color(static) isColor(c) → {Boolean}Check if object is a valid ColorParameters:NameTypeDescriptioncanySourceengineUtilities.js, line 583Returns:Type: Boolean(static) isIntersecting(start, end, pos, size) → {Boolean}Returns true if a line segment is intersecting an axis aligned boxParameters:NameTypeDescriptionstartVector2Start of raycastendVector2End of raycastposVector2Center of boxsizeVector2Size of boxSourceengineUtilities.js, line 143Returns:True if intersectingType: Boolean(static) isOverlapping(posA, sizeA, posB, sizeBopt) → {Boolean}Returns true if two axis aligned bounding boxes are overlappingParameters:NameTypeAttributesDefaultDescriptionposAVector2Center of box AsizeAVector2Size of box AposBVector2Center of box BsizeBVector2<optional>(0,0)Size of box B, a point if undefinedSourceengineUtilities.js, line 130Returns:True if overlappingType: Boolean(static) isVector2(v) → {Boolean}Check if object is a valid Vector2Parameters:NameTypeDescriptionvanySourceengineUtilities.js, line 316Returns:Type: Boolean(static) lerp(percent, valueA, valueB) → {Number}Linearly interpolates between values passed in using percentParameters:NameTypeDescriptionpercentNumbervalueANumbervalueBNumberSourceengineUtilities.js, line 75Returns:Type: Number(static) lerpAngle(percent, angleA, angleB) → {Number}Linearly interpolates between the angles passed in with wrappingParameters:NameTypeDescriptionpercentNumberangleANumberangleBNumberSourceengineUtilities.js, line 109Returns:Type: Number(static) lerpWrap(percent, valueA, valueB, wrapSizeopt) → {Number}Linearly interpolates between values passed in with wrappingParameters:NameTypeAttributesDefaultDescriptionpercentNumbervalueANumbervalueBNumberwrapSizeNumber<optional>1SourceengineUtilities.js, line 93Returns:Type: Number(static) max(valueA, valueB) → {Number}Returns highest of two values passed inParameters:NameTypeDescriptionvalueANumbervalueBNumberSourceengineUtilities.js, line 37Returns:Type: Number(static) min(valueA, valueB) → {Number}Returns lowest of two values passed inParameters:NameTypeDescriptionvalueANumbervalueBNumberSourceengineUtilities.js, line 30Returns:Type: Number(static) mod(dividend, divisoropt) → {Number}Returns first parm modulo the second param, but adjusted so negative numbers work as expectedParameters:NameTypeAttributesDefaultDescriptiondividendNumberdivisorNumber<optional>1SourceengineUtilities.js, line 50Returns:Type: Number(static) nearestPowerOfTwo(value) → {Number}Returns the nearest power of two not less then the valueParameters:NameTypeDescriptionvalueNumberSourceengineUtilities.js, line 121Returns:Type: Number(static) percent(value, valueA, valueB) → {Number}Returns what percentage the value is between valueA and valueBParameters:NameTypeDescriptionvalueNumbervalueANumbervalueBNumberSourceengineUtilities.js, line 66Returns:Type: Number(static) rgb(ropt, gopt, bopt, aopt) → {Color}Create a color object with RGBA values, white by defaultParameters:NameTypeAttributesDefaultDescriptionrNumber<optional>1redgNumber<optional>1greenbNumber<optional>1blueaNumber<optional>1alphaSourceengineUtilities.js, line 564Returns:Type: Color(static) sign(value) → {Number}Returns the sign of value passed inParameters:NameTypeDescriptionvalueNumberSourceengineUtilities.js, line 43Returns:Type: Number(static) smoothStep(percent) → {Number}Applies smoothstep function to the percentage valueParameters:NameTypeDescriptionpercentNumberSourceengineUtilities.js, line 115Returns:Type: Number(static) vec2(xopt, yopt) → {Vector2}Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalarParameters:NameTypeAttributesDefaultDescriptionxNumber | Vector2<optional>0yNumber<optional>SourceengineUtilities.js, line 303Returns:Type: Vector2Examplelet a = vec2(0, 1); // vector with coordinates (0, 1) let b = vec2(a); // copy a into b a = vec2(5); // set a to (5, 5) b = vec2(); // set b to (0, 0)(static) wave(frequencyopt, amplitudeopt, topt) → {Number}Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by defaultParameters:NameTypeAttributesDefaultDescriptionfrequencyNumber<optional>1Frequency of the wave in HzamplitudeNumber<optional>1Amplitude (max height) of the wavetNumber<optional>timeValue to use for time of the waveSourceengineUtilities.js, line 183Returns:Value waving between 0 and amplitudeType: Number",https://killedbyapixel.github.io/LittleJS/docs/Utilities.html
Namespace: WebGL,"WebGLLittleJS WebGL InterfaceAll webgl used by the engine is wrapped up hereFor normal stuff you won't need to see or call anything in this fileFor advanced stuff there are helper functions to create shaders, textures, etcCan be disabled with glEnable to revert to 2D canvas renderingBatches sprite rendering on GPU for incredibly fast performanceSprite transform math is done in the shader where possibleSupports shadertoy style post processing shadersSourceengineWebGL.js, line 1Members(static) glAntialias :BooleanShould webgl be setup with anti-aliasing? must be set before calling engineInitType:BooleanSourceengineWebGL.js, line 28(static) glCanvas :HTMLCanvasElementThe WebGL canvas which appears above the main canvas and below the overlay canvasType:HTMLCanvasElementSourceengineWebGL.js, line 18(static) glContext :WebGL2RenderingContext2d context for glCanvasType:WebGL2RenderingContextSourceengineWebGL.js, line 23Methods(static) glCompileShader(source, type) → {WebGLShader}Compile WebGL shader of the given type, will throw errors if in debug modeParameters:NameTypeDescriptionsourceStringtypeNumberSourceengineWebGL.js, line 159Returns:Type: WebGLShader(static) glCopyToContext(context, forceDrawopt)Draw any sprites still in the buffer, copy to main canvas and clearParameters:NameTypeAttributesDefaultDescriptioncontextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2DforceDrawBoolean<optional>falseSourceengineWebGL.js, line 239(static) glCreateProgram(vsSource, fsSource) → {WebGLProgram}Create WebGL program with given shadersParameters:NameTypeDescriptionvsSourceStringfsSourceStringSourceengineWebGL.js, line 177Returns:Type: WebGLProgram(static) glCreateTexture(image) → {WebGLTexture}Create WebGL texture from an image and init the texture settingsParameters:NameTypeDescriptionimageHTMLImageElementSourceengineWebGL.js, line 195Returns:Type: WebGLTexture(static) glDraw(x, y, sizeX, sizeY, angle, uv0X, uv0Y, uv1X, uv1Y, rgba, rgbaAdditiveopt)Add a sprite to the gl draw list, used by all gl draw functionsParameters:NameTypeAttributesDefaultDescriptionxNumberyNumbersizeXNumbersizeYNumberangleNumberuv0XNumberuv0YNumberuv1XNumberuv1YNumberrgbaNumberrgbaAdditiveNumber<optional>0SourceengineWebGL.js, line 272(static) glFlush()Draw all sprites and clear out the buffer, called automatically by the system whenever necessarySourceengineWebGL.js, line 218(static) glSetAntialias(antialiasopt)Set anti-aliasing for webgl canvasParameters:NameTypeAttributesDefaultDescriptionantialiasBoolean<optional>trueSourceengineWebGL.js, line 253(static) glSetTexture(texture)Set the WebGl texture, called automatically if using multiple texturesThis may also flush the gl buffer resulting in more draw calls and worse performanceParameters:NameTypeDescriptiontextureWebGLTextureSourceengineWebGL.js, line 144",https://killedbyapixel.github.io/LittleJS/docs/WebGL.html