Commit 5151b227 authored by SrishAkaTux's avatar SrishAkaTux

Letters are no more dancing.Smooth group animation|Added Manual

parent e81fd302
# gcompris - braille_fun.py # gcompris - braille_fun.py
# #
# Copyright (C) 2003, 2008 Bruno Coudoin # Copyright (C) 2003, 2008 Bruno Coudoin | Srishti Sethi
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
...@@ -89,6 +89,11 @@ class Gcompris_braille_fun: ...@@ -89,6 +89,11 @@ class Gcompris_braille_fun:
# automaticaly. # automaticaly.
self.root = goocanvas.Group(parent = self.root = goocanvas.Group(parent =
self.gcomprisBoard.canvas.get_root_item()) self.gcomprisBoard.canvas.get_root_item())
#To create a group item for horizontal and vertical text
self.horizontalTextRoot = goocanvas.Group(parent =
self.gcomprisBoard.canvas.get_root_item())
self.verticalTextRoot = goocanvas.Group(parent =
self.gcomprisBoard.canvas.get_root_item())
#Display the sublevel #Display the sublevel
gcompris.score.start(gcompris.score.STYLE_NOTE, 530, 460, gcompris.score.start(gcompris.score.STYLE_NOTE, 530, 460,
...@@ -121,77 +126,80 @@ class Gcompris_braille_fun: ...@@ -121,77 +126,80 @@ class Gcompris_braille_fun:
25000 + level * 9000, 25000 + level * 9000,
250, 250,
goocanvas.ANIMATE_FREEZE) goocanvas.ANIMATE_FREEZE)
for index in range (level) : for index in range (level) :
#Select a random letter and append it to self.letter_array #Select a random letter and append it to self.letter_array
letter = random.choice(string.letters) letter = random.choice(string.letters)
self.letter_array.append(letter.upper()) self.letter_array.append(letter.upper())
self.animateString = "".join(self.letter_array)
#Display rectangle for braille tile
goocanvas.Rect(parent=self.root,
x = 300 + 90 * index,
y = 155,
width = 80 ,
height = 100,
stroke_color = "black",
fill_color = "#DfDfDf",
line_width=2.0)
#Naming Objects from Variable Class Names and appending
#to array self.tile_array
self.obj = "self.obj" + str(index)
self.tile_array.append(self.obj)
#Defining Object to BrailleChar Instance to produce braille_tile
self.tile_array[index] = BrailleChar(self.root, 300 + 90 * index , 150, 80,
'',COLOR_ON ,COLOR_OFF, "#DfDfDf","black",
True, True ,True, callback = self.letter_change)
#Display alphabets for TUX_PLANE horizontally #Display alphabets for TUX_PLANE horizontally and vertically
self.alphabet_horizontal = goocanvas.Text( lengthString = len(self.animateString)
parent = self.root, for index in range(lengthString):
self.alphabet_horizontal = goocanvas.Text(
parent = self.horizontalTextRoot,
x = 50 * index , x = 50 * index ,
y = 60.0 , y = 60.0 ,
text=self.letter_array[index], text = self.animateString[index],
fill_color="black", fill_color="black",
anchor = gtk.ANCHOR_CENTER, anchor = gtk.ANCHOR_CENTER,
alignment = pango.ALIGN_CENTER, alignment = pango.ALIGN_CENTER,
font = 'SANS 50' font = 'SANS 50'
) )
#Display animated or moving letters horizontally self.alphabet_vertical = goocanvas.Text(
self.alphabet_horizontal.animate(900, parent = self.verticalTextRoot,
5,
1,
1,
True,
20000 + level * 16000,
250,
goocanvas.ANIMATE_FREEZE)
#Display alphabets vertically
self.alphabet_vertical = goocanvas.Text(
parent = self.root,
x=50.0 + 50 * index , x=50.0 + 50 * index ,
y=130.0 , y=130.0 ,
text=self.letter_array[index], text=self.animateString[index],
fill_color="black", fill_color="black",
anchor = gtk.ANCHOR_CENTER, anchor = gtk.ANCHOR_CENTER,
alignment = pango.ALIGN_CENTER, alignment = pango.ALIGN_CENTER,
font = 'SANS 50' font = 'SANS 50'
) )
self.alphabet_array.append(self.alphabet_vertical) self.alphabet_array.append(self.alphabet_vertical)
#Display animated or falling letters #Animate or move letters horizontally and vertically
self.alphabet_vertical.animate(-20 + 30 * index, self.horizontalTextRoot.animate(900,
410, 5,
1, 1,
1, 1,
True, True,
30000 + level * 5000, 20000 + level * 16000,
250, 250,
goocanvas.ANIMATE_FREEZE) goocanvas.ANIMATE_FREEZE)
#To call a function when animation finishes self.verticalTextRoot.animate(5,
self.alphabet_vertical.connect("animation-finished", self.animationFinished) 415,
1,
#Display rectangle for braille tile 1,
goocanvas.Rect(parent=self.root, True,
x = 300 + 90 * index, 30000 + level * 5000,
y = 155, 250,
width = 80 , goocanvas.ANIMATE_FREEZE)
height = 100,
stroke_color = "black",
fill_color = "#DfDfDf",
line_width=2.0)
#Naming Objects from Variable Class Names and appending #To call a function when animation finishes
#to array self.tile_array self.verticalTextRoot.connect("animation-finished", self.animationFinished)
self.obj = "self.obj" + str(index)
self.tile_array.append(self.obj)
#Defining Object to BrailleChar Instance to produce braille_tile
self.tile_array[index] = BrailleChar(self.root, 300 + 90 * index , 150, 80,
'',COLOR_ON ,COLOR_OFF, "#DfDfDf","black",
True, True ,True, callback = self.letter_change)
def letter_change(self, letter): def letter_change(self, letter):
self.letter = letter self.letter = letter
...@@ -229,6 +237,8 @@ class Gcompris_braille_fun: ...@@ -229,6 +237,8 @@ class Gcompris_braille_fun:
def end(self): def end(self):
# Remove the root item removes all the others inside it # Remove the root item removes all the others inside it
self.root.remove() self.root.remove()
self.horizontalTextRoot.remove()
self.verticalTextRoot.remove()
def ok(self): def ok(self):
print("braille_fun ok.") print("braille_fun ok.")
...@@ -239,9 +249,13 @@ class Gcompris_braille_fun: ...@@ -239,9 +249,13 @@ class Gcompris_braille_fun:
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(), gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
"braille_fun/hillside.svg") "braille_fun/hillside.svg")
self.root.props.visibility = goocanvas.ITEM_VISIBLE self.root.props.visibility = goocanvas.ITEM_VISIBLE
self.horizontalTextRoot.props.visibility = goocanvas.ITEM_VISIBLE
self.verticalTextRoot.props.visibility = goocanvas.ITEM_VISIBLE
self.mapActive = False self.mapActive = False
else : else :
self.root.props.visibility = goocanvas.ITEM_INVISIBLE self.root.props.visibility = goocanvas.ITEM_INVISIBLE
self.horizontalTextRoot.props.visibility = goocanvas.ITEM_INVISIBLE
self.verticalTextRoot.props.visibility = goocanvas.ITEM_INVISIBLE
self.rootitem = goocanvas.Group(parent= self.rootitem = goocanvas.Group(parent=
self.gcomprisBoard.canvas.get_root_item()) self.gcomprisBoard.canvas.get_root_item())
gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item()) gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
...@@ -281,7 +295,6 @@ class Gcompris_braille_fun: ...@@ -281,7 +295,6 @@ class Gcompris_braille_fun:
self.tile_index_array = [] self.tile_index_array = []
self.counter = 0 self.counter = 0
def increment_level(self): def increment_level(self):
self.declare() self.declare()
gcompris.sound.play_ogg("sounds/bleep.wav") gcompris.sound.play_ogg("sounds/bleep.wav")
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
author="your name here" author="your name here"
boarddir="" boarddir=""
demo="1"> demo="1">
<_title>set a title for braille_fun</_title> <_title>Braille Fun</_title>
<_description>set a description for braille_fun</_description> <_description>Braille the falling letters</_description>
<_prerequisite>set a prerequisite for braille_fun</_prerequisite> <_prerequisite>Braille Alphabet Codes</_prerequisite>
<_goal>set a goal for braille_fun</_goal> <_goal></_goal>
<_manual>set a manual for braille_fun</_manual> <_manual>Braille code the tile for the corresponding falling letters.Check the braille chart by clicking on the toggle button for help.</_manual>
<_credit>set a credit for braille_fun</_credit> <_credit></_credit>
</Board> </Board>
<Data directory=""/> <Data directory=""/>
</GCompris> </GCompris>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment