2
* Copyright (C) 2008 Jordi Mas i Hernàndez <jmas@softcatala.org>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
24
public class PuzzleCountCircles : Game
26
private const double figure_size = 0.3;
27
private const double radian = Math.PI / 180;
28
private int n_circles;
32
public double x, y, rad;
34
public ItemCircle (double x, double y, double rad)
44
public override string Name {
45
get {return Catalog.GetString ("Count circles");}
48
public override string Question {
49
get {return Catalog.GetString ("How many circles do you count?");}
52
public override string Tip {
53
get { return Catalog.GetString ("It is an easy exercise if you systematically count the circles.");}
56
public override void Initialize ()
60
switch (CurrentDifficulty) {
64
case Difficulty.Master:
67
case Difficulty.Medium:
73
n_circles += random.Next (5);
74
circles = new ItemCircle [n_circles];
75
for (int i = 0; i < circles.Length; i++)
77
x = random.Next (500) / 1000d;
78
y = random.Next (500) / 1000d;
79
rad = 0.03 + random.Next (500) / 3200d;
81
circles[i] = new ItemCircle (x, y, rad);
84
right_answer = n_circles.ToString ();
88
public override void Draw (CairoContextEx gr, int area_width, int area_height)
90
double x = DrawAreaX + 0.1, y = DrawAreaY + 0.05;
92
gr.Scale (area_width, area_height);
96
for (int i = 0; i < circles.Length; i++)
98
gr.Arc (x + circles[i].x + 0.1, y + circles[i].y + 0.1, circles[i].rad, 0, 2 * Math.PI);