gbrainy r281 - trunk/src
- From: jmas svn gnome org
- To: svn-commits-list gnome org
- Subject: gbrainy r281 - trunk/src
- Date: Wed, 2 Apr 2008 21:29:23 +0100 (BST)
Author: jmas
Date: Wed Apr 2 21:29:22 2008
New Revision: 281
URL: http://svn.gnome.org/viewvc/gbrainy?rev=281&view=rev
Log:
2008-04-02 Jordi Mas <jmas softcatala org>
* PuzzleCountCircles.cs: New logic puzzle
* GameManager.cs: Add new logic puzzle
* Makefile.am: Add new puzzle
Added:
trunk/src/PuzzleCountCircles.cs
Modified:
trunk/src/ChangeLog
trunk/src/GameManager.cs
trunk/src/Makefile.am
Modified: trunk/src/GameManager.cs
==============================================================================
--- trunk/src/GameManager.cs (original)
+++ trunk/src/GameManager.cs Wed Apr 2 21:29:22 2008
@@ -54,6 +54,7 @@
typeof (PuzzleMostInCommon),
typeof (PuzzleBuildTriangle),
typeof (PuzzleClocks),
+ typeof (PuzzleCountCircles),
};
static Type[] CalculationTrainers = new Type[]
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Apr 2 21:29:22 2008
@@ -55,6 +55,7 @@
$(srcdir)/PuzzleBuildTriangle.cs \
$(srcdir)/CairoContextEx.cs \
$(srcdir)/PuzzleClocks.cs \
+ $(srcdir)/PuzzleCountCircles.cs \
$(srcdir)/gbrainy.cs
ASSEMBLIES = \
Added: trunk/src/PuzzleCountCircles.cs
==============================================================================
--- (empty file)
+++ trunk/src/PuzzleCountCircles.cs Wed Apr 2 21:29:22 2008
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2008 Jordi Mas i HernÃndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using Cairo;
+using Mono.Unix;
+using System;
+
+public class PuzzleCountCircles : Game
+{
+ private const double figure_size = 0.3;
+ private const double radian = Math.PI / 180;
+ private int n_circles;
+
+ class ItemCircle
+ {
+ public double x, y, rad;
+
+ public ItemCircle (double x, double y, double rad)
+ {
+ this.x = x;
+ this.y = y;
+ this.rad = rad;
+ }
+ }
+
+ ItemCircle[] circles;
+
+ public override string Name {
+ get {return Catalog.GetString ("Count circles");}
+ }
+
+ public override string Question {
+ get {return Catalog.GetString ("How many circles can you count?");}
+ }
+
+ public override string Tip {
+ get { return Catalog.GetString ("It is an easy exercise if you use a systematic way of counting the circles.");}
+ }
+
+ public override void Initialize ()
+ {
+ double x, y, rad;
+
+ switch (CurrentDifficulty) {
+ case Difficulty.Easy:
+ n_circles = 7;
+ break;
+ case Difficulty.Master:
+ n_circles = 14;
+ break;
+ case Difficulty.Medium:
+ default:
+ n_circles = 10;
+ break;
+ }
+
+ n_circles += random.Next (5);
+ circles = new ItemCircle [n_circles];
+ for (int i = 0; i < circles.Length; i++)
+ {
+ x = random.Next (500) / 1000d;
+ y = random.Next (500) / 1000d;
+ rad = 0.03 + random.Next (500) / 3200d;
+
+ circles[i] = new ItemCircle (x, y, rad);
+ }
+
+ right_answer = n_circles.ToString ();
+ }
+
+
+ public override void Draw (CairoContextEx gr, int area_width, int area_height)
+ {
+ double x = DrawAreaX + 0.1, y = DrawAreaY + 0.05;
+
+ gr.Scale (area_width, area_height);
+ DrawBackground (gr);
+ PrepareGC (gr);
+
+ for (int i = 0; i < circles.Length; i++)
+ {
+ gr.Arc (x + circles[i].x + 0.1, y + circles[i].y + 0.1, circles[i].rad, 0, 2 * Math.PI);
+ gr.Stroke ();
+ }
+ }
+}
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]