Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

35 Commits

Repository files navigation

Joystick plugin for Litecanvas

Adds a virtual joystick to litecanvas games.

Tip

This plugin is automatically loaded on Litecanvas playground.

Install

NPM: npm i @litecanvas/plugin-joystick

CDN: https://unpkg.com/@litecanvas/plugin-joystick/dist/dist.js

Basic Usage

importlitecanvasfrom"litecanvas"importpluginJoystickfrom"@litecanvas/plugin-joystick"letactorlitecanvas({loop: { init, update, draw },})functioninit(){use(pluginJoystick)// load the pluginactor={x: W/2,y: H/2,speed: 200,}}functionupdate(dt){if(joystick.on){const{ angle, force }=joystickactor.x+=actor.speed*force*cos(angle)*dtactor.y+=actor.speed*force*sin(angle)*dt}}functiondraw(){cls(0)circfill(actor.x,actor.y,32,3)}

Live Demo

For more advance usage, check the samples code or clone this repository to run them locally:

git clone https://github.com/litecanvas/plugin-joystick
cd plugin-joystick
npm install
npm run dev

About

🕹️ Add virtual joystick in litecanvas games

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages