seed r28 - trunk/examples/lightsoff
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r28 - trunk/examples/lightsoff
- Date: Thu, 23 Oct 2008 11:33:23 +0000 (UTC)
Author: racarr
Date: Thu Oct 23 11:33:23 2008
New Revision: 28
URL: http://svn.gnome.org/viewvc/seed?rev=28&view=rev
Log:
Indentation.
Modified:
trunk/examples/lightsoff/lightsoff.js
Modified: trunk/examples/lightsoff/lightsoff.js
==============================================================================
--- trunk/examples/lightsoff/lightsoff.js (original)
+++ trunk/examples/lightsoff/lightsoff.js Thu Oct 23 11:33:23 2008
@@ -5,55 +5,57 @@
image_on = new Gtk.Image({"file": "./tim-on.svg"});
/* SxS size*/
-var size = 20;
+var size = 5;
var wincount = 0;
function create_board()
{
- var table = new Gtk.Table();
- table.resize(size,size);
+ var table = new Gtk.Table();
+ table.resize(size,size);
- buttons = new Array(size);
+ buttons = new Array(size);
- for (i = 0; i < size; ++i)
- {
- buttons[i] = new Array(size);
- for (j = 0; j < size; ++j)
- {
- buttons[i][j] = new Gtk.Button();
+ for (i = 0; i < size; ++i)
+ {
+ buttons[i] = new Array(size);
+ for (j = 0; j < size; ++j)
+ {
+ buttons[i][j] = new Gtk.Button();
- buttons[i][j].x = i;
- buttons[i][j].y = j;
+ buttons[i][j].x = i;
+ buttons[i][j].y = j;
- buttons[i][j].set_relief(Gtk.ReliefStyle.none);
- buttons[i][j].can_focus = false;
+ buttons[i][j].set_relief(Gtk.ReliefStyle.none);
+ buttons[i][j].can_focus = false;
- buttons[i][j].signal_clicked.connect(button_clicked, buttons[i][j]);
- table.attach_defaults(buttons[i][j], j, j+1, i, i+1);
- }
- }
+ buttons[i][j].signal_clicked.connect(button_clicked,
+ buttons[i][j]);
+ table.attach_defaults(buttons[i][j], j, j+1, i, i+1);
+ }
+ }
- return table;
+ return table;
}
function clear_board()
{
- for(i = 0; i < size; ++i)
- {
- for(j = 0; j < size; ++j)
- {
- buttons[i][j].lit = false;
- buttons[i][j].set_image(new Gtk.Image({"pixbuf": image_off.pixbuf}));
- }
- }
+ for(i = 0; i < size; ++i)
+ {
+ for(j = 0; j < size; ++j)
+ {
+ buttons[i][j].lit = false;
+ buttons[i][j].set_image(new Gtk.Image({"pixbuf":
+ image_off.pixbuf}));
+ }
+ }
}
function initialize_game()
{
- wincount = 0;
+ wincount = 0;
- clear_board();
- random_clicks(); // generate random puzzle
+ clear_board();
+ random_clicks(); // generate random puzzle
}
function do_click(x , y)
@@ -86,27 +88,27 @@
{
var count = Math.round(size*5* Math.random());
- var sym = Math.floor(3*Math.random());
+ var sym = Math.floor(3*Math.random(level));
for (q = 0; q < count + 5; ++q)
{
- i = Math.round((size-1) * Math.random());
- j = Math.round((size-1) * Math.random());
+ i = Math.round((size-1) * Math.random());
+ j = Math.round((size-1) * Math.random());
- do_click(i, j);
+ do_click(i, j);
- if (sym == 0)
- {
- do_click(Math.abs(i-(size-1)), j);
- }
- else if (sym == 1)
- {
- do_click(Math.abs(i-(size-1)), Math.abs(j-(size-1)));
- }
- else
- {
- do_click(i,Math.abs(j-(size-1)));
- }
+ if (sym == 0)
+ {
+ do_click(Math.abs(i-(size-1)), j);
+ }
+ else if (sym == 1)
+ {
+ do_click(Math.abs(i-(size-1)), Math.abs(j-(size-1)));
+ }
+ else
+ {
+ do_click(i,Math.abs(j-(size-1)));
+ }
}
//do it again if you won already
if ( wincount == 0 )
@@ -118,15 +120,17 @@
if ( buttons[i][j].lit )
{
--wincount;
- buttons[i][j].set_image(new Gtk.Image({"pixbuf": image_off.pixbuf}));
+ buttons[i][j].set_image(new Gtk.Image({"pixbuf":
+ image_off.pixbuf}));
}
else
{
++wincount;
- buttons[i][j].set_image(new Gtk.Image({"pixbuf": image_on.pixbuf}));
+ buttons[i][j].set_image(new Gtk.Image({"pixbuf":
+ image_on.pixbuf}));
}
- buttons[i][j].lit = !buttons[i][j].lit;
+ buttons[i][j].lit = !buttons[i][j].lit;
}
Gtk.init(null, null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]