[gcompris/gcomprismusic] added more levels



commit 61d0d8943d2c083ba5aaec5df50d4a3d2e0de772
Author: Karthik Subramanian <itskarthik s gmail com>
Date:   Tue Jul 5 23:07:00 2011 +0530

    added more levels

 src/piano-activity/piano.py |   64 +++++++++++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 17 deletions(-)
---
diff --git a/src/piano-activity/piano.py b/src/piano-activity/piano.py
index 03785cc..9f72ab9 100644
--- a/src/piano-activity/piano.py
+++ b/src/piano-activity/piano.py
@@ -84,22 +84,26 @@ class Gcompris_piano:
                                     self.gcomprisBoard.canvas.get_root_item())
 
     self.gcomprisBoard.level = 1
-    self.gcomprisBoard.maxlevel = 3
+    self.gcomprisBoard.maxlevel = 5
     self.gcomprisBoard.sublevel = 1
     self.gcomprisBoard.number_of_sublevel = 1
     gcompris.bar_set(gcompris.BAR_LEVEL)
     gcompris.bar_set_level(self.gcomprisBoard)
 
     self.cmajor = ['c2', 'd2', 'e2', 'f2', 'g2', 'a2', 'b2', 'c3','c3','b2', 'a2', 'g2', 'f2', 'e2', 'd2', 'c2']
-    self.dmajor = ['e2', 'fh2' , 'g2', 'a2', 'b2', 'ch3', 'd3', 'd3', 'ch3','b2','a2','g2','fh2','e2']
-
+    self.dmajor = ['e2', 'fh2' , 'g2', 'a2', 'b2', 'ch3', 'd3', 'e3', 'e3', 'd3', 'ch3','b2','a2','g2','fh2','e2']
+    self.mohanam = ['c2', 'd2', 'e2', 'g2', 'a2', 'c3', 'c3', 'a2', 'g2', 'e2', 'd2', 'c2']
+    self.bday = ['g2', 'g2', 'a2', 'g2', 'c3', 'b2', 'g2', 'g2', 'a2', 'g2', 'd3','c3']
+    self.noteslength = 15
+    self.pianosize = 1    
 
     self.read_data()
-    goocanvas.Text(
+    self.titletext = goocanvas.Text(
       parent = self.rootitem,
       x = 400.0,
       y = 100.0,
       text = _("Piano"),
+      font = 'sans bold 20',
       fill_color = "black",
       anchor = gtk.ANCHOR_CENTER,
       alignment = pango.ALIGN_CENTER
@@ -269,13 +273,13 @@ class Gcompris_piano:
     if self.gcomprisBoard.level == 2:
       self.noteno += 1
       self.dochecknotes(notename)
-      if self.noteno == 15:
+      if self.noteno == self.noteslength:
           gcompris.bonus.display(gcompris.bonus.WIN,gcompris.bonus.FLOWER)
           self.noteno = 0         
     elif self.gcomprisBoard.level == 3:
       self.noteno += 1
       self.dochecknotes(notename)
-      if self.noteno == 15:
+      if self.noteno == self.noteslength:
           gcompris.bonus.display(gcompris.bonus.WIN,gcompris.bonus.FLOWER)
           self.noteno = 0
 
@@ -289,7 +293,7 @@ class Gcompris_piano:
     #Play the corresponding note only if present in the allowed array
     if strn in allowed1:
       self.play_note(strn, self.pianobg1)
-    elif strn in allowed2 and self.gcomprisBoard.level == 2:
+    elif strn in allowed2 and self.gcomprisBoard.level > 2:
       self.play_note(strn, self.pianobg2)
 
     print("Gcompris_piano key press keyval=%i %s" % (keyval, strn))
@@ -307,12 +311,18 @@ class Gcompris_piano:
   def dochecknotes(self, notename):
   
     if self.gcomprisBoard.level == 2:
-      if self.cmajor [self.noteno] == notename:
+      if self.mohanam [self.noteno] == notename:
         print self.noteno
         return True
       else:
         self.noteno = 0
     elif self.gcomprisBoard.level == 3:
+      if self.cmajor [self.noteno] == notename:
+        print self.noteno
+        return True
+      else:
+        self.noteno = 0
+    elif self.gcomprisBoard.level == 4:
       if self.dmajor [self.noteno] == notename:
         print self.noteno
         return True
@@ -324,23 +334,43 @@ class Gcompris_piano:
     self.gcomprisBoard.level = level
     gcompris.bar_set_level(self.gcomprisBoard);
     if level == 1 : 
+       self.setpiano(1)
+       self.pianosize = 1
        self.notestext.props.text = 'Freeplay!'
-    elif level == 2 : 
-      
+    elif level == 2 :
+       self.setpiano(1)
+       self.pianosize = 1
+       self.noteslength = 11  
+       self.titletext.props.text = ' Pentatonic Scale (Mohanam)'
+       self.notestext.props.text = 'C D E G A C C A G E D C'
+    elif level == 3 : 
+       self.setpiano(1)
+       self.pianosize = 1
+       self.noteslength = 15
+       self.titletext.props.text = ' C Major Scale ' 
        self.notestext.props.text = 'C D E F G A B C C B A G F E D C'
-    elif level == 3 :
+    elif level == 4 :
+       self.noteslength = 15
+       self.setpiano(2)
+       self.pianosize = 2
+       self.titletext.props.text = ' D Major Scale '
+       self.notestext.props.text = 'E F# G A B C# D E E D C# B A G F# E'
+    elif level == 5:
+       self.noteslength = 11
        self.setpiano(2)
-       self.notestext.props.text = 'E F# G A B C# D D C# B A G F# E'
+       self.pianosize = 2
+       self.titletext.props.text = 'Happy Birthday tune (Pentatonic Scale)'
+       self.notestext.props.text = 'G G A G C3 B G G A G D3 C3'
     self.noteno = 0
 
-  def setpiano(self, size):
-    if size == 1:
+  def setpiano(self, nextsize):
+    if self.pianosize == 2 and nextsize == 1:
       self.pianopic2.props.visibility = goocanvas.ITEM_INVISIBLE
-      self.pianopic1.translate(150, 0)
+      self.pianopic1.props.x = 275
       self.pianobg1.translate(150, 0)
       self.pianolabel.translate(150, 0)
-    elif size == 2:
+    elif self.pianosize == 1 and nextsize == 2:
      self.pianopic2.props.visibility = goocanvas.ITEM_VISIBLE
-     self.pianopic1.translate(-150, 0)
+     self.pianopic1.props.x = 125
      self.pianolabel.translate(-150, 0)
      self.pianobg1.translate(-150, 0)



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