ippa / jaws

Jaws - HTML5 canvas javascript 2D Game Framework
https://jawsjs.ippa.se
GNU Lesser General Public License v3.0
364 stars 75 forks source link

Gamepad support, multiplayer considerations? #113

Open zatch opened 10 years ago

zatch commented 10 years ago

Hey there,

Just wondering if you've spent any time working with the Gamepad API, now that it's in live builds of Chrome and Firefox... I whipped up something to add support myself, but it's far from perfect at this point. Xbox 360 support only, but that would be easy enough to change. Feel free to check it out on my fork: https://github.com/zatch/jaws

Criticisms and enhancements appreciated!

-Zatch

brenopolanski commented 10 years ago

Hi @zatch.

Great feature :v:

You could create a simple demo?

Bye! :)

zatch commented 10 years ago

@brenopolanski I'm honestly not sure if I'm going overkill on the math I'm doing in jaws.gamepadReadJoystick, so I don't feel quite ready to build a formal demo page yet. I'd prefer to actually know what I'm talking about before I write up documentation/notes. ;)

In the meantime, you can check out the work-in-progress game I'm working on with @suicidepills. It has pressure-sensitive joystick support for movement (left analog), as well as for drawing a vector that will eventually represent attacks (right analog).

Game progress as of this moment: http://zandadev.com/zach/hack-n-slash-sprint/gamepad-early-demo/

You can see how I'm implementing the gamepad joysticks at: lines 99-122: http://zandadev.com/zach/hack-n-slash-sprint/gamepad-early-demo/js/entities/player-factory.js lines 67-91: http://zandadev.com/zach/hack-n-slash-sprint/gamepad-early-demo/js/entities/character-factory.js

Let me know if you have any questions! Or, if you're better at physics than I am, if you have any suggestions!

-Zatch

Disclaimer 1: Current game sprites are borrowed from Final Fantasy 4. Disclaimer 2: Chrome is pretty fickle about detecting gamepads... You have to be holding down a button on your gamepad when you refresh the page. Something to do with gamepad signatures...blah blah blah...something else I don't understand.

brenopolanski commented 10 years ago

@zatch... I will test your code and the send to you my suggestions.

Bye! :P