Skip to content
Browse files

pretty strongly typed!

  • Loading branch information...
1 parent 743be7f commit b026c0b8cea17b0d970f178d2d613c2a4d4c8555 @seanhess committed Nov 10, 2012
View
35 public/directives/keys.ts
@@ -1,27 +1,28 @@
///<reference path="../def/angular.d.ts"/>
+///<reference path="../def/jquery.d.ts"/>
angular.module('directives')
.directive('keypress', function($parse) {
- return function(scope, element, attrs) {
- // element is a jquery element
+ return function(scope:ng.IScope, element:JQuery, attrs) {
+ // element is a jquery element
- // focus the div
- element.attr('tabindex', 0)
+ // focus the div
+ element.attr('tabindex', 0)
- var onPress = $parse(attrs.keypress)
- var isPressed = false
+ var onPress = $parse(attrs.keypress)
+ var isPressed = false
- element.keydown(function(e) {
- if (isPressed) return
- isPressed = true
- scope.$apply(function() {
- onPress(scope, {e:e})
- })
- });
+ element.keydown(function(e) {
+ if (isPressed) return
+ isPressed = true
+ scope.$apply(function() {
+ onPress(scope, {e:e})
+ })
+ });
- element.keyup(function(e) {
- isPressed = false
- })
- }
+ element.keyup(function(e) {
+ isPressed = false
+ })
+ }
})
View
2 public/directives/sprite.ts
@@ -3,7 +3,7 @@
angular.module('directives')
.directive('sprite', function($parse) {
- return function(scope, element, attrs) {
+ return function(scope:ng.IScope, element:JQuery, attrs) {
// element is the player div
// attrs.sprite is "player1"
View
7 public/filters/position.ts
@@ -7,10 +7,3 @@ angular.module('filters')
return {left: object.x * Board.UNIT + "px", top: object.y * Board.UNIT + "px"}
}
})
-
-
-.filter("tauntposition", function(Board:IBoard) {
- return function(object:IPoint) {
- return {left: (object.x+1) * Board.UNIT + "px", top: object.y * Board.UNIT + "px"}
- }
-})
View
4 public/services/AppVersion.ts
@@ -1,5 +1,7 @@
///<reference path="../def/angular.d.ts"/>
-angular.module('services').factory('AppVersion', function($rootScope) {
+angular.module('services')
+
+.factory('AppVersion', function():string {
return "1.1"
})
View
4 public/services/Board.ts
@@ -35,7 +35,9 @@ interface IMove {
facing: string;
}
-angular.module('services').factory('Board', function($rootScope:ng.IRootScopeService):IBoard {
+angular.module('services')
+
+.factory('Board', function($rootScope:ng.IRootScopeService):IBoard {
var WIDTH = 800
var HEIGHT = 600
View
4 public/services/CurrentPlayer.ts
@@ -12,7 +12,9 @@ interface ICurrentPlayerService {
savePreferences(player:IPlayer, gameId:string);
}
-angular.module('services').factory('CurrentPlayer', function():ICurrentPlayerService {
+angular.module('services')
+
+.factory('CurrentPlayer', function():ICurrentPlayerService {
// lets you share the current player
function loadPreferences():IPreferences {
View
4 public/services/Players.ts
@@ -54,7 +54,9 @@ interface IPlayerService {
move(state:IPlayerState, player:IPlayer);
}
-angular.module('services').factory('Players', function($rootScope:ng.IScope, FB:firebase.IFB, Board:IBoard, AppVersion:any):IPlayerService {
+angular.module('services')
+
+.factory('Players', function($rootScope:ng.IScope, FB:firebase.IFB, Board:IBoard, AppVersion:any):IPlayerService {
// the big cheese. Does the deed
// you can make fancy bindings here, no?
View
40 public/services/SoundEffects.ts
@@ -1,32 +1,42 @@
+interface ISoundEffectsService {
+ music();
+ explosion();
+ rocket();
+}
+
+declare class Audio {
+ currentTime: number;
+ play();
+ pause();
+}
+
angular.module('services')
-.factory('SoundEffects', function() {
+.factory('SoundEffects', function():ISoundEffectsService {
var bgMusic = new Audio("/audio/g-style.mp3")
//var underwater = new Audio("/audio/Underwater.mp3")
var epic = new Audio("/audio/UnderwaterEpicBattle.mp3")
- function makeMusic(audio, seconds) {
- console.log("makeMusic ",audio.networkState, " / ", audio.readyState)
+ function makeMusic(audio:any, seconds:number):() => void {
seconds = seconds || 0
-
return function() {
audio.play();
}
- /*
- var callback = function() {
- $(audio).bind("canplay", function() {
- console.log("makeMusic - canplay")
- audio.currentTime = seconds
- audio.play()
- })
- }
- audio.load()
- return callback*/
+
+ //var callback = function() {
+ //$(audio).bind("canplay", function() {
+ //console.log("makeMusic - canplay")
+ //audio.currentTime = seconds
+ //audio.play()
+ //})
+ //}
+ //audio.load()
+ //return callback
}
// all parameters required
- function makeSound(audio, seconds, duration) {
+ function makeSound(audio:any, seconds:number, duration:number):() => void {
return function() {
audio.pause()
// we don't want the canplay thing if we're going to play it after it's been really loaded.

0 comments on commit b026c0b

Please sign in to comment.
Something went wrong with that request. Please try again.