This site works A LOT better with JavaScript enabled!
This is the beta version of this site! Some things may not be working.

Gamepad Controller

Run
var ladybug = null; var SPEED = 200; var ROTSPEED = 400; var game = new tine.Game(null, { preload: function() { game.load.image('bg', 'assets/scene-jungle.png'); game.load.image('lady', 'assets/ladybug.png'); }, create: function() { game.stage.addChild(game.create.bitmap('bg')); ladybug = game.create.bitmap('lady', {regX:'center', regY:'center', x:512, y:288}); game.stage.addChild(ladybug); }, update: function() { var angle; var gamepad = game.gamepad.get(0); // Rotation (with right stick) if (gamepad.rightStickForce > 0.1) { angle = Math.atan2(gamepad.rightStickY, gamepad.rightStickX); angle = tine.DEGREES*angle +90; var rotdist = tine.angleDistance(ladybug.rotation, angle); if (rotdist > 5) { var rotdir = tine.angleDirection(ladybug.rotation, angle); ladybug.rotation += rotdir*ROTSPEED*gamepad.rightStickForce*game.time.fdelta; } } // Movement (with left stick) if (gamepad.leftStickForce > 0.1) { angle = Math.atan2(gamepad.leftStickY, gamepad.leftStickX); angle += 90*tine.RADIANS; // Move the ladybug according to its rotation var dirX = Math.sin(angle); var dirY = -Math.cos(angle); ladybug.x += SPEED*dirX*gamepad.leftStickForce*game.time.fdelta; ladybug.y += SPEED*dirY*gamepad.leftStickForce*game.time.fdelta; } } })