From a24aa662aeb4f6cf59218716d9534d7d62d85be7 Mon Sep 17 00:00:00 2001 From: Cristhofer Travieso Date: Wed, 15 May 2013 20:27:36 +0000 Subject: optimize the code Signed-off-by: Cristhofer Travieso --- diff --git a/game.py b/game.py index b08a2be..18dd74b 100644 --- a/game.py +++ b/game.py @@ -41,7 +41,7 @@ class Canvas(Gtk.DrawingArea): GObject.GObject.__init__(self) self.cars = [] - self.routes = [(10, 50)] + self.routes = [(10, "horizontal"), (200, "vertical")] self.connect('draw', self._draw_cb) @@ -57,8 +57,19 @@ class Canvas(Gtk.DrawingArea): #Draw route for route in self.routes: - x, w = route - context.rectangle(x, 0, w, self.alloc.height) + pos, address = route + if address == "horizontal": + x = pos + y = 0 + w = 50 + h = self.alloc.height + else: + x = 0 + y = pos + w = self.alloc.width + h = 50 + + context.rectangle(x, y, w, h) context.set_source_rgb(0.2, 0.2, 0.2) context.fill() -- cgit v0.9.1