Permalink
Browse files

Turn the grid into a global.

  • Loading branch information...
stephank committed Jun 12, 2010
1 parent b3355c6 commit b6a8137b5b779053d4d79394a9705e59497b87ec
Showing with 11 additions and 9 deletions.
  1. +8 −8 src/gamestates/game.js
  2. +2 −0 src/globals.js
  3. +1 −1 src/vakit/starfield.js
View
@@ -2,13 +2,13 @@ var
GameMachine = {
enter_start: function() {
- this.grid = Grids.Circle16;
- Starfield.color = this.grid.color = [0,0,255];
+ grid = Grids.Circle16;
+ Starfield.color = grid.color = [0,0,255];
Engine.transition('flyInStars');
},
enter_flyInStars: function() {
- setTimeout(function() { Starfield.twistFromGrid(GameMachine.grid); }, 1000);
+ setTimeout(function() { Starfield.twistFromGrid(); }, 1000);
setTimeout(function() { Engine.transition('flyInGrid'); }, 3000);
},
flyInStars: function() {
@@ -17,16 +17,16 @@ GameMachine = {
},
enter_flyInGrid: function() {
- this.grid.distance = C.flyInStart;
+ grid.distance = C.flyInStart;
},
flyInGrid: function() {
Starfield.ride();
- this.grid.draw();
- if (this.grid.distance <= 0) {
- this.grid.distance = 0;
+ grid.draw();
+ if (grid.distance <= 0) {
+ grid.distance = 0;
Engine.transition('main');
}
- this.grid.distance -= C.flyInAdvance;
+ grid.distance -= C.flyInAdvance;
},
enter_main: function() {
View
@@ -11,6 +11,8 @@ var c = null;
// Some frame parameters. (See engine.js.)
var frame = null;
+// The active grid;
+var grid = null;
// Radians per degree, used in conversion.
Constants.radPerDeg = Math.PI / 180;
View
@@ -92,7 +92,7 @@ Starfield.ride = function() {
};
// Adjust the targetTwist based on the grid settings
-Starfield.twistFromGrid = function(grid) {
+Starfield.twistFromGrid = function() {
// Calculate the scale the grid will use...
var scale = Math.min(frame.w / grid.size[0], frame.h / grid.size[1]);
// ...so we can get to the screen coordinates of the twist target

0 comments on commit b6a8137

Please sign in to comment.