Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-06-30 13:37:37 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-06-30 13:37:37 (GMT)
commit0a0ae1921e458aa61caa6a8689c65b22e3e25217 (patch)
tree5a972f327c20c1ffff58551f0d0c22c542cd8def
parentea15dddfcec90baa2fd760c6d90dc7af089de08b (diff)
adding offsets to challenges to align turtle starting position
-rw-r--r--TurtleConfusionActivity.py22
-rw-r--r--challenges/offsets35
2 files changed, 56 insertions, 1 deletions
diff --git a/TurtleConfusionActivity.py b/TurtleConfusionActivity.py
index c966ffe..3aa9cef 100644
--- a/TurtleConfusionActivity.py
+++ b/TurtleConfusionActivity.py
@@ -911,6 +911,20 @@ class TurtleConfusionActivity(activity.Activity):
"""
for i in range(40):
level_files.append('confusion-%d' % (i+1))
+
+ '''
+ '''
+ self.offsets = {}
+ offset_fd = open(os.path.join(activity.get_bundle_path(), 'challenges',
+ 'offsets'))
+ for line in offset_fd:
+ try:
+ idx, offsets = line.strip('\n').split(':')
+ xoffset, yoffset = offsets.split(',')
+ self.offsets[int(idx)] = (int(xoffset), int(yoffset))
+ except ValueError:
+ pass
+ offset_fd.close()
return level_files
def _levels_cb(self, combobox=None):
@@ -937,7 +951,13 @@ class TurtleConfusionActivity(activity.Activity):
activity.get_bundle_path(), 'images',
'turtle-a.png'))
# Slight offset to account for stroke width
- self.tw.canvas.setxy(-2.5, -2.5, pendown=False)
+ if self._level + 1 in self.offsets:
+ xoffset = self.offsets[self._level + 1][0]
+ yoffset = self.offsets[self._level + 1][1]
+ else:
+ xoffset = 0
+ yoffset = 0
+ self.tw.canvas.setxy(-2.5 + xoffset, -2.5 + yoffset, pendown=False)
self.tw.lc.insert_image(center=False,
filepath=os.path.join(
activity.get_bundle_path(), 'challenges',
diff --git a/challenges/offsets b/challenges/offsets
new file mode 100644
index 0000000..0cacd33
--- /dev/null
+++ b/challenges/offsets
@@ -0,0 +1,35 @@
+5:-100,0
+7:-141,-141
+10:0,-48
+11:0,-51
+12:0,-72
+13:0,-115
+14:0,-122
+15:-117,0
+16:-150,-150
+17:-100,-85
+18:-100,-100
+19:-150,-150
+20:-100,-118
+21:-100,-100
+22:-100,-100
+23:-150,-150
+24:-175,-150
+25:-75,-94
+26:-105,-125
+27:-150,-150
+28:-107,-107
+29:-155,-161
+30:-130,-152
+31:0,-50
+32:-121,-121
+33:-106,-106
+34:-100,-100
+35:-150,-150
+36:-121,-121
+37:-100,-100
+38:-106,-106
+39:-100,-100
+40:-104,-104
+
+