[gbrainy] Fixes and make files for sample extensions
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Fixes and make files for sample extensions
- Date: Sat, 5 Jun 2010 10:11:53 +0000 (UTC)
commit 87aebd7092a6633fffc17e7ee2034ff8122209dc
Author: Jordi Mas <jmas softcatala org>
Date: Sat Jun 5 12:11:53 2010 +0200
Fixes and make files for sample extensions
sample_extensions/Calculation/CalculationSample.cs | 22 ++++++++++----------
sample_extensions/Calculation/Makefile | 7 ++++++
sample_extensions/Logic/Makefile | 7 ++++++
sample_extensions/Logic/PuzzleSample.cs | 4 +-
sample_extensions/Makefile | 11 ++++++++++
sample_extensions/Memory/Makefile | 7 ++++++
sample_extensions/Memory/MemorySample.cs | 16 +++++++-------
sample_extensions/README | 2 +
8 files changed, 55 insertions(+), 21 deletions(-)
---
diff --git a/sample_extensions/Calculation/CalculationSample.cs b/sample_extensions/Calculation/CalculationSample.cs
index d3bb5c6..366d626 100644
--- a/sample_extensions/Calculation/CalculationSample.cs
+++ b/sample_extensions/Calculation/CalculationSample.cs
@@ -34,16 +34,16 @@ public class CalculationSample : Game
get {return "Calculation sample";}
}
- public override Types Type {
- get { return Game.Types.MathTrainer;}
+ public override GameTypes Type {
+ get { return GameTypes.MathTrainer;}
}
public override string Question {
- get {return String.Format ("Which two numbers when added are {0} and when multiplied are {1}?", op1, op2);}
+ get {return String.Format ("Which two numbers when added are {0} and when multiplied are {1}?", op1, op2);}
}
- public override void Initialize ()
- {
+ protected override void Initialize ()
+ {
switch (CurrentDifficulty) {
case Difficulty.Easy:
max_operand = 8;
@@ -66,7 +66,7 @@ public class CalculationSample : Game
}
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
- {
+ {
double x = DrawAreaX + 0.1;
base.Draw (gr, area_width, area_height, rtl);
@@ -75,7 +75,7 @@ public class CalculationSample : Game
gr.MoveTo (x, DrawAreaY + 0.22);
gr.ShowPangoText (String.Format ("number1 + number2 = {0}", op1));
-
+
gr.MoveTo (x, DrawAreaY + 0.44);
gr.ShowPangoText (String.Format ("number1 * number2 = {0}", op2));
@@ -84,18 +84,18 @@ public class CalculationSample : Game
}
public override bool CheckAnswer (string answer)
- {
+ {
string num_a = string.Empty;
string num_b = string.Empty;
bool first = true;
-
+
for (int c = 0; c < answer.Length; c++)
{
if (answer[c] < '0' || answer[c] > '9') {
first = false;
continue;
}
-
+
if (first == true)
num_a += answer[c];
else
@@ -111,7 +111,7 @@ public class CalculationSample : Game
catch (FormatException) {
return false;
}
-
+
return false;
}
}
diff --git a/sample_extensions/Calculation/Makefile b/sample_extensions/Calculation/Makefile
new file mode 100644
index 0000000..44228b4
--- /dev/null
+++ b/sample_extensions/Calculation/Makefile
@@ -0,0 +1,7 @@
+TARGET = gbrainy.calculation_sample_extension.dll
+
+all: CalculationSample.cs CalculationSample.addin.xml
+ gmcs -t:library CalculationSample.cs -resource:CalculationSample.addin.xml -pkg:gbrainy -out:$(TARGET)
+
+clean:
+ rm $(TARGET) -r -f
diff --git a/sample_extensions/Logic/Makefile b/sample_extensions/Logic/Makefile
new file mode 100644
index 0000000..33d4045
--- /dev/null
+++ b/sample_extensions/Logic/Makefile
@@ -0,0 +1,7 @@
+TARGET = gbrainy.logic_sample_extension.dll
+
+all: PuzzleSample.cs PuzzleSample.addin.xml
+ gmcs -t:library PuzzleSample.cs -resource:PuzzleSample.addin.xml -pkg:gbrainy -out:$(TARGET)
+
+clean:
+ rm $(TARGET) -r -f
diff --git a/sample_extensions/Logic/PuzzleSample.cs b/sample_extensions/Logic/PuzzleSample.cs
index 3587df7..31a4261 100644
--- a/sample_extensions/Logic/PuzzleSample.cs
+++ b/sample_extensions/Logic/PuzzleSample.cs
@@ -31,10 +31,10 @@ public class PuzzleSample : Game
}
public override string Question {
- get {return "In a party all the people is introduced to the rest. There are 28 handeshakes. How many people is in the party?";}
+ get {return "In a party all the people is introduced to the rest. There are 28 handshakes. How many people is in the party?";}
}
- public override void Initialize ()
+ protected override void Initialize ()
{
right_answer = "8";
}
diff --git a/sample_extensions/Makefile b/sample_extensions/Makefile
new file mode 100644
index 0000000..87b344f
--- /dev/null
+++ b/sample_extensions/Makefile
@@ -0,0 +1,11 @@
+all: subdirs
+
+.PHONY: all subdirs clean
+subdirs:
+ ${MAKE} -C Logic ${MAKECMDGOALS}
+ ${MAKE} -C Memory ${MAKECMDGOALS}
+ ${MAKE} -C Calculation ${MAKECMDGOALS}
+
+clean: subdirs
+
+
diff --git a/sample_extensions/Memory/Makefile b/sample_extensions/Memory/Makefile
new file mode 100644
index 0000000..076a856
--- /dev/null
+++ b/sample_extensions/Memory/Makefile
@@ -0,0 +1,7 @@
+TARGET = gbrainy.memory_sample_extension.dll
+
+all: MemorySample.cs MemorySample.addin.xml
+ gmcs -t:library MemorySample.cs -resource:MemorySample.addin.xml -pkg:gbrainy -out:$(TARGET)
+
+clean:
+ rm $(TARGET) -r -f
diff --git a/sample_extensions/Memory/MemorySample.cs b/sample_extensions/Memory/MemorySample.cs
index da49c05..ec0ce48 100644
--- a/sample_extensions/Memory/MemorySample.cs
+++ b/sample_extensions/Memory/MemorySample.cs
@@ -38,11 +38,11 @@ public class MemorySample : Memory
}
public override string MemoryQuestion {
- get {
+ get {
return "There is a missing animal name from the previous list. Which one is missing?";}
}
- public override void Initialize ()
+ protected override void Initialize ()
{
int tmp;
animals = new List <string> ();
@@ -76,7 +76,7 @@ public class MemorySample : Memory
right_answer = animals [tmp];
base.Initialize ();
}
-
+
public override void DrawPossibleAnswers (CairoContextEx gr, int area_width, int area_height, bool rtl)
{
double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1;
@@ -103,13 +103,13 @@ public class MemorySample : Memory
gr.Color = new Color (0.9, 0.9, 0.9);
gr.DrawTextCentered (0.5, DrawAreaY, "This is an extension sample");
}
-
- public override void DrawObjectToMemorize (CairoContextEx gr, int area_width, int area_height)
+
+ public override void DrawObjectToMemorize (CairoContextEx gr, int area_width, int area_height, bool rtl)
{
- base.DrawObjectToMemorize (gr, area_width, area_height);
+ base.DrawObjectToMemorize (gr, area_width, area_height, rtl);
DrawObject (gr, area_width, area_height);
}
-
+
void DrawObject (CairoContextEx gr, int area_width, int area_height)
{
double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1;
@@ -118,7 +118,7 @@ public class MemorySample : Memory
gr.MoveTo (x, y);
gr.ShowPangoText (animals[animals_order[i]]);
gr.Stroke ();
-
+
if ((i + 1) % 3 == 0) {
y += 0.2;
x = DrawAreaX + 0.125;
diff --git a/sample_extensions/README b/sample_extensions/README
index dadcbb2..f8628ae 100644
--- a/sample_extensions/README
+++ b/sample_extensions/README
@@ -1,3 +1,5 @@
gbrainy sample extensions
+Just type 'make' to build the samples
+
See http://live.gnome.org/gbrainy/Extensions for more details
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]