Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-09-02 22:10:50 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-09-02 22:10:50 (GMT)
commit8eb166545a73894d491912b8ac5a693a4b2e9226 (patch)
tree9e8c2c194d522848cc869feeae4c0857227bc140
parent55cea2e750c12b401776abe634a214a2293cf101 (diff)
Save all the squares center
-rwxr-xr-xgame.py44
1 files changed, 32 insertions, 12 deletions
diff --git a/game.py b/game.py
index e319c39..bdc10dc 100755
--- a/game.py
+++ b/game.py
@@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import cairo
+import random
from gi.repository import Gtk
from gi.repository import Gdk
from sugar3.graphics import style
@@ -40,7 +41,7 @@ class Canvas(Gtk.DrawingArea):
self._mode = MODE_CROSS
self._circles = []
self._crosses = []
- self._center = ()
+ self.squares = []
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
@@ -72,28 +73,47 @@ class Canvas(Gtk.DrawingArea):
x = (alloc.width - BETWEEN_LINE_SPACE * 3) / 2
y = (alloc.height - BETWEEN_LINE_SPACE * 3) / 2
- self._center = (x, y)
-
y += BETWEEN_LINE_SPACE
+ lx = BETWEEN_LINE_SPACE * SIZE_FACTOR
context.move_to(x, y)
- context.line_to(BETWEEN_LINE_SPACE * SIZE_FACTOR, y)
+ context.line_to(lx, y)
context.stroke()
- y += BETWEEN_LINE_SPACE
+ size = SIZE / 2 + style.zoom(25)
+
+ cx1 = x + size
+ cx2 = x + BETWEEN_LINE_SPACE + size
+ cx3 = x + (BETWEEN_LINE_SPACE * 2) + size
+
+ x += BETWEEN_LINE_SPACE
+ y -= BETWEEN_LINE_SPACE
+ ly = BETWEEN_LINE_SPACE * SIZE_FACTOR_2
context.move_to(x, y)
- context.line_to(BETWEEN_LINE_SPACE * SIZE_FACTOR, y)
+ context.line_to(x, ly)
context.stroke()
- x += BETWEEN_LINE_SPACE
- y -= BETWEEN_LINE_SPACE * 2
+ cy1 = y + size
+ cy2 = y + BETWEEN_LINE_SPACE + size
+ cy3 = y + (BETWEEN_LINE_SPACE * 2) + size
+
+ y += BETWEEN_LINE_SPACE * 2
+ x -= BETWEEN_LINE_SPACE
context.move_to(x, y)
- context.line_to(x, BETWEEN_LINE_SPACE * SIZE_FACTOR_2)
+ context.line_to(lx, y)
context.stroke()
- x += BETWEEN_LINE_SPACE
+ x += BETWEEN_LINE_SPACE * 2
+ y -= BETWEEN_LINE_SPACE * 2
context.move_to(x, y)
- context.line_to(x, BETWEEN_LINE_SPACE * SIZE_FACTOR_2)
+ context.line_to(x, ly)
context.stroke()
+
+ # Save center squares coords
+ if not cx1 < 0:
+ self.squares = []
+ self.squares.extend([(cx1, cy1), (cx2, cy1), (cx3, cy1)])
+ self.squares.extend([(cx1, cy2), (cx2, cy2), (cx3, cy2)])
+ self.squares.extend([(cx1, cy3), (cx2, cy3), (cx3, cy3)])
context.set_source_rgb(*fill)
for circle in self._circles:
@@ -124,7 +144,7 @@ class Canvas(Gtk.DrawingArea):
def get_pos(self, x, y):
# TODO: Return the specific square coords
- return x, y
+ return self.squares[4]
if __name__ == "__main__":