Giter VIP home page Giter VIP logo

rodrigodornelles / npm-gamepadzilla Goto Github PK

View Code? Open in Web Editor NEW
28.0 1.0 3.0 75 KB

A plug-and-play gamepad frontend framework for HTML5 mobile games, supporting both virtual and physical joysticks. No scripting required.

Home Page: https://rodrigodornelles.github.io/npm-gamepadzilla/

License: GNU Affero General Public License v3.0

TypeScript 100.00%
gamepad gamepad-library gamepad-viewer gamepadlistener html5-canvas html5-game

npm-gamepadzilla's Introduction

๐Ÿฆ– GamepadZilla la la!

npm cdn

A plug-and-play gamepad frontend framework for HTML5 mobile games, supporting both virtual and physical joysticks. No scripting required.

๐ŸŽฎ Preview ๐Ÿ•น๏ธ Features
virtual gamepad gpz is fast. (no DOM manpulation)

gpz is easy. (no Javascript needed, use only html5 attributes)

gpz is pure. (made with only typescript without dependencies)

gpz hates the van's old-man!

showcase

post your open-source game using gamepadzilla!

game stack source
Coco Battle Royale 2 C, Assembly 6502, WebAssembly, Html, gampadzila.js :octocat:repo

How to use

  • import library with npm or cdn. ๐Ÿš
  • create html5 canvas elements with class gpz-joy or gpz-btn and configure data attributes.
<!DOCTYPE html>
<html>
    <head>
        <script src='https://cdn.jsdelivr.net/npm/gamepadzilla@1/dist/gamepadzilla.js'></script>
    </head>
    <body style="touch-action: none">
        <canvas
            class="gpz-joy"
            data-gpz-bind="ArrowUp ArrowLeft ArrowDown ArrowRight">
        </canvas>
        <canvas
            class="gpz-btn"
            data-gpz-bind="KeyF">
        </canvas>
    </body>
</html>

How to build

if you intend to contribute, let's rock! ๐ŸŽธ

bun ๐Ÿš

bun run build

nodejs :rage1:

npm install
npm run build

container ๐Ÿ‹

podman run --rm -v $(pwd):/app -w /app  -it oven/bun bun run build
docker run --rm -v $(pwd):/app -w /app  -it ove/bun bun run build

Cheatsheet

main classes

html5 class description
gpz-dpad virtual digital pad for directional input.
gpz-joy virtual stick or gamepad analog for directional input.
gpz-btn virtual circle buttons with various console layouts.

data attributes

html5 attribute html5 class description
data-gpz-bind * keyboard to emulate
(follows anti-clockwise button pattern like:WASD)
data-gpz-vibrate * vibration animation when pressed for feedback
data-gpz-color gpz-dpad
gpz-btn
button colors when is not pressed
data-gpz-color-action gpz-dpad
gpz-btn
buttons colors when is pressed
data-gpz-size gpz-dpad size of shapes elements
data-gpz-offset gpz-dpad size of gap in elements

This project is licensed under GNU Affero General Public License 3.0, please read the LICENSE file.

npm-gamepadzilla's People

Contributors

rodrigodornelles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

npm-gamepadzilla's Issues

docs: gpz protocol for network

It is important to define a protocol to be used between external communications, it can be standard between more than one event.

  • bluetooth
  • webrtc #33
  • websocket #21

bug: no feedback should be given before the user interacts with the page

Browsers are generating error logs when on computers you have to hover your mouse over two buttons before clicking somewhere.

console log

[Intervention] Blocked call to navigator.vibrate because user hasn't tapped on the frame or any embedded frame yet: <URL>

solution

detect event click in the window.document to activate feedbacks.

feat: add support to microphone scream, blow and noises

Like legend of zelda support scream like gamepad action

references

features

  • data-gpz-loud sound noise tolerance

examples

simple controls joystick

<canvas
  class="gpz-btn"
  data-gpz-bind="KeyF"
  data-gpz-loud="50">
</canvas>

feat: npm library for react wrapper

Create a separate library for npm that depends on gamepadzilla, which allows you to use it as a react component.

  • package.json
  • react component

path suggestion

src/
wrappers/
--react/
----src/
----package.json
package.json

feat: add support gyroscope API

Support the cell phone's gyroscope, which can be 1, 2 or 3 axes at the same time.

references

features

  • data-gpz-gryo add axis to controll

examples

car wheel steering

<canvas
  class="gpz-car-steering"
  data-gpz-bind="KeyA KeyD"
  data-gpz-gryo="Y">
</canvas>

simple controls joystick

<canvas
  class="gpz-joy"
  data-gpz-bind="KeyW KeyA KeyS KeyD"
  data-gpz-gryo="X Y">
</canvas>

feat: add coverage status in the pipeline

Bun already has the possibility of receiving test coverage results, but it does not yet generate reports in lcov format.

  • start unit tests for frontend
  • add coverage results in the pipeline
  • generate coverage reports in lcov
  • report coverage to quality plataform (like codacy, codeclimate...)
  • add badge in the readme

extra

Maybe I can study a temporary way to convert the bun report to a more basic lcov while it is still being developed, with knowledge if you haven't worked on it yet I can contribute to bun and also 3bc.

related

feat: add attributes for physical gamepad

The physical gamepad support is very poor, it is only suitable for the Coco Battle Royale game, as it is simpler. It would be interesting to improve the control options.

related #18 #19

  • data-gpz-gamepad-player none, all, odd, even, 0, 1...
  • data-gpz-gamepad-bind btn1 btn2 xboxA xboxB

feat: add support to custom javascript

  • data-gpz-action-up
  • data-gpz-action-down

html5 attribute

<canvas class="gpz-btn" data-gpz-action-down="console.log(this)"></canvas>

callback

document.querySelectorAll('.gpz-btn').foreach(el => {
  el.addEventListener('gpz-action-down', ev => {
   console.log(ev)
 })
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.