seed r825 - trunk/examples/same-seed
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r825 - trunk/examples/same-seed
- Date: Mon, 2 Feb 2009 01:06:54 +0000 (UTC)
Author: hortont
Date: Mon Feb 2 01:06:53 2009
New Revision: 825
URL: http://svn.gnome.org/viewvc/seed?rev=825&view=rev
Log:
There's a long debugging function here. It's going away but might be useful later. The game is playable now. Yay!
Modified:
trunk/examples/same-seed/board.js
trunk/examples/same-seed/light.js
trunk/examples/same-seed/main.js
Modified: trunk/examples/same-seed/board.js
==============================================================================
--- trunk/examples/same-seed/board.js (original)
+++ trunk/examples/same-seed/board.js Mon Feb 2 01:06:53 2009
@@ -44,7 +44,10 @@
var x = li.get_light_x();
var y = li.get_light_y();
- if(li.visited)
+ //Seed.printf("%d %d " + li.toString(), x, y);
+ //Seed.print(lights[x][y+1]);
+
+ if(li.visited || li.get_closed())
return [ ];
li.visited = true;
@@ -53,16 +56,16 @@
// doesn't deal with state of tile yet
- if((y+1 < tiles_h) && (li.get_state() == lights[x][y+1].get_state()))
+ if(lights[x][y+1] && (li.get_state() == lights[x][y+1].get_state()))
con = con.concat(_connected_lights(lights[x][y+1]));
- if((y-1 >= 0) && (li.get_state() == lights[x][y-1].get_state()))
+ if(lights[x][y-1] && (li.get_state() == lights[x][y-1].get_state()))
con = con.concat(_connected_lights(lights[x][y-1]));
- if((x+1 < tiles_w) && (li.get_state() == lights[x+1][y].get_state()))
+ if(lights[x+1] && (li.get_state() == lights[x+1][y].get_state()))
con = con.concat(_connected_lights(lights[x+1][y]));
- if((x-1 >= 0) && (li.get_state() == lights[x-1][y].get_state()))
+ if(lights[x-1] && (li.get_state() == lights[x-1][y].get_state()))
con = con.concat(_connected_lights(lights[x-1][y]));
return con;
@@ -109,47 +112,100 @@
this.remove_region = function (actor, event, light)
{
+ if(event.button.button == 2)
+ {
+ x = light.get_light_x();
+ y = light.get_light_y();
+
+ Seed.print(x + " " + y);
+
+ for(i in lights[x])
+ Seed.print(x + " " + i + " " + lights[x][i].get_closed() + " " + (i == y));
+
+ Seed.print(lights[x].length);
+
+ if(lights[x][y+1])
+ Seed.print("up " + lights[x][y+1].get_closed());
+ else
+ Seed.print(x + " " + (y+1) + " " +lights[x][y+1]);
+
+ if(lights[x][y-1])
+ Seed.print("down " + lights[x][y-1].get_closed());
+ else
+ Seed.print(x + " " + (y-1) + " " +lights[x][y-1]);
+
+ if(lights[x-1] && lights[x-1][x])
+ Seed.print("left " + lights[x-1][y].get_closed());
+ else
+ Seed.print((x-1) + " " + y + " " +lights[x-1]);
+
+ if(lights[x+1] && lights[x+1][y])
+ Seed.print("right " + lights[x+1][y].get_closed());
+ else
+ Seed.print((x+1) + " " + y + " " +lights[x+1]);
+
+ return false;
+ }
+
+ if(event.button.button == 3)
+ {
+ var str = [];
+
+ for(var i = 0; i < tiles_h; i++)
+ str[i] = "";
+
+ for(x in lights)
+ {
+ for(y in lights[x])
+ //if(lights[x][y].get_closed())
+ // str[y] += " ";
+ //else
+ str[y] += lights[x][y].get_state();
+ }
+
+ for(i in str)
+ Seed.print(str[i]);
+
+ return false;
+ }
+
var cl = connected_lights(light);
for(i in cl)
{
- cl[i].flip();
+ cl[i].close_tile();
}
- x = 0;
- //for(x in lights)
+ for(x in lights)
{
- var y = 0;
+ var good_lights = [];
+ var bad_lights = [];
- while(y != lights[x].length - 1)
+ for(y in lights[x])
{
var li = lights[x][y];
- // if find empty one
- // pull next full one down
- // go back one
-
- var p = -1, found_full = -1;
- if(li.get_closed())
- {
- for(p = y; p < lights[x].length; p++)
- {
- if(!lights[x][p].get_closed())
- {
- found_full = p;
- break;
- }
- }
- }
-
- if(found_full != -1)
- {
- lights[x][found_full].y += 50;
- y--;
- }
+ if(!li.get_closed())
+ good_lights.push(li);
+ else
+ bad_lights.push(li);
+ }
+
+ lights[x] = good_lights.concat(bad_lights);
+
+ for(y in lights[x])
+ {
+ lights[x][y].set_light_y(parseInt(y,10));
- y++;
+ Seed.print(lights[x][y].get_light_y() + 2);
+
+ lights[x][y].set_position(x * tile_size + offset,
+ (tiles_h - y - 1) * tile_size + offset);
}
+
+
+
+
}
return false;
@@ -169,7 +225,7 @@
lights[x][y].set_light_y(y);
lights[x][y].set_position(x * tile_size + offset,
- y * tile_size + offset);
+ (tiles_h - y - 1) * tile_size + offset);
this.add_actor(lights[x][y]);
lights[x][y].on.signal.button_press_event.connect(this.remove_region,
lights[x][y]);
Modified: trunk/examples/same-seed/light.js
==============================================================================
--- trunk/examples/same-seed/light.js (original)
+++ trunk/examples/same-seed/light.js Mon Feb 2 01:06:53 2009
@@ -41,18 +41,11 @@
return closed;
}
- this.flip = function ()
+ this.close_tile = function ()
{
- closed = !closed;
+ closed = true;
- if(closed)
- {
- this.hide();
- }
- else
- {
- this.show();
- }
+ this.hide();
}
this.set_light_x = function (new_x)
Modified: trunk/examples/same-seed/main.js
==============================================================================
--- trunk/examples/same-seed/main.js (original)
+++ trunk/examples/same-seed/main.js Mon Feb 2 01:06:53 2009
@@ -1,7 +1,7 @@
#!/usr/bin/env seed
-var tiles_w = 15;
-var tiles_h = 10;
+var tiles_w = 5;
+var tiles_h = 5;
var tile_size = 50;
// Configuration
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]