gbrainy r191 - trunk/src



Author: jmas
Date: Thu Jan 31 23:36:20 2008
New Revision: 191
URL: http://svn.gnome.org/viewvc/gbrainy?rev=191&view=rev

Log:
2008-01-31 Jordi Mas <jmas softcatala org>

	* MathGreaterDivisor.cs: Implement difficult levels in the game
	* MathTwoNumbers.cs: Implement difficult levels in the game
	* MathArithmetical.cs: Implement difficult levels in the game
	* MemoryFigures.cs: Implement difficult levels in the game
	* CustomGameDialog.cs: Use gbrainy icon in dialog
	* PreferencesDialog.cs: Use gbrainy icon in dialog
	* GameDrawingArea.cs: Two new tips and countdown does not show 0



Modified:
   trunk/src/ChangeLog
   trunk/src/CustomGameDialog.cs
   trunk/src/GameDrawingArea.cs
   trunk/src/MathArithmetical.cs
   trunk/src/MathGreaterDivisor.cs
   trunk/src/MathTwoNumbers.cs
   trunk/src/MemoryFigures.cs
   trunk/src/PreferencesDialog.cs

Modified: trunk/src/CustomGameDialog.cs
==============================================================================
--- trunk/src/CustomGameDialog.cs	(original)
+++ trunk/src/CustomGameDialog.cs	Thu Jan 31 23:36:20 2008
@@ -107,7 +107,7 @@
 		}
 
 		treeview.Model = games_store;
-
+		Dialog.IconName = "gbrainy";
 		game =  (Game) Activator.CreateInstance (games [0], true);
 		game.Initialize ();
 		drawing_area.puzzle = game;

Modified: trunk/src/GameDrawingArea.cs
==============================================================================
--- trunk/src/GameDrawingArea.cs	(original)
+++ trunk/src/GameDrawingArea.cs	Thu Jan 31 23:36:20 2008
@@ -41,7 +41,7 @@
 	public Modes mode;
 	private GameSession session;
 	private ArrayListIndicesRandom random_indices;
-	private const int tips_count = 8;
+	private const int tips_count = 10;
 	private const int tips_shown = 4;
 	private System.Timers.Timer timer;
 	private int countdown_time;
@@ -140,7 +140,7 @@
 	private void TimerUpdater (object source, ElapsedEventArgs e)
 	{
 		lock (this) {
-			if (countdown_time == 0) {
+			if (countdown_time == 1) {
 				timer.Enabled = false;
 				timer.Dispose ();
 				finish (this, EventArgs.Empty);
@@ -294,6 +294,10 @@
 			return Catalog.GetString ("Play in daily basis, you will notice progress soon.");
 		case 7:
 			return Catalog.GetString ("You can use the Custom Game Selection to choose exactly which games you want to train.");
+		case 8:
+			return Catalog.GetString ("You can use the Preferences to adjust the difficulty level of the game.");
+		case 9:
+			return Catalog.GetString ("Association of elements is a common technique for remembering things.");
 		}
 
 		return string.Empty;

Modified: trunk/src/MathArithmetical.cs
==============================================================================
--- trunk/src/MathArithmetical.cs	(original)
+++ trunk/src/MathArithmetical.cs	Thu Jan 31 23:36:20 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Jordi Mas i HernÃndez <jmas softcatala org>
+ * Copyright (C) 2007-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
@@ -34,6 +34,8 @@
 
 	private int []operands;
 	private Operation operation;
+	private int max_operand;
+	private int max_operations;
 
 	public override string Name {
 		get {return Catalog.GetString ("Arithmetical");}
@@ -52,10 +54,25 @@
 		int result = 0, operations = 0;
 		operation = (Operation) random.Next ((int) Operation.LastOperation);
 
+		switch (CurrentDifficulty) {
+		case Difficulty.Easy:
+			max_operations = 2;
+			max_operand = 50;
+			break;
+		case Difficulty.Medium:
+			max_operations = 3;
+			max_operand = 100;
+			break;
+		case Difficulty.Master:
+			max_operations = 5;
+			max_operand = 500;
+			break;
+		}
+
 		switch (operation) {
 		case Operation.Addition:
 		case Operation.Substraction:
-			operations = 2 + random.Next (3);
+			operations = 2 + random.Next (max_operations);
 				break;
 		case Operation.Multiplication:
 			operations = 2 + random.Next (1);
@@ -64,10 +81,10 @@
 
 		operands = new int [operations];
 
-		result = operands[0] = 10 + random.Next (90);
+		result = operands[0] = 10 + random.Next (max_operand);
 		for (int i = 1; i < operands.Length; i ++)
 		{
-			operands[i] = 10 + random.Next (90);
+			operands[i] = 10 + random.Next (max_operand);
 			switch (operation) {
 			case Operation.Addition:
 				result += operands[i];

Modified: trunk/src/MathGreaterDivisor.cs
==============================================================================
--- trunk/src/MathGreaterDivisor.cs	(original)
+++ trunk/src/MathGreaterDivisor.cs	Thu Jan 31 23:36:20 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Jordi Mas i HernÃndez <jmas softcatala org>
+ * Copyright (C) 2007-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
@@ -26,6 +26,8 @@
 {
 	private int []numbers;
 	private int []answers;
+	private int max_num;
+	private int num_answ_ques;
 
 	public override string Name {
 		get {return Catalog.GetString ("Greater divisor");}
@@ -44,9 +46,24 @@
 		bool found;
 		int n, m;
 		int []mult = new int [3];
-		numbers = new int [4];
-		answers = new int [4];
-		
+
+		switch (CurrentDifficulty) {
+		case Difficulty.Easy:
+			max_num = 999;
+			num_answ_ques = 3;
+			break;
+		case Difficulty.Medium:
+			max_num = 999;
+			num_answ_ques = 4;
+			break;
+		case Difficulty.Master:
+			max_num = 9999;
+			num_answ_ques = 5;
+			break;
+		}
+
+		numbers = new int [num_answ_ques];
+		answers = new int [num_answ_ques];
 
 		// Common multiplayers for all numbers
 		for (m = 0; m < mult.Length; m++) {
@@ -64,7 +81,7 @@
 				numbers[n] = numbers [n] * mult[m];
 			}
 			
-			if (numbers[n] > 999 || numbers[n] < 50) 
+			if (numbers[n] > max_num || numbers[n] < 50) 
 				continue;
 
 			found = false;
@@ -178,7 +195,7 @@
 
 	public override void Draw (Cairo.Context gr, int area_width, int area_height)
 	{	
-		double x = DrawAreaX + 0.05, y = DrawAreaY + 0.1;
+		double x = DrawAreaX, y = DrawAreaY + 0.1;
 
 		gr.Scale (area_width, area_height);
 		DrawBackground (gr);
@@ -194,10 +211,10 @@
 			gr.MoveTo (x, y);
 			gr.ShowText (numbers[n].ToString ());
 			gr.Stroke ();
-			x += 0.2;
+			x += 0.17;
 		}
 		
-		x = DrawAreaX + 0.05;
+		x = DrawAreaX;
 		y += 0.3;
 
 		gr.MoveTo (0.05, y);
@@ -209,7 +226,7 @@
 			gr.MoveTo (x, y);
 			gr.ShowText (answers[n].ToString ());
 			gr.Stroke ();
-			x += 0.2;
+			x += 0.17;
 		}
 	}
 }

Modified: trunk/src/MathTwoNumbers.cs
==============================================================================
--- trunk/src/MathTwoNumbers.cs	(original)
+++ trunk/src/MathTwoNumbers.cs	Thu Jan 31 23:36:20 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Jordi Mas i HernÃndez <jmas softcatala org>
+ * Copyright (C) 2007-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
@@ -25,7 +25,7 @@
 public class MathTwoNumbers : Game
 {
 	private int number_a, number_b;
-	private int op1, op2;
+	private int op1, op2, max_operand;
 
 	public override string Name {
 		get {return Catalog.GetString ("Two numbers");}
@@ -41,8 +41,20 @@
 
 	public override void Initialize ()
 	{	
-		number_a = 5 + random.Next (15);
-		number_b = 3 + random.Next (10);
+		switch (CurrentDifficulty) {
+		case Difficulty.Easy:
+			max_operand = 8;
+			break;
+		case Difficulty.Medium:
+			max_operand = 12;
+			break;
+		case Difficulty.Master:
+			max_operand = 25;
+			break;
+		}
+
+		number_a = 5 + random.Next (max_operand);
+		number_b = 3 + random.Next (max_operand);
 
 		op1 = number_a + number_b;
 		op2 = number_a * number_b;

Modified: trunk/src/MemoryFigures.cs
==============================================================================
--- trunk/src/MemoryFigures.cs	(original)
+++ trunk/src/MemoryFigures.cs	Thu Jan 31 23:36:20 2008
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Jordi Mas i HernÃndez <jmas softcatala org>
+ * Copyright (C) 2007-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
@@ -26,15 +26,15 @@
 
 public class MemoryFigures : Memory
 {
-
 	private ArrayListIndicesRandom figures;
-	private const int rows = 3;
-	private const int columns = 4;
+	private int rows;
+	private int columns;
 	private const double start_x = 0.25;
 	private const double start_y = 0.1;
 	private const double figure_size = 0.08;
 	private double rect_w, rect_h;
 	private int question_pos, question_answer;
+	private int figures_active;
 
 	public enum FigureType
 	{
@@ -44,9 +44,8 @@
 		Cercle,
 		TriangleWithLine,
 		RectangleWithLine,
-		//DiamondWithLine,
-		//CercleWithLine,
-		Length
+		DiamondWithLine,
+		CercleWithLine,
 	}
 
 	public override string Name {
@@ -65,13 +64,30 @@
 	public override void Initialize ()
 	{
 		int fig1, fig2;
+
+		switch (CurrentDifficulty) {
+		case Difficulty.Easy:
+			figures_active = 4;
+			rows = columns = 3;
+			break;
+		case Difficulty.Medium:
+			figures_active = 6;
+			rows = 3;
+			columns = 4;			
+			break;
+		case Difficulty.Master:
+			figures_active = 8;
+			columns = rows = 4;
+			break;
+		}
+
 		rect_w = 0.6 / columns;
-		rect_h = DrawAreaHeight / rows;
-		figures = new ArrayListIndicesRandom ((int) FigureType.Length * 2);
+		rect_h = 0.8 / rows;
+		figures = new ArrayListIndicesRandom ((int) figures_active * 2);
 		figures.Initialize ();
-		question_pos = (int) random.Next ((int) FigureType.Length * 2);
+		question_pos = (int) random.Next ((int) figures_active * 2);
 
-		for (int figure = 0; figure < (int) FigureType.Length * 2; figure++)
+		for (int figure = 0; figure < (int) figures_active * 2; figure++)
 		{	
 			if (figure == question_pos)
 				continue;
@@ -79,8 +95,8 @@
 			fig1 = (int) figures[figure];
 			fig2 = (int) figures[question_pos];
 
-			if (fig1 >= (int) FigureType.Length) fig1 -= (int) FigureType.Length;
-			if (fig2 >= (int) FigureType.Length) fig2 -= (int) FigureType.Length;
+			if (fig1 >= (int) figures_active) fig1 -= (int) figures_active;
+			if (fig2 >= (int) figures_active) fig2 -= (int) figures_active;
 
 			if (fig1 == fig2) {
 				question_answer = figure + 1;
@@ -107,13 +123,12 @@
 		for (int figure = 0; figure < figures.Count; figure++, col++)
 		{
 			fig = (int)figures[figure];
-			if (fig >= (int) FigureType.Length) fig -= (int) FigureType.Length;
+			if (fig >= figures_active) fig -= figures_active;
 
 			if (figure == question_pos)
 				DrawFigure (gr, x, y, (FigureType) fig);
 			else {
-				gr.MoveTo (x + 0.04, y + 0.1);
-				gr.ShowText ((figure + 1).ToString ());
+				DrawingHelpers.DrawTextCentered (gr, x + rect_w / 2, y + rect_h / 2, (figure + 1).ToString ());
 				gr.Stroke ();
 			}
 
@@ -142,8 +157,8 @@
 		for (int figure = 0; figure < figures.Count; figure++, col++)
 		{
 			fig = (int)figures[figure];
-			if (fig >= (int) FigureType.Length) 
-				fig -= (int) FigureType.Length;
+			if (fig >= figures_active) 
+				fig -= figures_active;
 
 			DrawFigure (gr, x, y, (FigureType) fig);
 
@@ -159,7 +174,10 @@
 
 	private void DrawFigure (Cairo.Context gr, double x, double y, FigureType fig)
 	{
-		double space_x = 0.04, space_y = 0.08;
+		double space_x, space_y;
+
+		space_x = (rect_w - figure_size) / 2;
+		space_y = (rect_h - figure_size) / 2;
 
 		switch (fig) {
 		case FigureType.Triangle:
@@ -190,7 +208,7 @@
 			gr.LineTo (x + space_x, y + space_y + figure_size);
 			gr.Stroke ();
 			break;
-		/*case FigureType.DiamondWithLine:
+		case FigureType.DiamondWithLine:
 			DrawingHelpers.DrawDiamond  (gr, x + space_x, y + space_y, figure_size);
 			gr.MoveTo (x + space_x + figure_size / 2, y + space_y);
 			gr.LineTo (x + space_x + figure_size / 2, y + space_y + figure_size);
@@ -202,7 +220,7 @@
 			gr.MoveTo (x + space_x + figure_size / 2, y + space_y);
 			gr.LineTo (x + space_x + figure_size / 2, y + space_y + figure_size);
 			gr.Stroke ();
-			break;*/
+			break;
 		}
 	}
 

Modified: trunk/src/PreferencesDialog.cs
==============================================================================
--- trunk/src/PreferencesDialog.cs	(original)
+++ trunk/src/PreferencesDialog.cs	Thu Jan 31 23:36:20 2008
@@ -39,6 +39,7 @@
 		dialog = null;
 		xml = new Glade.XML (null, "gbrainy.glade", dialog_name, "gbrainy");
 		xml.Autoconnect (this);
+		Dialog.IconName = "gbrainy";
 	}
 	
 	public virtual int MemQuestionTime {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]