diff options
author | Cristhofer Travieso <cristhofert97@gmail.com> | 2013-05-26 02:28:39 (GMT) |
---|---|---|
committer | Cristhofer Travieso <cristhofert97@gmail.com> | 2013-05-26 02:28:39 (GMT) |
commit | 7b0db958b5bbc728493acd633ea28495fc682c03 (patch) | |
tree | e216e896021b53f1cb08aca87929b42f2490393e /game.py | |
parent | c0293bc75b3cf60416c1e29cc17c5537bb8b99a7 (diff) |
Add window file and .gitignore file
Signed-off-by: Cristhofer Travieso <cristhofert97@gmail.com>
Diffstat (limited to 'game.py')
-rw-r--r-- | game.py | 53 |
1 files changed, 17 insertions, 36 deletions
@@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright (C) 2012 Cristhofer Travieso <cristhofert97@gmail.com> +# Copyright (C) 2013 Cristhofer Travieso <cristhofert97@gmail.com> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,64 +16,45 @@ # 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 -try: +sugar = False +if sugar: from sugar3.graphics import style - SIZE = style.zoom(150) BETWEEN_LINE_SPACE = style.zoom(200) -except: - pass - +else: + SIZE = 0 + BETWEEN_LINE_SPACE = 0 LINE_WIDTH = 12 -MODE_CIRCLE = 0 -MODE_CROSS = 1 +BACKGROUND_COLOR = (0, 1, 0) -TICTACTOE_COLOR = (1, 1, 1) -CROSS_COLOR = (0, 0.921568, 0.0627450) -CIRCLE_COLOR = (1, 0.556862, 0) -BACKGROUND_COLOR = (0.50, 0.20, 0) +class Canvas(Gtk.DrawingArea): -class Game(Gtk.DrawingArea): + __gsignals__ = { + 'update': (GObject.SIGNAL_RUN_FIRST, None, [])} def __init__(self): GObject.GObject.__init__(self) - self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | - Gdk.EventMask.POINTER_MOTION_MASK) + self.cars = [[100, 100, 50, 50, "horizontal", True]] + self.routes = [(10, "horizontal"), (200, "vertical")] self.connect('draw', self._draw_cb) - self.connect('button-press-event', self._click_cb) - self.connect('motion-notify-event', self._motion_notify_cb) self.show_all() def _draw_cb(self, widget, context): - alloc = self.get_allocation() + #redraw + + self.alloc = self.get_allocation() # Background - context.rectangle(0, 0, alloc.width, alloc.height) + context.rectangle(0, 0, self.alloc.width, self.alloc.height) context.set_source_rgb(*BACKGROUND_COLOR) context.fill() - def _motion_notify_cb(self, widget, event): - x_cursor = event.x - y_cursor = event.y - - def _click_cb(self, widget, event): - x_click = event.x - y_click = event.y - -if __name__ == "__main__": - window = Gtk.Window() - window.connect('destroy', lambda w: Gtk.main_quit()) - window.add(Game()) - window.maximize() - window.show_all() - Gtk.main() + #Draw cards |