Observed since 20 Oct, 19:11 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
a 2d game input handler

When you want to quckly add Game Inputs in your javascript game.
It supports the following inputs :
Use the following url to download the library from a CDN.
https://unpkg.com/2dgameinputs/InputHandler.js
import { JOYSTICK } from "https://unpkg.com/2dgameinputs/InputHandler.js";
var joystick = new JOYSTICK();
The instance has a 'controller' property which has a 'value' property.
console.log(joystick.controller.value);
This property is a vector with an 'x'and 'y' , each with a value ranging from -1 to 1.
"x": 0,
"y": 0
move player to the right and left.
function gameLoop(){
if( joystick.controller.value.x > 0){
player.position.x++
}
if( joystick.controller.value.x < 0){
player.position.x--
}
}
import { BUTTON } from "https://unpkg.com/2dgameinputs/InputHandler.js";
var hitbtn = new BUTTON('btn');
The instance has a 'pressed' property that is a boolean value.
console.log(hitbtn);
This property is TRUE when the element is pressed and FALSE otherwise.
a jump button
function gameLoop(){
if( hitbtn){
player.position.y++
}
}
import { INPUTHANDLER } from "https://unpkg.com/2dgameinputs/InputHandler.js";
const inputHandler = new INPUTHANDLER();
The instance has a 'addkeys' method that accepts a string (HTML keys) .
inputHandler.addkeys('a')
inputHandler.addkeys('d')
The instance has a 'getKey' method that returns a boolean value.
let a = inputHandler.getKey('a');
let d = inputHandler.getKey('d');
move player to the right and left.
function gameLoop(){
if( d){
player.position.x++
}
if( a){
player.position.x--
}
}
import { SWIPE } from "https://unpkg.com/2dgameinputs/InputHandler.js";
var swipe = new SWIPE();
The instance has four methods that each returns a boolean value .
let swipeDown = swipe.swipeDown()
let swiperight = swipe.swipeRight()
let swipeleft = swipe.swipeLeft()
let swipeup = swipe.swipeUp()
move player to the right and left.
function gameLoop(){
if( swiperight){
player.position.x++
}
if(swipeleft){
player.position.x--
}
}
Distributed under the MIT License. See LICENSE.txt for more information.
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 19:11 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:503b1777b79e1e2bc306377f1b20dd5940cecf5632f0346d858fe56d4887c773