[gcompris: 53/111] fixed a few issues in land_safe



commit b6b6ccfbb3525c369c4c014a94fe9527dec38673
Author: serah <serah4291 gmail com>
Date:   Thu Jul 12 19:49:38 2012 +0530

    fixed a few issues in land_safe

 src/land_safe-activity/land_safe.py                |   59 ++++++++++---------
 src/land_safe-activity/land_safe.xml.in            |    2 +-
 .../resources/land_safe/Makefile.am                |   11 ++--
 src/land_safe-activity/resources/land_safe/README  |    2 +
 .../resources/land_safe/background1.jpg            |  Bin 0 -> 12809 bytes
 .../resources/land_safe/background2.jpg            |  Bin 0 -> 11792 bytes
 .../resources/land_safe/background3.jpg            |  Bin 0 -> 13063 bytes
 .../resources/land_safe/background4.jpg            |  Bin 0 -> 53189 bytes
 .../resources/land_safe/land1.png                  |  Bin 121713 -> 117358 bytes
 .../resources/land_safe/landing_area_green.png     |  Bin 0 -> 5297 bytes
 .../resources/land_safe/landing_area_red.png       |  Bin 0 -> 3590 bytes
 11 files changed, 40 insertions(+), 34 deletions(-)
---
diff --git a/src/land_safe-activity/land_safe.py b/src/land_safe-activity/land_safe.py
index c275200..993bcb1 100644
--- a/src/land_safe-activity/land_safe.py
+++ b/src/land_safe-activity/land_safe.py
@@ -46,7 +46,8 @@ class Gcompris_land_safe:
     self.game_complete = False
 
   def start(self):
-    self.board_paused = True
+    self.board_paused = False
+    self.game_start = False
     # Create our rootitem. We put each canvas item in it so at the end we
     # only have to kill it. The canvas deletes all the items it contains
     # automaticaly.
@@ -56,7 +57,7 @@ class Gcompris_land_safe:
 
     # Set a background image
     level = str(self.gcomprisBoard.level)
-    image = 'land_safe/background'+level+'.png'
+    image = 'land_safe/background'+level+'.jpg'
     gcompris.set_background(self.gcomprisBoard.canvas.get_root_item(),
                             image)
 
@@ -131,17 +132,15 @@ class Gcompris_land_safe:
   def next_level(self):
     if self.gcomprisBoard.level < self.gcomprisBoard.maxlevel:
       self.gcomprisBoard.level += 1
-    else:
-      self.gcomprisBoard.level = 1
 
   def ready_button(self, rootitem):
     if self.gcomprisBoard.level == 1:
      intro = _("Use the up and down keys to control the thrust"
                "\nUse the right and left keys to control direction."
                "\nYou must drive Tux's ship towards the landing platform."
-               "\nThere is an indicator that shows if the velocity is safe to land.")
+               "\nThe landing platform turns green when the velocity is safe to land")
      intro += "\n\n"
-     intro += "Click on me when you are ready."
+     intro += "Click on me or press the Return key when you are ready."
     else:
       intro = _('I am ready!')
 
@@ -170,13 +169,14 @@ class Gcompris_land_safe:
       fill_color_rgba = 0xCCCCCC44L)
     gcompris.utils.item_focus_init(self.ready_back, None)
     gcompris.utils.item_focus_init(self.ready_text, self.ready_back)
-    self.ready_back.connect('button_press_event', self.ready_event, False)
+    self.ready_back.connect('button_press_event', self.ready_event)
 
 
-  def ready_event(self, widget, target, event, state):
+  def ready_event(self, widget, target, event):
     self.ready_back.props.visibility = goocanvas.ITEM_INVISIBLE
     self.ready_text.props.visibility = goocanvas.ITEM_INVISIBLE
-    self.pause(state)
+    self.game_start = True
+    self.space_ship.initiate()
 
 class Spaceship:
   """Class for the spaceship"""
@@ -201,13 +201,22 @@ class Spaceship:
 
     # Load landing area
     self.land_x = random.randrange(100, 400)
-    landing = goocanvas.Image(
+    self.landing_red = goocanvas.Image(
+      parent = self.land_rootitem,
+      pixbuf = gcompris.utils.load_pixmap("land_safe/landing_area_red.png"),
+      width = 145 - (self.level * 12),
+      x = self.land_x,
+      y = 365)
+    self.landing_red.lower(self.flame_rootitem)
+    self.landing_red.props.visibility = goocanvas.ITEM_INVISIBLE
+
+    self.landing_green = goocanvas.Image(
       parent = self.land_rootitem,
-      pixbuf = gcompris.utils.load_pixmap("land_safe/landing_area.png"),
+      pixbuf = gcompris.utils.load_pixmap("land_safe/landing_area_green.png"),
       width = 145 - (self.level * 12),
       x = self.land_x,
       y = 365)
-    landing.lower(self.flame_rootitem)
+    self.landing_green.lower(self.flame_rootitem)
 
     # Load spaceship
     pixbuf = gcompris.utils.load_pixmap("land_safe/rocket.png")
@@ -228,13 +237,14 @@ class Spaceship:
     # Load fuel, altitude and landing area
     self.info = Display(self, rootitem)
 
-    self.initiate()
-
   def initiate(self):
     # incase of landing return false
     gobject.timeout_add(30, self.spaceship_movement)
 
   def handle_key(self, key):
+    if key == gtk.keysyms.Return and self.game.game_start == False:
+      self.game.ready_event(1,2,3)
+
     if self.game.board_paused:
       return
 
@@ -416,7 +426,7 @@ class Display:
       x = 20,
       y = 20,
       fill_color = "white",
-      text = _("Altitude : "))
+      text = _("Height : "))
 
     # initiate text for altitude
     self.alt_text = goocanvas.Text(
@@ -424,7 +434,7 @@ class Display:
       x = 100,
       y = 20,
       fill_color = "white",
-      text = _('start'))
+      text = _('354'))
 
     # text for fuel display
     fuel_text = goocanvas.Text(
@@ -474,15 +484,6 @@ class Display:
       fill_color = 'white',
       text = _('0'))
 
-    # Indicator for safe display
-    self.safe_land = goocanvas.Rect(
-      parent = rootitem,
-      x = 130,
-      y = 62,
-      width = 17,
-      height = 15,
-      stroke_color = "grey")
-
     self.ship_instance = ship_instance
     self.key = 0
     self.stop_consumtion = False
@@ -531,8 +532,10 @@ class Display:
 
   def set_velocity(self):
     self.velocity.set_property('text',int(self.vel * 10))
-    if 0 <= int(self.vel * 10) < 8:
-      self.safe_land.set_property('fill_color', 'green')
+    if int(self.vel * 10) < 8:
+      self.ship_instance.landing_red.props.visibility = goocanvas.ITEM_INVISIBLE
+      self.ship_instance.landing_green.props.visibility = goocanvas.ITEM_VISIBLE
     else:
-      self.safe_land.set_property('fill_color', 'red')
+      self.ship_instance.landing_green.props.visibility = goocanvas.ITEM_INVISIBLE
+      self.ship_instance.landing_red.props.visibility = goocanvas.ITEM_VISIBLE
 
diff --git a/src/land_safe-activity/land_safe.xml.in b/src/land_safe-activity/land_safe.xml.in
index fb3c0b8..6a4e133 100644
--- a/src/land_safe-activity/land_safe.xml.in
+++ b/src/land_safe-activity/land_safe.xml.in
@@ -12,7 +12,7 @@
         <title>Land Safe</title>
         <description>Understanding acceleration due to gravity.</description>
         <goal>Station the spaceship in the green landing area.</goal>
-        <manual>
+        <manual xml:space="preserve">
         Acceleration due to gravity experienced by the spaceship is directly proportional to the mass of
         the planet and inversely proportional to the square of the distance from the centre of the planet.
         Thus, with every planet the acceleration will differ and as the spaceship comes closer and closer
diff --git a/src/land_safe-activity/resources/land_safe/Makefile.am b/src/land_safe-activity/resources/land_safe/Makefile.am
index 3925834..51b567f 100644
--- a/src/land_safe-activity/resources/land_safe/Makefile.am
+++ b/src/land_safe-activity/resources/land_safe/Makefile.am
@@ -1,9 +1,9 @@
 imgdir = $(pkgdatadir)/@PACKAGE_DATA_DIR@/land_safe
 img_DATA = \
-	background1.png \
-	background2.png \
-	background3.png \
-	background4.png \
+	background1.jpg \
+	background2.jpg \
+	background3.jpg \
+	background4.jpg \
 	crash.png \
 	flame1.png \
 	flame2.png \
@@ -14,7 +14,8 @@ img_DATA = \
 	land2.png \
 	land3.png \
 	land4.png \
-	landing_area.png \
+	landing_area_green.png \
+	landing_area_red.png \
 	rocket.png 
 
 EXTRA_DIST = $(img_DATA)
diff --git a/src/land_safe-activity/resources/land_safe/README b/src/land_safe-activity/resources/land_safe/README
new file mode 100644
index 0000000..326f34b
--- /dev/null
+++ b/src/land_safe-activity/resources/land_safe/README
@@ -0,0 +1,2 @@
+The rocket has been taken from openclipart.org and modified according to requirement.
+
diff --git a/src/land_safe-activity/resources/land_safe/background1.jpg b/src/land_safe-activity/resources/land_safe/background1.jpg
new file mode 100644
index 0000000..373e0ea
Binary files /dev/null and b/src/land_safe-activity/resources/land_safe/background1.jpg differ
diff --git a/src/land_safe-activity/resources/land_safe/background2.jpg b/src/land_safe-activity/resources/land_safe/background2.jpg
new file mode 100644
index 0000000..b81248b
Binary files /dev/null and b/src/land_safe-activity/resources/land_safe/background2.jpg differ
diff --git a/src/land_safe-activity/resources/land_safe/background3.jpg b/src/land_safe-activity/resources/land_safe/background3.jpg
new file mode 100644
index 0000000..728fe2c
Binary files /dev/null and b/src/land_safe-activity/resources/land_safe/background3.jpg differ
diff --git a/src/land_safe-activity/resources/land_safe/background4.jpg b/src/land_safe-activity/resources/land_safe/background4.jpg
new file mode 100644
index 0000000..4f277f4
Binary files /dev/null and b/src/land_safe-activity/resources/land_safe/background4.jpg differ
diff --git a/src/land_safe-activity/resources/land_safe/land1.png b/src/land_safe-activity/resources/land_safe/land1.png
index e33aa8e..59de1d5 100644
Binary files a/src/land_safe-activity/resources/land_safe/land1.png and b/src/land_safe-activity/resources/land_safe/land1.png differ
diff --git a/src/land_safe-activity/resources/land_safe/landing_area_green.png b/src/land_safe-activity/resources/land_safe/landing_area_green.png
new file mode 100644
index 0000000..b4d1fba
Binary files /dev/null and b/src/land_safe-activity/resources/land_safe/landing_area_green.png differ
diff --git a/src/land_safe-activity/resources/land_safe/landing_area_red.png b/src/land_safe-activity/resources/land_safe/landing_area_red.png
new file mode 100644
index 0000000..d7144f8
Binary files /dev/null and b/src/land_safe-activity/resources/land_safe/landing_area_red.png differ



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