Home

Awesome

<div align="center">

:t-rex: GamepadZilla la la!

npm cdn

</div>

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

:video_game: Preview:joystick: Features
virtual gamepadgpz is fast. (no DOM manpulation)<br/><br/>gpz is easy. (no Javascript needed, use only html5 attributes)<br/><br/>gpz is pure. (made with only typescript without dependencies)<br/><br/>gpz hates the van's old-man!

showcase

post your open-source game using gamepadzilla!

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

How to use

<!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! :guitar:

bun :rice:

bun run build

nodejs :rage1:

npm install
npm run build

container :whale2:

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 classdescription
gpz-dpadvirtual digital pad for directional input.
gpz-joyvirtual stick or gamepad analog for directional input.
gpz-btnvirtual circle buttons with various console layouts.

data attributes

html5 attributehtml5 classdescription
data-gpz-bind*keyboard to emulate<br/>(follows anti-clockwise button pattern like:<kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd>)
data-gpz-vibrate*vibration animation when pressed for feedback
data-gpz-colorgpz-dpad<br/>gpz-btnbutton colors when is not pressed
data-gpz-color-actiongpz-dpad<br/>gpz-btnbuttons colors when is pressed
data-gpz-sizegpz-dpadsize of shapes elements
data-gpz-offsetgpz-dpadsize of gap in elements
<!-- ### extra classes You can customize the canvas element by combining visibility at and a condition. Note that there are 60 available classes, and you can also modify their activation as needed. #### examples * `gpz-disable-on-first-keyboard` disable first time when used keyboard * `gpz-hidde-on-startup` started insibible * `gpz-show-on-mobile` when browser is ios or android show the gamepad | `<status>` | description | | :--------: | :---------- | | `disable` | turn off component | | `enable` | turn on component | `hidde` | turn invisible | | `show` | turn visibile | | `<condition>` | description | | :-----------: | :---------- | | `mobile` | browser is a smartphone/iPhone | | `desktop` | browser not is a smartphone/Iphone | | `portrait` | display ratio is a portrait | | `landscape` | display ratio is a landscape | | `on-startup` | when page start | | `on-gamepad` | when gamepad connect | | `on-keyboard` | when keyboard pressed | | `on-interact` | when interact with browser | | `on-mouse` | when moved or clicked mouse | | `on-touch` | when touched the screen | | `on-first-gamepad` | when gamepad connect (only first time) | | `on-first-keyboard`| when keyboard pressed (only first time) | | `on-first-interact`| when interact with browser (only first time) | | `on-first-mouse` | when moved or clicked mouse (only first time) | | `on-first-touch` | when touched the screen (only first time) | -->

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