seed r826 - trunk/examples/same-seed
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r826 - trunk/examples/same-seed
- Date: Mon, 2 Feb 2009 01:25:02 +0000 (UTC)
Author: hortont
Date: Mon Feb 2 01:25:02 2009
New Revision: 826
URL: http://svn.gnome.org/viewvc/seed?rev=826&view=rev
Log:
Game works now (forgot sliding left when you empty a row...)
Modified:
trunk/examples/same-seed/board.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:25:02 2009
@@ -44,9 +44,6 @@
var x = li.get_light_x();
var y = li.get_light_y();
- //Seed.printf("%d %d " + li.toString(), x, y);
- //Seed.print(lights[x][y+1]);
-
if(li.visited || li.get_closed())
return [ ];
@@ -54,8 +51,6 @@
var con = [li];
- // doesn't deal with state of tile yet
-
if(lights[x][y+1] && (li.get_state() == lights[x][y+1].get_state()))
con = con.concat(_connected_lights(lights[x][y+1]));
@@ -96,6 +91,9 @@
var cl = connected_lights(picked);
+ if(cl.length < 2)
+ return false;
+
for(i in cl)
{
cl[i].opacity = 255;
@@ -112,70 +110,18 @@
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);
+ if(cl.length < 2)
+ return false;
+
for(i in cl)
{
cl[i].close_tile();
}
+ var real_x = 0;
+
for(x in lights)
{
var good_lights = [];
@@ -191,23 +137,28 @@
bad_lights.push(li);
}
- lights[x] = good_lights.concat(bad_lights);
+ lights[real_x] = good_lights.concat(bad_lights);
- for(y in lights[x])
+ var empty_col = true;
+
+ for(y in lights[real_x])
{
- lights[x][y].set_light_y(parseInt(y,10));
+ lights[real_x][y].set_light_x(real_x);
+ lights[real_x][y].set_light_y(parseInt(y,10)); //wtfstring?
+ lights[real_x][y].set_position(real_x * tile_size + offset,
+ (tiles_h - y - 1) * tile_size + offset);
- 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);
+ if(!lights[real_x][y].get_closed())
+ empty_col = false;
}
-
-
-
+ if(!empty_col)
+ real_x++;
}
+ for(;real_x < tiles_w; real_x++)
+ lights[real_x] = null;
+
return false;
}
Modified: trunk/examples/same-seed/main.js
==============================================================================
--- trunk/examples/same-seed/main.js (original)
+++ trunk/examples/same-seed/main.js Mon Feb 2 01:25:02 2009
@@ -1,7 +1,7 @@
#!/usr/bin/env seed
-var tiles_w = 5;
-var tiles_h = 5;
+var tiles_w = 15;
+var tiles_h = 10;
var tile_size = 50;
// Configuration
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]