[gcompris] mining: determine game state at tutorial start
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris] mining: determine game state at tutorial start
- Date: Tue, 25 Sep 2012 22:13:10 +0000 (UTC)
commit 593e107fa1e8a20922363a449d596d1345bcbdc7
Author: Peter Albrecht <pa-dev gmx de>
Date: Mon Sep 24 21:25:16 2012 +0200
mining: determine game state at tutorial start
Since the user can start the tutorial, whenever she/he likes to, the
tutorial start must determine, at which game state (zoom in, collect,
zoom out) the user is.
src/mining-activity/mining.py | 22 ++++++++++++++++++----
src/mining-activity/mining_tutorial.py | 11 ++++++-----
2 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/src/mining-activity/mining.py b/src/mining-activity/mining.py
index 11596b3..21dd2e4 100644
--- a/src/mining-activity/mining.py
+++ b/src/mining-activity/mining.py
@@ -243,7 +243,21 @@ class Gcompris_mining:
self.is_tutorial_enabled = True
self.tutorial.start()
nuggetArea = Area(self.nugget.get_bounds())
- self.tutorial.set_tutorial_state('move to', event.x_root, event.y_root, nuggetArea.center_x, nuggetArea.center_y)
+
+ # determine state, to start the tutorial from
+ if self.need_new_nugget:
+ # we have collected the nugget, and need to zoom out
+ self.tutorial.set_tutorial_state('zoom out', True)
+
+ elif self.nugget.is_visible():
+ # the nugget needs to be collected
+ self.tutorial.set_tutorial_state('click', True)
+ else:
+ # we are at the beginning: 'move to' and then 'zoom in'
+ self.tutorial.set_tutorial_state('move to', True, event.x_root, event.y_root, nuggetArea.center_x, nuggetArea.center_y)
+
+ # we processed this click event
+ return True
def show_teacher_icon(self):
@@ -286,7 +300,7 @@ class Gcompris_mining:
# a^2 + b^2 <= c^2
if (x - nx) * (x - nx) + (y - ny) * (y - ny) <= self.min_nugget_approach * self.min_nugget_approach:
# the mouse cursor is close enough, go to next tutorial step
- self.tutorial.set_tutorial_state('zoom in')
+ self.tutorial.set_tutorial_state('zoom in', False)
else:
# if we still want to show the user, where to move the mouse pointer to, we need to
@@ -318,7 +332,7 @@ class Gcompris_mining:
elif state == 'max':
if self.is_tutorial_enabled:
# proceed to next tutorial step
- self.tutorial.set_tutorial_state('click')
+ self.tutorial.set_tutorial_state('click', False)
self.nugget.show()
@@ -379,7 +393,7 @@ class Gcompris_mining:
self.need_new_nugget = True
if self.is_tutorial_enabled:
- self.tutorial.set_tutorial_state('zoom out')
+ self.tutorial.set_tutorial_state('zoom out', False)
def update_lorry(self):
diff --git a/src/mining-activity/mining_tutorial.py b/src/mining-activity/mining_tutorial.py
index 98e887d..dd1c851 100644
--- a/src/mining-activity/mining_tutorial.py
+++ b/src/mining-activity/mining_tutorial.py
@@ -68,7 +68,7 @@ class MiningTutorial:
return self.current_state
- def set_tutorial_state(self, state, *special_state_arguments):
+ def set_tutorial_state(self, state, dont_check_previous_state, *special_state_arguments):
"""
Set the current state of the tutorial
state: the state to set, valid values:
@@ -76,6 +76,7 @@ class MiningTutorial:
- 'zoom in'
- 'click'
- 'zoom out'
+ dont_check_previous_state: should we check the previous state?
special_state_arguments: special arguments for the particular state
"""
@@ -85,13 +86,13 @@ class MiningTutorial:
# advance to next state, if current state matches
if state == 'move to':
- if self.current_state == 'start':
+ if dont_check_previous_state or self.current_state == 'start':
self.cursor.start(*special_state_arguments)
self.current_state = state
elif state == 'zoom in':
- if self.current_state == 'move to':
+ if dont_check_previous_state or self.current_state == 'move to':
self.cursor.stop()
self.mouse.start_zoom('in')
@@ -100,7 +101,7 @@ class MiningTutorial:
self.current_state = state
elif state == 'click':
- if self.current_state == 'zoom in':
+ if dont_check_previous_state or self.current_state == 'zoom in':
self.mouse.stop()
self.touchpad.stop()
@@ -110,7 +111,7 @@ class MiningTutorial:
self.current_state = state
elif state == 'zoom out':
- if self.current_state == 'click':
+ if dont_check_previous_state or self.current_state == 'click':
self.mouse.stop()
self.touchpad.stop()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]