Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

pretty strongly typed!

  • Loading branch information...
commit b026c0b8cea17b0d970f178d2d613c2a4d4c8555 1 parent 743be7f
Sean Hess authored
35 public/directives/keys.ts
... ... @@ -1,27 +1,28 @@
1 1 ///<reference path="../def/angular.d.ts"/>
  2 +///<reference path="../def/jquery.d.ts"/>
2 3
3 4 angular.module('directives')
4 5
5 6 .directive('keypress', function($parse) {
6   - return function(scope, element, attrs) {
7   - // element is a jquery element
  7 + return function(scope:ng.IScope, element:JQuery, attrs) {
  8 + // element is a jquery element
8 9
9   - // focus the div
10   - element.attr('tabindex', 0)
  10 + // focus the div
  11 + element.attr('tabindex', 0)
11 12
12   - var onPress = $parse(attrs.keypress)
13   - var isPressed = false
  13 + var onPress = $parse(attrs.keypress)
  14 + var isPressed = false
14 15
15   - element.keydown(function(e) {
16   - if (isPressed) return
17   - isPressed = true
18   - scope.$apply(function() {
19   - onPress(scope, {e:e})
20   - })
21   - });
  16 + element.keydown(function(e) {
  17 + if (isPressed) return
  18 + isPressed = true
  19 + scope.$apply(function() {
  20 + onPress(scope, {e:e})
  21 + })
  22 + });
22 23
23   - element.keyup(function(e) {
24   - isPressed = false
25   - })
26   - }
  24 + element.keyup(function(e) {
  25 + isPressed = false
  26 + })
  27 + }
27 28 })
2  public/directives/sprite.ts
@@ -3,7 +3,7 @@
3 3 angular.module('directives')
4 4
5 5 .directive('sprite', function($parse) {
6   - return function(scope, element, attrs) {
  6 + return function(scope:ng.IScope, element:JQuery, attrs) {
7 7 // element is the player div
8 8 // attrs.sprite is "player1"
9 9
7 public/filters/position.ts
@@ -7,10 +7,3 @@ angular.module('filters')
7 7 return {left: object.x * Board.UNIT + "px", top: object.y * Board.UNIT + "px"}
8 8 }
9 9 })
10   -
11   -
12   -.filter("tauntposition", function(Board:IBoard) {
13   - return function(object:IPoint) {
14   - return {left: (object.x+1) * Board.UNIT + "px", top: object.y * Board.UNIT + "px"}
15   - }
16   -})
4 public/services/AppVersion.ts
... ... @@ -1,5 +1,7 @@
1 1 ///<reference path="../def/angular.d.ts"/>
2 2
3   -angular.module('services').factory('AppVersion', function($rootScope) {
  3 +angular.module('services')
  4 +
  5 +.factory('AppVersion', function():string {
4 6 return "1.1"
5 7 })
4 public/services/Board.ts
@@ -35,7 +35,9 @@ interface IMove {
35 35 facing: string;
36 36 }
37 37
38   -angular.module('services').factory('Board', function($rootScope:ng.IRootScopeService):IBoard {
  38 +angular.module('services')
  39 +
  40 +.factory('Board', function($rootScope:ng.IRootScopeService):IBoard {
39 41
40 42 var WIDTH = 800
41 43 var HEIGHT = 600
4 public/services/CurrentPlayer.ts
@@ -12,7 +12,9 @@ interface ICurrentPlayerService {
12 12 savePreferences(player:IPlayer, gameId:string);
13 13 }
14 14
15   -angular.module('services').factory('CurrentPlayer', function():ICurrentPlayerService {
  15 +angular.module('services')
  16 +
  17 +.factory('CurrentPlayer', function():ICurrentPlayerService {
16 18 // lets you share the current player
17 19
18 20 function loadPreferences():IPreferences {
4 public/services/Players.ts
@@ -54,7 +54,9 @@ interface IPlayerService {
54 54 move(state:IPlayerState, player:IPlayer);
55 55 }
56 56
57   -angular.module('services').factory('Players', function($rootScope:ng.IScope, FB:firebase.IFB, Board:IBoard, AppVersion:any):IPlayerService {
  57 +angular.module('services')
  58 +
  59 +.factory('Players', function($rootScope:ng.IScope, FB:firebase.IFB, Board:IBoard, AppVersion:any):IPlayerService {
58 60 // the big cheese. Does the deed
59 61 // you can make fancy bindings here, no?
60 62
40 public/services/SoundEffects.ts
... ... @@ -1,32 +1,42 @@
  1 +interface ISoundEffectsService {
  2 + music();
  3 + explosion();
  4 + rocket();
  5 +}
  6 +
  7 +declare class Audio {
  8 + currentTime: number;
  9 + play();
  10 + pause();
  11 +}
  12 +
1 13 angular.module('services')
2 14
3   -.factory('SoundEffects', function() {
  15 +.factory('SoundEffects', function():ISoundEffectsService {
4 16
5 17 var bgMusic = new Audio("/audio/g-style.mp3")
6 18 //var underwater = new Audio("/audio/Underwater.mp3")
7 19 var epic = new Audio("/audio/UnderwaterEpicBattle.mp3")
8 20
9   - function makeMusic(audio, seconds) {
10   - console.log("makeMusic ",audio.networkState, " / ", audio.readyState)
  21 + function makeMusic(audio:any, seconds:number):() => void {
11 22 seconds = seconds || 0
12   -
13 23 return function() {
14 24 audio.play();
15 25 }
16   - /*
17   - var callback = function() {
18   - $(audio).bind("canplay", function() {
19   - console.log("makeMusic - canplay")
20   - audio.currentTime = seconds
21   - audio.play()
22   - })
23   - }
24   - audio.load()
25   - return callback*/
  26 +
  27 + //var callback = function() {
  28 + //$(audio).bind("canplay", function() {
  29 + //console.log("makeMusic - canplay")
  30 + //audio.currentTime = seconds
  31 + //audio.play()
  32 + //})
  33 + //}
  34 + //audio.load()
  35 + //return callback
26 36 }
27 37
28 38 // all parameters required
29   - function makeSound(audio, seconds, duration) {
  39 + function makeSound(audio:any, seconds:number, duration:number):() => void {
30 40 return function() {
31 41 audio.pause()
32 42 // 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.