Commit 5151b227 authored by SrishAkaTux's avatar SrishAkaTux

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

parent e81fd302
# 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
# it under the terms of the GNU General Public License as published by
......@@ -89,6 +89,11 @@ class Gcompris_braille_fun:
# automaticaly.
self.root = goocanvas.Group(parent =
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
gcompris.score.start(gcompris.score.STYLE_NOTE, 530, 460,
......@@ -121,77 +126,80 @@ class Gcompris_braille_fun:
25000 + level * 9000,
250,
goocanvas.ANIMATE_FREEZE)
for index in range (level) :
#Select a random letter and append it to self.letter_array
letter = random.choice(string.letters)
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
self.alphabet_horizontal = goocanvas.Text(
parent = self.root,
#Display alphabets for TUX_PLANE horizontally and vertically
lengthString = len(self.animateString)
for index in range(lengthString):
self.alphabet_horizontal = goocanvas.Text(
parent = self.horizontalTextRoot,
x = 50 * index ,
y = 60.0 ,
text=self.letter_array[index],
text = self.animateString[index],
fill_color="black",
anchor = gtk.ANCHOR_CENTER,
alignment = pango.ALIGN_CENTER,
font = 'SANS 50'
)
#Display animated or moving letters horizontally
self.alphabet_horizontal.animate(900,
5,
1,
1,
True,
20000 + level * 16000,
250,
goocanvas.ANIMATE_FREEZE)
#Display alphabets vertically
self.alphabet_vertical = goocanvas.Text(
parent = self.root,
self.alphabet_vertical = goocanvas.Text(
parent = self.verticalTextRoot,
x=50.0 + 50 * index ,
y=130.0 ,
text=self.letter_array[index],
text=self.animateString[index],
fill_color="black",
anchor = gtk.ANCHOR_CENTER,
alignment = pango.ALIGN_CENTER,
font = 'SANS 50'
)
self.alphabet_array.append(self.alphabet_vertical)
self.alphabet_array.append(self.alphabet_vertical)
#Display animated or falling letters
self.alphabet_vertical.animate(-20 + 30 * index,
410,
#Animate or move letters horizontally and vertically
self.horizontalTextRoot.animate(900,
5,
1,
1,
True,
30000 + level * 5000,
20000 + level * 16000,
250,
goocanvas.ANIMATE_FREEZE)
#To call a function when animation finishes
self.alphabet_vertical.connect("animation-finished", self.animationFinished)
#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)
self.verticalTextRoot.animate(5,
415,
1,
1,
True,
30000 + level * 5000,
250,
goocanvas.ANIMATE_FREEZE)
#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)
#To call a function when animation finishes
self.verticalTextRoot.connect("animation-finished", self.animationFinished)
#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):
self.letter = letter
......@@ -229,6 +237,8 @@ class Gcompris_braille_fun:
def end(self):
# Remove the root item removes all the others inside it
self.root.remove()
self.horizontalTextRoot.remove()
self.verticalTextRoot.remove()
def ok(self):
print("braille_fun ok.")
......@@ -239,9 +249,13 @@ class Gcompris_braille_fun:
gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
"braille_fun/hillside.svg")
self.root.props.visibility = goocanvas.ITEM_VISIBLE
self.horizontalTextRoot.props.visibility = goocanvas.ITEM_VISIBLE
self.verticalTextRoot.props.visibility = goocanvas.ITEM_VISIBLE
self.mapActive = False
else :
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.gcomprisBoard.canvas.get_root_item())
gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
......@@ -281,7 +295,6 @@ class Gcompris_braille_fun:
self.tile_index_array = []
self.counter = 0
def increment_level(self):
self.declare()
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 @@
author="your name here"
boarddir=""
demo="1">
<_title>set a title for braille_fun</_title>
<_description>set a description for braille_fun</_description>
<_prerequisite>set a prerequisite for braille_fun</_prerequisite>
<_goal>set a goal for braille_fun</_goal>
<_manual>set a manual for braille_fun</_manual>
<_credit>set a credit for braille_fun</_credit>
<_title>Braille Fun</_title>
<_description>Braille the falling letters</_description>
<_prerequisite>Braille Alphabet Codes</_prerequisite>
<_goal></_goal>
<_manual>Braille code the tile for the corresponding falling letters.Check the braille chart by clicking on the toggle button for help.</_manual>
<_credit></_credit>
</Board>
<Data directory=""/>
</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