gbrainy r291 - trunk/src
- From: jmas svn gnome org
- To: svn-commits-list gnome org
- Subject: gbrainy r291 - trunk/src
- Date: Sun, 6 Apr 2008 20:12:20 +0100 (BST)
Author: jmas
Date: Sun Apr 6 20:12:20 2008
New Revision: 291
URL: http://svn.gnome.org/viewvc/gbrainy?rev=291&view=rev
Log:
2008-04-02 Jordi Mas <jmas softcatala org>
* PuzzleQuadrilaterals.cs: New logic puzzle
* GameManager.cs: Add new logic puzzle
* Makefile.am: Add new puzzle
Added:
trunk/src/PuzzleQuadrilaterals.cs
Modified:
trunk/src/ChangeLog
trunk/src/GameManager.cs
trunk/src/Makefile.am
trunk/src/gbrainy.cs
Modified: trunk/src/GameManager.cs
==============================================================================
--- trunk/src/GameManager.cs (original)
+++ trunk/src/GameManager.cs Sun Apr 6 20:12:20 2008
@@ -56,6 +56,7 @@
typeof (PuzzleClocks),
typeof (PuzzleCountCircles),
typeof (PuzzleEquation),
+ typeof (PuzzleQuadrilaterals),
};
static Type[] CalculationTrainers = new Type[]
@@ -175,7 +176,7 @@
}
puzzle = (Game) Activator.CreateInstance ((Type) games [(int) enumerator.Current], true);
- //puzzle = (Game) Activator.CreateInstance (LogicPuzzles [31], true);
+ //puzzle = (Game) Activator.CreateInstance (LogicPuzzles [32], true);
if (first != null && first.GetType () == puzzle.GetType ())
break;
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Apr 6 20:12:20 2008
@@ -57,6 +57,7 @@
$(srcdir)/PuzzleClocks.cs \
$(srcdir)/PuzzleCountCircles.cs \
$(srcdir)/PuzzleEquation.cs \
+ $(srcdir)/PuzzleQuadrilaterals.cs \
$(srcdir)/gbrainy.cs
ASSEMBLIES = \
Added: trunk/src/PuzzleQuadrilaterals.cs
==============================================================================
--- (empty file)
+++ trunk/src/PuzzleQuadrilaterals.cs Sun Apr 6 20:12:20 2008
@@ -0,0 +1,144 @@
+/*
+ * 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 System;
+using Cairo;
+using Mono.Unix;
+
+public class PuzzleQuadrilaterals : Game
+{
+ enum Figures
+ {
+ FigureA,
+ FigureB,
+ FigureC,
+ FigureD,
+ FigureE,
+ FigureF,
+ Last
+ };
+
+ private ArrayListIndicesRandom random_indices;
+ private const double figure_size = 0.15;
+
+ public override string Name {
+ get {return Catalog.GetString ("Quadrilaterals");}
+ }
+
+ public override string Question {
+ get {return Catalog.GetString ("Which of the following figures does not belong to the group?");}
+ }
+
+ public override string Answer {
+ get {
+ string answer = base.Answer + "It is the only figure with all lines of equal size.";
+ return answer;
+ }
+ }
+
+ public override void Initialize ()
+ {
+ random_indices = new ArrayListIndicesRandom ((int) Figures.Last);
+ random_indices.Initialize ();
+
+ for (int i = 0; i < (int) Figures.Last; i++)
+ {
+ if ((Figures) random_indices[i] == Figures.FigureA) {
+ right_answer += (char) (65 + i);
+ break;
+ }
+ }
+ }
+
+ private void DrawFigure (CairoContextEx gr, double x, double y, Figures figure)
+ {
+ switch (figure) {
+ case Figures.FigureA:
+ gr.MoveTo (x, y);
+ gr.LineTo (x + figure_size, y);
+ gr.LineTo (x + figure_size * 0.6, y + figure_size + 0.02);
+ gr.LineTo (x - figure_size * 0.4, y + figure_size + 0.02);
+ gr.LineTo (x, y);
+ break;
+
+ case Figures.FigureB:
+ gr.Rectangle (x, y, figure_size * 0.8, figure_size * 1.2);
+ break;
+
+ case Figures.FigureC:
+ gr.MoveTo (x, y);
+ gr.LineTo (x + figure_size * 1.3, y);
+ gr.LineTo (x + figure_size * 1.3, y + figure_size);
+ gr.LineTo (x , y + figure_size);
+ gr.LineTo (x, y);
+ break;
+
+ case Figures.FigureD:
+ gr.MoveTo (x + 0.03, y);
+ gr.LineTo (x + figure_size - 0.03, y);
+ gr.LineTo (x + figure_size, y + figure_size);
+ gr.LineTo (x , y + figure_size);
+ gr.LineTo (x + 0.03, y);
+ break;
+
+ case Figures.FigureE:
+ gr.MoveTo (x + 0.03, y);
+ gr.LineTo (x + figure_size - 0.04, y);
+ gr.LineTo (x + figure_size - 0.04, y + figure_size);
+ gr.LineTo (x , y + figure_size);
+ gr.LineTo (x + 0.03, y);
+ break;
+
+ case Figures.FigureF:
+ gr.MoveTo (x, y);
+ gr.LineTo (x, y + figure_size);
+ gr.LineTo (x + figure_size, y + figure_size);
+ gr.LineTo (x + figure_size - 0.02, y);
+ gr.LineTo (x, y);
+ break;
+ }
+
+ gr.Stroke ();
+
+ }
+
+ public override void Draw (CairoContextEx gr, int area_width, int area_height)
+ {
+ double x = DrawAreaX, y = DrawAreaY, space_x = 0.15;
+
+ gr.Scale (area_width, area_height);
+
+ DrawBackground (gr);
+ PrepareGC (gr);
+
+ for (int i = 0; i < random_indices.Count; i++) {
+ DrawFigure (gr, x, y, (Figures) random_indices[i]);
+ gr.MoveTo (x, y + figure_size * 1.6);
+ gr.ShowText (String.Format (Catalog.GetString ("Figure {0}"), (char) (65 + i)));
+
+ if (i == 2) {
+ x = DrawAreaX;
+ y += figure_size * 3;
+ } else
+ x += figure_size + space_x;
+ }
+ }
+}
+
+
Modified: trunk/src/gbrainy.cs
==============================================================================
--- trunk/src/gbrainy.cs (original)
+++ trunk/src/gbrainy.cs Sun Apr 6 20:12:20 2008
@@ -316,7 +316,7 @@
{
session.NewSession ();
GetNextGame ();
- solution_label.Text = Catalog.GetString ("Once you have an answer type it in \"Answer:\" entry box and press the \"Ok\" button.");
+ solution_label.Text = Catalog.GetString ("Once you have an answer type it in the \"Answer:\" entry box and press the \"OK\" button.");
UpdateStatusBar ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]