Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/game.py
diff options
context:
space:
mode:
authorCristhofer Travieso <cristhofert97@gmail.com>2013-05-01 21:41:32 (GMT)
committer Cristhofer Travieso <cristhofert97@gmail.com>2013-05-01 21:41:32 (GMT)
commit3ed33e4eb0963bcfeda220eeb1f9752a999dc138 (patch)
tree01f4cfcb8af24b7e6fb94c8880db4abcb4d2d2a5 /game.py
parent081ca9948febebce225a7169715d9bbcc13831b2 (diff)
Add a route
Signed-off-by: Cristhofer Travieso <cristhofert97@gmail.com>
Diffstat (limited to 'game.py')
-rw-r--r--game.py36
1 files changed, 24 insertions, 12 deletions
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()