[gcompris/gcomprisbraille] Generate number from lotto tickets|symmetry in buttons|Braille_Lotto Complete
- From: Srishti Sethi <srishs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprisbraille] Generate number from lotto tickets|symmetry in buttons|Braille_Lotto Complete
- Date: Fri, 22 Jul 2011 08:20:18 +0000 (UTC)
commit 922e250d522931598998e4b80f4f7eb0988dd4f9
Author: Srishti Sethi <srishakatux gmail com>
Date: Fri Jul 22 13:49:55 2011 +0530
Generate number from lotto tickets|symmetry in buttons|Braille_Lotto Complete
src/braille_lotto-activity/braille_lotto.py | 115 ++++++++++----------
.../resources/braille_lotto/button.svg | 88 +++------------
.../resources/braille_lotto/button2.svg | 65 +++++++++++
.../resources/braille_lotto/callout1.svg | 15 ++--
.../resources/braille_lotto/callout2.svg | 15 ++--
5 files changed, 157 insertions(+), 141 deletions(-)
---
diff --git a/src/braille_lotto-activity/braille_lotto.py b/src/braille_lotto-activity/braille_lotto.py
index cde616d..d231e28 100644
--- a/src/braille_lotto-activity/braille_lotto.py
+++ b/src/braille_lotto-activity/braille_lotto.py
@@ -39,14 +39,10 @@ CIRCLE_FILL = "light green"
CIRCLE_STROKE = "black"
CELL_WIDTH = 30
-CHECK_RANDOM = []
-
class Gcompris_braille_lotto:
"""Empty gcompris python class"""
def __init__(self, gcomprisBoard):
- print "braille_lotto init"
-
# Save the gcomprisBoard, it defines everything we need
# to know from the core
self.gcomprisBoard = gcomprisBoard
@@ -54,14 +50,7 @@ class Gcompris_braille_lotto:
# Needed to get key_press
gcomprisBoard.disable_im_context = True
- for index in range(1, 91):
- CHECK_RANDOM.append(index)
-
- random.shuffle(CHECK_RANDOM)
-
def start(self):
- print "braille_lotto start"
-
# Set the buttons we want in the bar
gcompris.bar_set(gcompris.BAR_LEVEL)
gcompris.bar_set(0)
@@ -81,7 +70,7 @@ class Gcompris_braille_lotto:
self.gamewon = 0
self.score_player_a = 0
self.score_player_b = 0
- self.status_timer = 50
+ self.status_timer = 70
self.delay_one = 100
self.delay_two = 100
self.tile_counter = 0
@@ -142,7 +131,7 @@ class Gcompris_braille_lotto:
#Button to display the number to be checked in the ticket
goocanvas.Image(parent = self.root,
pixbuf = gcompris.utils.load_pixmap("braille_lotto/button.svg"),
- x = 5,
+ x = 20,
y = 340,
)
@@ -151,8 +140,8 @@ class Gcompris_braille_lotto:
parent = self.root,
text= _("Check Number"),
font = gcompris.skin.get_font("gcompris/board/medium"),
- x=120,
- y=390,
+ x=110,
+ y=380,
anchor=gtk.ANCHOR_CENTER,
)
@@ -218,9 +207,9 @@ class Gcompris_braille_lotto:
#Generate Number Button
generate_number = goocanvas.Image(parent = self.root,
- pixbuf = gcompris.utils.load_pixmap("braille_lotto/button2.png"),
- x = 620,
- y = 350,
+ pixbuf = gcompris.utils.load_pixmap("braille_lotto/button2.svg"),
+ x = 610,
+ y = 340,
)
generate_number.connect("button_press_event", self.generateNumber)
gcompris.utils.item_focus_init(generate_number, None)
@@ -236,10 +225,6 @@ class Gcompris_braille_lotto:
generate_text.connect("button_press_event", self.generateNumber)
gcompris.utils.item_focus_init(generate_text, generate_number)
-
- #Calling the random number and checking it on lotto board
- self.number_call()
-
#An array to store the ticket numbers
self.ticket_array = []
@@ -260,22 +245,29 @@ class Gcompris_braille_lotto:
self.displayTicket(51, 75, 610, 200)
self.displayTicket(76, 90, 700, 125)
+ #Copy the contents of ticket array into another for shuffling
+ self.check_random = self.ticket_array[:]
+ random.shuffle(self.check_random)
+
+ #Calling the random number and checking it on lotto board
+ self.number_call()
+
def clue_left(self, event , target, item):
self.callout1 = goocanvas.Image(parent = self.root,
pixbuf = gcompris.utils.load_pixmap("braille_lotto/callout1.svg"),
- x = 220,
+ x = 230,
y =250,
)
self.status_one = goocanvas.Text(
parent = self.root,
text= "",
x=310,
- y=320,
+ y=310,
font = "SANS 10 BOLD",
anchor=gtk.ANCHOR_CENTER,
)
- if (CHECK_RANDOM[self.counter] in self.ticket_array[0:6]):
+ if (self.check_random[self.counter] in self.ticket_array[0:6]):
self.findColumn()
self.status_one.props.text = " Hey,you have \n "" it. Its there \n"" in your\n " + self.column + " column"
else :
@@ -285,18 +277,18 @@ class Gcompris_braille_lotto:
def clue_right(self, event , target, item):
self.callout2 = goocanvas.Image(parent = self.root,
pixbuf = gcompris.utils.load_pixmap("braille_lotto/callout2.svg"),
- x = 400,
+ x = 410,
y = 250,
)
self.status_two = goocanvas.Text(
parent = self.root,
text= "",
x=500,
- y=320,
+ y=310,
font = "SANS 10 BOLD",
anchor=gtk.ANCHOR_CENTER,
)
- if (CHECK_RANDOM[self.counter] in self.ticket_array[6:12]):
+ if (self.check_random[self.counter] in self.ticket_array[6:12]):
self.findColumn()
self.status_two.props.text = " Hey,you have \n "" it. Its there \n"" in your\n " + self.column + " column"
else :
@@ -325,11 +317,11 @@ class Gcompris_braille_lotto:
self.hideCalloutRight)
def findColumn(self):
- if CHECK_RANDOM[self.counter] <= 25:
+ if self.check_random[self.counter] <= 25:
self.column = "1st"
- elif CHECK_RANDOM[self.counter] <= 50 and CHECK_RANDOM[self.counter] > 25 :
+ elif self.check_random[self.counter] <= 50 and self.check_random[self.counter] > 25 :
self.column = "2nd"
- elif CHECK_RANDOM[self.counter] <= 75 and CHECK_RANDOM[self.counter] > 50 :
+ elif self.check_random[self.counter] <= 75 and self.check_random[self.counter] > 50 :
self.column = "3rd"
else :
self.column = "4th"
@@ -341,18 +333,28 @@ class Gcompris_braille_lotto:
self.number_call()
def number_call(self):
- if(self.counter == 90):
- self.game.props.visibility = goocanvas.ITEM_VISIBLE
+ if(self.counter == 11):
+ self.displayGameStatus()
self.game_status.props.text = " Game Over"
-
- self.check_number = goocanvas.Text(
+ self.timer_inc = gobject.timeout_add(self.status_timer,
+ self.game_over)
+ else :
+ self.check_number = goocanvas.Text(
parent = self.root,
- text= CHECK_RANDOM[self.counter],
+ text= self.check_random[self.counter],
x=110,
y=420,
font = "SANS 20",
anchor=gtk.ANCHOR_CENTER,
)
+ def game_over(self):
+ self.status_timer -= 1
+ if self.status_timer == 0 :
+ self.pause(1)
+ self.status_timer = 70
+ if self.status_timer < 70 :
+ self.timer_inc = gobject.timeout_add(self.status_timer,
+ self.game_over)
def displayTicketBox(self, x, y):
goocanvas.Rect(
@@ -402,7 +404,7 @@ class Gcompris_braille_lotto:
self.tile_counter += 1
def cross_number(self,item, event, target, index):
- if( CHECK_RANDOM[self.counter] == self.ticket_array[index]):
+ if( self.check_random[self.counter] == self.ticket_array[index]):
if(index in (0, 1, 2, 3, 4, 5)):
self.score_player_a +=1
else:
@@ -432,43 +434,46 @@ class Gcompris_braille_lotto:
if(self.score_player_a == 6 or self.score_player_b == 6):
- self.game = goocanvas.Image(parent = self.root,
+ self.displayGameStatus()
+ if(self.score_player_a == 6):
+ self.game_status.props.text = "PLAYER 1\n" "You WON"
+ elif(self.score_player_b == 6):
+ self.game_status.props.text = "PLAYER 2 \n" "You WON"
+
+ self.timer_inc = gobject.timeout_add(self.status_timer,
+ self.timer_loop)
+ #print self.score_player_a
+ #print self.score_player_b
+
+ def displayGameStatus(self):
+ self.game = goocanvas.Image(parent = self.root,
pixbuf = gcompris.utils.load_pixmap("braille_lotto/game.svg"),
x = 230 ,
y = 150,
)
-
- self.game_status = goocanvas.Text(
+ self.game_status = goocanvas.Text(
parent = self.root,
text= "",
- x=390,
+ x=375,
y=220,
font = "SANS 30",
fill_color = "blue",
anchor=gtk.ANCHOR_CENTER,
)
- if(self.score_player_a == 6):
- self.game_status.props.text = "PLAYER 1\n" "You WON"
- elif(self.score_player_b == 6):
- self.game_status.props.text = "PLAYER 2 \n" "You WON"
-
- self.timer_inc = gobject.timeout_add(self.status_timer,
- self.timer_loop)
- #print self.score_player_a
- #print self.score_player_b
-
def timer_loop(self):
self.status_timer -= 1
if(self.status_timer == 0):
+ self.game.props.visibility = goocanvas.ITEM_INVISIBLE
+ self.game_status.props.visibility = goocanvas.ITEM_INVISIBLE
+ self.status_timer = 70
self.gamewon = 1
gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.FLOWER)
- self.timer_inc = gobject.timeout_add(self.status_timer,
+ if (self.status_timer < 70):
+ self.timer_inc = gobject.timeout_add(self.status_timer,
self.timer_loop)
def end(self):
- print "braille_lotto end"
-
# Remove the root item removes all the others inside it
self.root.remove()
gcompris.end_board()
@@ -500,7 +505,7 @@ class Gcompris_braille_lotto:
def pause(self, pause):
self.board_paused = pause
- if(self.board_paused == 1 and (self.counter == 90 or self.gamewon == 1)):
+ if(self.board_paused and (self.counter == 11 or self.gamewon == 1)):
self.end()
self.start()
diff --git a/src/braille_lotto-activity/resources/braille_lotto/button.svg b/src/braille_lotto-activity/resources/braille_lotto/button.svg
index 608d077..c2a36cd 100644
--- a/src/braille_lotto-activity/resources/braille_lotto/button.svg
+++ b/src/braille_lotto-activity/resources/braille_lotto/button.svg
@@ -7,49 +7,16 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="208.17999"
- height="113.34"
- id="svg3098"
+ width="174.17999"
+ height="110.34"
+ id="svg3960"
version="1.1"
inkscape:version="0.48.0 r9654"
sodipodi:docname="button.svg">
<defs
- id="defs3">
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient3294"
- id="linearGradient3332"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.3737772,0,0,0.1148277,-145.55742,-124.02192)"
- x1="234.46304"
- y1="735.4422"
- x2="233.05591"
- y2="480.19824" />
- <linearGradient
- id="linearGradient3294">
- <stop
- id="stop3296"
- offset="0"
- style="stop-color:#cf4700;stop-opacity:0.29019609;" />
- <stop
- id="stop3298"
- offset="1"
- style="stop-color:#ffffff;stop-opacity:1;" />
- </linearGradient>
- <linearGradient
- y2="480.19824"
- x2="233.05591"
- y1="735.4422"
- x1="234.46304"
- gradientTransform="matrix(0.3737772,0,0,0.1148277,-145.55742,-124.02192)"
- gradientUnits="userSpaceOnUse"
- id="linearGradient3030"
- xlink:href="#linearGradient3294"
- inkscape:collect="always" />
- </defs>
+ id="defs3" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
@@ -69,14 +36,14 @@
inkscape:window-y="37"
inkscape:window-maximized="1" />
<metadata
- id="metadata3102">
+ id="metadata3964">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title />
+ <dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
@@ -84,38 +51,15 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
- transform="translate(0,-77.998269)">
- <g
- id="g3327"
- transform="matrix(2.3132409,0,0,1.3508219,237.89378,178.66758)"
- style="opacity:0.7">
- <rect
- rx="9.5005054"
- ry="9.5005054"
- y="-65.378021"
- x="-98.832886"
- height="65.000015"
- width="83.127678"
- id="rect3321"
- style="font-size:12px;fill:#fb8357;fill-opacity:1;fill-rule:evenodd" />
- <rect
- rx="6.7028937"
- ry="6.7028937"
- y="-63.386421"
- x="-96.841278"
- height="60.06572"
- width="78.367561"
- id="rect3323"
- style="font-size:12px;fill:#c27030;fill-opacity:1;fill-rule:evenodd" />
- <rect
- rx="7.2771926"
- ry="7.2771926"
- y="-63.386421"
- x="-96.841278"
- height="24.07522"
- width="78.367561"
- id="rect3325"
- style="font-size:12px;fill:url(#linearGradient3030);fill-opacity:1;fill-rule:evenodd" />
- </g>
+ transform="translate(0,-80.997761)">
+ <rect
+ style="fill:#d38d5f;fill-opacity:1;stroke:#000000;stroke-width:2.06761503;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
+ id="rect4098"
+ width="165.63531"
+ height="92.915855"
+ x="4.638341"
+ y="92.141853"
+ rx="22.963081"
+ ry="17.955" />
</g>
</svg>
diff --git a/src/braille_lotto-activity/resources/braille_lotto/button2.svg b/src/braille_lotto-activity/resources/braille_lotto/button2.svg
new file mode 100644
index 0000000..6771da6
--- /dev/null
+++ b/src/braille_lotto-activity/resources/braille_lotto/button2.svg
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="177.17999"
+ height="110.34"
+ id="svg3960"
+ version="1.1"
+ inkscape:version="0.48.0 r9654"
+ sodipodi:docname="button2.svg">
+ <defs
+ id="defs3" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.2"
+ inkscape:cx="6.25"
+ inkscape:cy="74.166666"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1256"
+ inkscape:window-height="701"
+ inkscape:window-x="0"
+ inkscape:window-y="37"
+ inkscape:window-maximized="1" />
+ <metadata
+ id="metadata3964">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-80.997761)">
+ <rect
+ style="fill:#d33e5f;fill-opacity:1;stroke:#000000;stroke-width:2.06356406;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline"
+ id="rect4098"
+ width="166.4727"
+ height="92.086571"
+ x="6.3029823"
+ y="89.639824"
+ rx="23.079172"
+ ry="17.794748" />
+ </g>
+</svg>
diff --git a/src/braille_lotto-activity/resources/braille_lotto/callout1.svg b/src/braille_lotto-activity/resources/braille_lotto/callout1.svg
index 547bb47..b4e130e 100644
--- a/src/braille_lotto-activity/resources/braille_lotto/callout1.svg
+++ b/src/braille_lotto-activity/resources/braille_lotto/callout1.svg
@@ -9,12 +9,12 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="85mm"
- height="54mm"
+ width="171.17999"
+ height="111.34"
id="svg3004"
version="1.1"
inkscape:version="0.48.0 r9654"
- sodipodi:docname="callout2 (copy).svg">
+ sodipodi:docname="callout1.svg">
<defs
id="defs3" />
<sodipodi:namedview
@@ -26,7 +26,7 @@
inkscape:pageshadow="2"
inkscape:zoom="1.2"
inkscape:cx="160"
- inkscape:cy="66.249999"
+ inkscape:cy="58.333332"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
@@ -43,17 +43,18 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
- id="layer1">
+ id="layer1"
+ transform="translate(0,-79.997721)">
<path
style="fill:#e6e6e6;fill-opacity:0.82352941;stroke:#0e181a;stroke-width:2.04655623;stroke-miterlimit:4;stroke-opacity:1;display:inline;enable-background:new"
- d="m 19.579809,17.681479 135.955361,0 c 2.38029,0 4.29656,8.578011 4.29656,19.23316 l -0.83791,10.247611 16.67124,59.61368 c -23.33333,-26.01149 -17.7496,12.56648 -20.12989,12.56648 l -135.955361,0 c -2.38029,0 -4.29654,-8.57797 -4.29654,-19.23315 l 0,-63.194621 c 0,-10.65515 1.91625,-19.23316 4.29654,-19.23316 z"
+ d="m 12.913142,84.348146 135.955358,0 c 2.38029,0 4.29656,8.578011 4.29656,19.233164 l -0.83791,10.24761 16.67124,59.61368 c -23.33333,-26.01149 -17.7496,12.56648 -20.12989,12.56648 l -135.955358,0 c -2.38029,0 -4.2965397,-8.57797 -4.2965397,-19.23315 l 0,-63.19462 c 0,-10.655154 1.9162497,-19.233164 4.2965397,-19.233164 z"
id="BUBBLE1"
sodipodi:nodetypes="cccccccccc"
inkscape:label="#BUBBLE1"
diff --git a/src/braille_lotto-activity/resources/braille_lotto/callout2.svg b/src/braille_lotto-activity/resources/braille_lotto/callout2.svg
index b9f88e9..1f801c2 100644
--- a/src/braille_lotto-activity/resources/braille_lotto/callout2.svg
+++ b/src/braille_lotto-activity/resources/braille_lotto/callout2.svg
@@ -9,12 +9,12 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="85mm"
- height="54mm"
+ width="165.17999"
+ height="110.34"
id="svg3004"
version="1.1"
inkscape:version="0.48.0 r9654"
- sodipodi:docname="callout1.svg">
+ sodipodi:docname="callout2.svg">
<defs
id="defs3" />
<sodipodi:namedview
@@ -26,7 +26,7 @@
inkscape:pageshadow="2"
inkscape:zoom="1.2"
inkscape:cx="160"
- inkscape:cy="66.249999"
+ inkscape:cy="58.333332"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
@@ -43,17 +43,18 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
+ <dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
- id="layer1">
+ id="layer1"
+ transform="translate(0,-80.998257)">
<path
style="fill:#e6e6e6;fill-opacity:0.82352941;stroke:#0e181a;stroke-width:2.04655623;stroke-miterlimit:4;stroke-opacity:1;display:inline;enable-background:new"
- d="m 174.70143,119.34241 -135.955354,0 c -2.38029,0 9.87188,-31.24753 -4.29656,-19.23316 l -14.995,10.58572 17.495,-63.780344 c 0,-10.65518 -0.58373,-29.23315 1.79656,-29.23315 l 135.955354,0 c 2.38029,0 4.29654,8.57797 4.29654,19.23315 l 0,63.194624 c 0,10.65514 -1.91625,19.23316 -4.29654,19.23316 z"
+ d="m 158.86809,187.67575 -135.955348,0 c -2.38029,0 9.87188,-31.24753 -4.29656,-19.23316 L 3.6211826,179.02831 21.116182,115.24796 c 0,-10.65518 -0.58373,-29.23315 1.79656,-29.23315 l 135.955348,0 c 2.38029,0 4.29654,8.57797 4.29654,19.23315 l 0,63.19463 c 0,10.65514 -1.91625,19.23316 -4.29654,19.23316 z"
id="BUBBLE1"
sodipodi:nodetypes="cccccccccc"
inkscape:label="#BUBBLE1"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]