JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdn.jsdelivr.net/phaser/2.4.6/phaser.min.js"></script>
<div id="game">
</div>
JavaScript
var game = new Phaser.Game(400, 400, Phaser.AUTO, 'phaser-example', {create: create, update: update});
var guy;
var controls;
function create() {
guy = game.add.graphics();
guy.beginFill(0xFF0000,1);
guy.drawRect(-10,-10,20,20);
guy.x = 200; guy.y = 200;
controls = {
shift: game.input.keyboard.addKey(Phaser.Keyboard.SHIFT),
up: game.input.keyboard.addKey(Phaser.Keyboard.Z)
}
}
function update() {
if(controls.shift.isDown){
if(controls.up.isDown){
guy.rotation += .05;
}
}else{
if(controls.up.isDown){
guy.x += Math.cos(guy.rotation);
guy.y += Math.sin(guy.rotation);
}
}
}