seed r271 - trunk/examples/lightsoff



Author: hortont
Date: Sun Nov 16 04:47:03 2008
New Revision: 271
URL: http://svn.gnome.org/viewvc/seed?rev=271&view=rev

Log:
LO Cleanup.


Added:
   trunk/examples/lightsoff/lcd-back.svg   (props changed)
      - copied unchanged from r268, /trunk/examples/lightsoff/back.svg
   trunk/examples/lightsoff/lcd-front.svg   (props changed)
      - copied unchanged from r268, /trunk/examples/lightsoff/front.svg
   trunk/examples/lightsoff/lcd-off.svg   (props changed)
      - copied unchanged from r270, /trunk/examples/lightsoff/off.svg
   trunk/examples/lightsoff/light-off.svg   (props changed)
      - copied unchanged from r268, /trunk/examples/lightsoff/tim-off.svg
   trunk/examples/lightsoff/light-on.svg   (props changed)
      - copied unchanged from r268, /trunk/examples/lightsoff/tim-on.svg
Removed:
   trunk/examples/lightsoff/back.svg
   trunk/examples/lightsoff/front.svg
   trunk/examples/lightsoff/led.svg
   trunk/examples/lightsoff/off.svg
   trunk/examples/lightsoff/tim-off.svg
   trunk/examples/lightsoff/tim-on.svg
Modified:
   trunk/examples/lightsoff/arrow.js
   trunk/examples/lightsoff/board.js
   trunk/examples/lightsoff/light.js
   trunk/examples/lightsoff/score.js

Modified: trunk/examples/lightsoff/arrow.js
==============================================================================
--- trunk/examples/lightsoff/arrow.js	(original)
+++ trunk/examples/lightsoff/arrow.js	Sun Nov 16 04:47:03 2008
@@ -1,8 +1,13 @@
 function pushed_arrow()
 {
 	// TODO: Need to check that click count is 1
-	score.animate_value(score.value + (this.flipped ? 1 : -1));
-	swap_animation((this.flipped ? 1 : -1));
+	var direction = (this.flipped ? 1 : -1);
+	
+	if(score.value + direction < 1)
+		return true;
+	
+	score.set_value(score.value + direction);
+	swap_animation(direction);
 	gconf_client.set_int("/apps/lightsoff/score", score.value);
 	
 	return true;

Modified: trunk/examples/lightsoff/board.js
==============================================================================
--- trunk/examples/lightsoff/board.js	(original)
+++ trunk/examples/lightsoff/board.js	Sun Nov 16 04:47:03 2008
@@ -90,7 +90,7 @@
 	
 	if(light.get_parent().cleared() && !in_setup)
 	{
-		score.animate_value(score.value+1);
+		score.set_value(score.value+1);
 		gconf_client.set_int("/apps/lightsoff/score", score.value);
 		win_animation();
 	}
@@ -144,28 +144,29 @@
 			in_setup = true;
 			
 			GLib.random_set_seed(score.value);
-
-			var count = Math.log(score.value*score.value) + 1;
-			var sym = Math.floor(3*GLib.random_double());
-
-			for (q = 0; q < count; ++q)
+			
+			do
 			{
-				i = Math.round((tiles-1) * GLib.random_double());
-				j = Math.round((tiles-1) * GLib.random_double());
+				var count = Math.floor(Math.log(score.value*score.value) + 1);
+				var sym = Math.floor(3*GLib.random_double());
 
-				flip_region(null, null, this.lights[i][j]);
-
-				if(sym == 0)
-					flip_region(null, null, this.lights[Math.abs(i-(tiles-1))][j]);
-				else if(sym == 1)
-					flip_region(null, null,
-						this.lights[Math.abs(i-(tiles-1))][Math.abs(j-(tiles-1))]);
-				else
-					flip_region(null, null, this.lights[i][Math.abs(j-(tiles-1))]);
+				for (q = 0; q < count; ++q)
+				{
+					i = Math.round((tiles-1) * GLib.random_double());
+					j = Math.round((tiles-1) * GLib.random_double());
+
+					flip_region(null, null, this.lights[i][j]);
+
+					if(sym == 0)
+						flip_region(null, null, this.lights[Math.abs(i-(tiles-1))][j]);
+					else if(sym == 1)
+						flip_region(null, null,
+							this.lights[Math.abs(i-(tiles-1))][Math.abs(j-(tiles-1))]);
+					else
+						flip_region(null, null, this.lights[i][Math.abs(j-(tiles-1))]);
+				}
 			}
-
-			if(this.cleared())
-				this.randomize();
+			while(this.cleared());
 
 			in_setup = false;
 		}

Modified: trunk/examples/lightsoff/light.js
==============================================================================
--- trunk/examples/lightsoff/light.js	(original)
+++ trunk/examples/lightsoff/light.js	Sun Nov 16 04:47:03 2008
@@ -1,7 +1,7 @@
 var tile_svg_size = 200;
 
-var on_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("./tim-on.svg", tile_svg_size, tile_svg_size);
-var off_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("./tim-off.svg", tile_svg_size, tile_svg_size);
+var on_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("./light-on.svg", tile_svg_size, tile_svg_size);
+var off_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("./light-off.svg", tile_svg_size, tile_svg_size);
 
 var on_svg = GtkClutter.texture_new_from_pixbuf(on_pixbuf);
 var off_svg = GtkClutter.texture_new_from_pixbuf(off_pixbuf);

Modified: trunk/examples/lightsoff/score.js
==============================================================================
--- trunk/examples/lightsoff/score.js	(original)
+++ trunk/examples/lightsoff/score.js	Sun Nov 16 04:47:03 2008
@@ -3,17 +3,7 @@
     name: "Score",
     class_init: function(klass, prototype)
     {
-    	prototype.increment_value = function (val)
-    	{
-    		var current_val = this.value;
-    		var max_val = this.value + val;
-    		for(var i = this.value; i <= max_val; i += 1)
-    		{
-				Seed.setTimeout("score.animate_value("+i+");",5*(i - current_val) + 100);
-			}
-    	}
-    	
-    	prototype.animate_value = function (val)
+	   	prototype.set_value = function (val)
 		{
 			this.value = val;
 			
@@ -48,9 +38,9 @@
     {
     	this.current_set = null;
     	
-    	this.bkg_top = Clutter.Texture.new_from_file("./front.svg");
-		var bkg = Clutter.Texture.new_from_file("./back.svg");
-		var off_svg = Clutter.Texture.new_from_file("./off.svg");
+    	this.bkg_top = Clutter.Texture.new_from_file("./lcd-front.svg");
+		var bkg = Clutter.Texture.new_from_file("./lcd-back.svg");
+		var off_svg = Clutter.Texture.new_from_file("./lcd-off.svg");
 	Seed.print(bkg.__debug_ref_count());
 	Seed.print(this.bkg_top.__debug_ref_count());
 	Seed.print(off_svg.__debug_ref_count());
@@ -85,7 +75,7 @@
 		this.bkg_top.set_position(1, 1);
 		this.add_actor(this.bkg_top);
 
-		this.animate_value(gconf_client.get_int("/apps/lightsoff/score"));
+		this.set_value(gconf_client.get_int("/apps/lightsoff/score"));
 	Seed.print(bkg.__debug_ref_count());
 	Seed.print(this.bkg_top.__debug_ref_count());
 	Seed.print(off_svg.__debug_ref_count());



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