[gnome-games] [same-gnome-clutter] Update various parts of the Seed port



commit 4fc2975c371a30015b7ea16e09dcdcad66aaadf5
Author: Tim Horton <hortont svn gnome org>
Date:   Wed Jun 24 03:04:36 2009 -0400

    [same-gnome-clutter] Update various parts of the Seed port

 configure.in                                 |    1 +
 same-gnome-clutter/Makefile.am               |    2 +-
 same-gnome-clutter/board.js                  |   54 ++++++++++++++-----------
 same-gnome-clutter/{light.js => light.js.in} |   21 ++++++----
 same-gnome-clutter/main.js                   |   10 ++--
 same-gnome-clutter/score.js                  |   14 ++++--
 6 files changed, 59 insertions(+), 43 deletions(-)
---
diff --git a/configure.in b/configure.in
index 1024668..b171003 100644
--- a/configure.in
+++ b/configure.in
@@ -1253,6 +1253,7 @@ same-gnome-clutter/Makefile
 same-gnome-clutter/same-gnome-clutter
 same-gnome-clutter/same-gnome-clutter.desktop.in
 same-gnome-clutter/same-gnome-clutter-c.desktop.in
+same-gnome-clutter/light.js
 lightsoff/Makefile
 lightsoff/lightsoff
 lightsoff/lightsoff.desktop.in
diff --git a/same-gnome-clutter/Makefile.am b/same-gnome-clutter/Makefile.am
index 8de739e..6ffe29f 100644
--- a/same-gnome-clutter/Makefile.am
+++ b/same-gnome-clutter/Makefile.am
@@ -31,7 +31,7 @@ EXTRA_DIST = \
     blue.svg \
     board.js \
     green.svg \
-    light.js \
+    light.js.in \
     main.js \
     red.svg \
     same-seed.ui \
diff --git a/same-gnome-clutter/board.js b/same-gnome-clutter/board.js
index d5d351a..eefd2ee 100644
--- a/same-gnome-clutter/board.js
+++ b/same-gnome-clutter/board.js
@@ -1,7 +1,13 @@
+Clutter = imports.gi.Clutter;
+GLib = imports.gi.GLib;
+light = imports.light;
+score = imports.score;
+main = imports.main;
+
 Board = new GType({
 	parent: Clutter.Group.type,
 	name: "Board",
-	init: function()
+	init: function(self)
 	{
 		// Private
 		var lights = [], all_lights = [];
@@ -137,31 +143,31 @@ Board = new GType({
 		{
 			var points_awarded = calculate_score(tiles);
 			
-			if(fly_score)
+			if(main.fly_score)
 			{
-				var score_text = new Score();
+				var score_text = new score.Score();
 				score_text.animate_score(points_awarded);
 			}
 			
-			score += points_awarded;
+			main.current_score += points_awarded;
 			
-			print(score);
+			print(main.current_score);
 			
-			if(board.has_completed())
+			if(self.has_completed())
 			{
-				if(board.has_won())
-					score += 1000;
+				if(self.has_won())
+					main.current_score += 1000;
 				
-				final_score = new Score();
-				final_score.animate_final_score(score);
+				final_score = new score.Score();
+				final_score.animate_final_score(main.current_score);
 				
-				print("Done with: " + score + " points!");
+				print("Done with: " + main.current_score + " points!");
 			}
 		}
 		
 		function enter_tile(actor, event)
 		{
-			var picked = stage.get_actor_at_pos(Clutter.PickMode.ALL,
+			var picked = main.stage.get_actor_at_pos(Clutter.PickMode.ALL,
 			                                    event.motion.x,
 			                                    event.motion.y).get_parent();
 			
@@ -258,8 +264,8 @@ Board = new GType({
 					li.set_light_x(real_x);
 					li.set_light_y(parseInt(y,10));
 					
-					var new_x = real_x * tile_size + offset;
-					var new_y = (tiles_h - y - 1) * tile_size + offset;
+					var new_x = real_x * main.tile_size + main.offset;
+					var new_y = (main.tiles_h - y - 1) * main.tile_size + main.offset;
 					
 					if(!li.get_closed() && ((new_x != li.x) ||
 										    (new_y != li.y)))
@@ -287,7 +293,7 @@ Board = new GType({
 			else
 				animating = false;
 			
-			for(; real_x < tiles_w; real_x++)
+			for(; real_x < main.tiles_w; real_x++)
 				lights[real_x] = null;
 			
 			update_score(cl.length);
@@ -299,30 +305,30 @@ Board = new GType({
 		
 		this.new_game = function ()
 		{
-			var children = board.get_children();
+			var children = self.get_children();
 			
 			for(var i in children)
-				board.remove_actor(children[i]);
+				self.remove_actor(children[i]);
 			
 			if(final_score)
 				final_score.hide_score();
 			
 			all_lights = [];
 			
-			for(var x = 0; x < tiles_w; x++)
+			for(var x = 0; x < main.tiles_w; x++)
 			{
 				lights[x] = [];
-				for(var y = 0; y < tiles_h; y++)
+				for(var y = 0; y < main.tiles_h; y++)
 				{
-					var li = new Light();
+					var li = new light.Light();
 				
 					li.set_light_x(x);
 					li.set_light_y(y);
 				
-					li.set_position(x * tile_size + offset,
-									(tiles_h - y - 1) * tile_size + offset);
-					board.add_actor(li);
-					li.on.signal.button_release_event.connect(board.remove_region);
+					li.set_position(x * main.tile_size + main.offset,
+									(main.tiles_h - y - 1) * main.tile_size + main.offset);
+					self.add_actor(li);
+					li.on.signal.button_release_event.connect(self.remove_region);
 				
 					lights[x][y] = li;
 					all_lights.push(lights[x][y]);
diff --git a/same-gnome-clutter/light.js b/same-gnome-clutter/light.js.in
similarity index 79%
rename from same-gnome-clutter/light.js
rename to same-gnome-clutter/light.js.in
index c047164..5f019f7 100644
--- a/same-gnome-clutter/light.js
+++ b/same-gnome-clutter/light.js.in
@@ -1,8 +1,13 @@
+Clutter = imports.gi.Clutter;
+GLib = imports.gi.GLib;
+main = imports.main;
+
 var tile_svg_size = 50;
+var file_prefix = '@prefix@' + "/share/gnome-games/same-gnome-clutter/";
 
 function load_svg(file)
 {
-    var tx = new Clutter.Texture({filename: file});
+    var tx = new Clutter.Texture({filename: file_prefix+file});
     tx.filter_quality = Clutter.TextureQuality.HIGH;
     return tx;
 }
@@ -18,7 +23,7 @@ Light = new GType({
 	// Private
 	var closed = false;
 	var light_x, light_y;
-	var state = Math.floor(Math.random() * max_colors);
+	var state = Math.floor(Math.random() * main.max_colors);
 		
 	// Public
 	this.visited = false;
@@ -39,10 +44,10 @@ Light = new GType({
 	{
 	    this.on.anim = this.on.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
 							 {
-							     height: tile_size * 2,
-							     width: tile_size * 2,
-							     x: -tile_size/2,
-							     y: -tile_size/2
+							     height: main.tile_size * 2,
+							     width: main.tile_size * 2,
+							     x: -main.tile_size/2,
+							     y: -main.tile_size/2
 							 });
 	    
 	    this.anim = this.animate_with_timeline(Clutter.AnimationMode.LINEAR, timeline,
@@ -110,11 +115,11 @@ Light = new GType({
 	};
 	
 	// Implementation
-	this.on.set_size(tile_size, tile_size);
+	this.on.set_size(main.tile_size, main.tile_size);
 	
 	this.opacity = 180;
 	
-	this.set_anchor_point(tile_size / 2, tile_size / 2);
+	this.set_anchor_point(main.tile_size / 2, main.tile_size / 2);
 	
 	this.add_actor(this.on);
     }
diff --git a/same-gnome-clutter/main.js b/same-gnome-clutter/main.js
index 2905fdc..223af72 100755
--- a/same-gnome-clutter/main.js
+++ b/same-gnome-clutter/main.js
@@ -24,11 +24,11 @@ Gtk.init(Seed.argv);
 Clutter.init(Seed.argv);
 GConf.init(Seed.argv);
 
-Seed.include("light.js");
-Seed.include("board.js");
-Seed.include("score.js");
+light = imports.light;
+board = imports.board;
+score = imports.score;
 
-var score = 0;
+var current_score = 0;
 var timelines = [];
 
 var stage = new Clutter.Stage();
@@ -38,7 +38,7 @@ stage.signal.hide.connect(Clutter.main_quit);
 stage.color = {alpha: 0};
 stage.set_size((tiles_w * tile_size),(tiles_h * tile_size));
 
-var board = new Board();
+var board = new board.Board();
 stage.add_actor(board);
 stage.show_all();
 
diff --git a/same-gnome-clutter/score.js b/same-gnome-clutter/score.js
index 39dcb4f..adab97d 100644
--- a/same-gnome-clutter/score.js
+++ b/same-gnome-clutter/score.js
@@ -1,3 +1,7 @@
+Clutter = imports.gi.Clutter;
+Pango = imports.gi.Pango;
+main = imports.main;
+
 Score = new GType({
 	parent: Clutter.Group.type,
 	name: "Score",
@@ -13,7 +17,7 @@ Score = new GType({
 				score = this;
 			
 			score.hide();
-			stage.remove_actor(score);
+			main.stage.remove_actor(score);
 		};
 		
 		this.animate_score = function (points)
@@ -25,7 +29,7 @@ Score = new GType({
 			label.set_text("+" + points);
 			this.set_anchor_point(this.width/2, this.height/2);
 			
-			stage.add_actor(this);
+			main.stage.add_actor(this);
 			this.show();
 			
 			this.anim = this.animate(Clutter.AnimationMode.EASE_OUT_SINE,400,
@@ -46,7 +50,7 @@ Score = new GType({
 			
 			this.set_anchor_point(this.width/2, this.height/2);
 			
-			stage.add_actor(this);
+			main.stage.add_actor(this);
 			this.show();
 			
 			//this.opacity = 0;
@@ -72,8 +76,8 @@ Score = new GType({
 		this.add_actor(label);
 		label.show();
 		
-		this.x = stage.width / 2;
-		this.y = stage.height / 2;
+		this.x = main.stage.width / 2;
+		this.y = main.stage.height / 2;
 	}
 });
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]