From 3ed33e4eb0963bcfeda220eeb1f9752a999dc138 Mon Sep 17 00:00:00 2001 From: Cristhofer Travieso Date: Wed, 01 May 2013 21:41:32 +0000 Subject: Add a route Signed-off-by: Cristhofer Travieso --- (limited to 'game.py') diff --git a/game.py b/game.py index 82c276c..28a6a02 100644 --- a/game.py +++ b/game.py @@ -17,11 +17,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import cairo from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject +import os +os.system('clear') + sugar = False if sugar: from sugar3.graphics import style @@ -45,20 +47,30 @@ class Canvas(Gtk.DrawingArea): self.show_all() def _draw_cb(self, widget, context): - alloc = self.get_allocation() + self.alloc = self.get_allocation() + self.context = context # Background - context.rectangle(0, 0, alloc.width, alloc.height) - context.set_source_rgb(*BACKGROUND_COLOR) - context.fill() + self.context.rectangle(0, 0, self.alloc.width, self.alloc.height) + self.context.set_source_rgb(*BACKGROUND_COLOR) + self.context.fill() + + self._get_route(False, 600) - def _get_route(self, direction, pos_x, pos_y): - if direction == 'horizontal': - x = alloc.width + def _get_route(self, horizontal, pos): + if horizontal: + pos_x = 0 + pos_y = pos + x = self.alloc.width + y = 50 else: - x = alloc.height + pos_x = pos + pos_y = 0 + x = 50 + y = self.alloc.height + - context.rectangle(pos_x, pos_y, x, 50) - context.set_source_rgb(0.803921569, 0.788235294, 0.788235294) - context.fill() + self.context.rectangle(pos_x, pos_y, x, y) + self.context.set_source_rgb(0, 0, 0) + self.context.fill() -- cgit v0.9.1