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

Mouse Controller

Run
var ladybug = null; var SPEED = 200; var ROTSPEED = 200; 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() { if (game.mouse.isDown(tine.buttons.LEFT)) { // Rotate the ladybug to face the mouse var angle = Math.atan2(ladybug.y-game.mouse.y, ladybug.x-game.mouse.x); angle = angle*tine.DEGREES - 90; var rotdist = tine.angleDistance(ladybug.rotation, angle); if (rotdist > 5) { var rotdir = tine.angleDirection(ladybug.rotation, angle); ladybug.rotation += rotdir*ROTSPEED*game.time.fdelta; } // Move the ladybug according to its rotation var dirX = Math.sin(ladybug.rotation*tine.RADIANS); var dirY = -Math.cos(ladybug.rotation*tine.RADIANS); ladybug.x += SPEED*dirX*game.time.fdelta; ladybug.y += SPEED*dirY*game.time.fdelta; } } })