Created
March 30, 2013 10:13
-
-
Save satoshun/5276205 to your computer and use it in GitHub Desktop.
bomber1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module("game", [], function($routeProvider, $locationProvider){ | |
// $routeProvider.when("test", { | |
// templateUrl: "index.html", | |
// controller: MyCtrl2 | |
// }); | |
// $locationProvider.html5Mode(true); | |
}); | |
app.config(function($interpolateProvider){ | |
$interpolateProvider.startSymbol('(('); | |
$interpolateProvider.endSymbol('))'); | |
}); | |
app.directive("keypress", function(){ | |
return { | |
restrict: "A", | |
require: "?ngModel", | |
link: function(scope){ | |
$(window).keydown(function(e){ | |
var KEY = { | |
left: 37, | |
up: 38, | |
right: 39, | |
down: 40, | |
attack: 32 | |
}; | |
var position = scope.player.position; | |
switch(e.keyCode){ | |
case KEY.left: | |
position.x -= 1; | |
break; | |
case KEY.right: | |
position.x += 1; | |
break; | |
case KEY.up: | |
position.y -= 1; | |
break; | |
case KEY.down: | |
position.y += 1; | |
break; | |
case KEY.attack: | |
break; | |
} | |
scope.$digest(); | |
}); | |
} | |
}; | |
}); | |
app.controller("MyCtrl", function($scope){ | |
$scope.player = {}; | |
$scope.player.position = new Spec.position(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment