diff options
author | olpc user <olpc@xo-74-31-ed.localdomain> | 2012-11-05 19:30:07 (GMT) |
---|---|---|
committer | olpc user <olpc@xo-74-31-ed.localdomain> | 2012-11-05 19:30:07 (GMT) |
commit | 519fd95e4107ab9cc9a8076e3180624195d9b5cb (patch) | |
tree | e4bd2b47f5a7ae69e877a8d14f9ff079009f2709 | |
parent | 76278b70773a64b280fe0e83c4fdc31b5ca913fc (diff) |
Signed-off-by: olpc user <olpc@xo-74-31-ed.localdomain>
-rwxr-xr-x | game.py | 26 | ||||
-rw-r--r-- | icons/eat.png | bin | 0 -> 29219 bytes | |||
-rw-r--r-- | icons/eat.svg | 65 |
3 files changed, 90 insertions, 1 deletions
@@ -27,7 +27,13 @@ class Head(glucosa.Sprite): def _key_pressed(self, _event): if _event.is_pressed(_event.K_UP): - self._to_rotate = 0 + if self.rotate == 270: + self._to_rotate = 360 + elif self.rotate == 90: + self._to_rotate = 0 + elif self.rotate == 180: + self._to_rotate = 0 + elif _event.is_pressed(_event.K_DOWN): self._to_rotate = 180 elif _event.is_pressed(_event.K_RIGHT): @@ -62,9 +68,27 @@ class Head(glucosa.Sprite): elif self.rotation == 270: self.x -= 2 + x, y, w, h = widget.get_allocation() + + if self.x < 0: + self.x = 0 + elif self.x > w: + self.x = w + elif self.y < 0: + self.y = 0 + elif self.y > h: + self.y = h + +class Eat(glucosa.Sprite): + + def __init__(self): + _image = glucosa.Image('images/eat.png') + glucosa.Sprite.__init__(self, _image, 0, 0) + if __name__ == '__main__': w = gtk.Window() w.maximize() + w.connect('destroy', gtk.main_quit) w.add(Game()) w.show_all() gtk.main() diff --git a/icons/eat.png b/icons/eat.png Binary files differnew file mode 100644 index 0000000..9086f55 --- /dev/null +++ b/icons/eat.png diff --git a/icons/eat.svg b/icons/eat.svg new file mode 100644 index 0000000..05a24fd --- /dev/null +++ b/icons/eat.svg @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="210mm" + height="297mm" + id="svg2" + version="1.1" + inkscape:version="0.48.2 r9819" + sodipodi:docname="Documento nuevo 1"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.35" + inkscape:cx="300" + inkscape:cy="514.28571" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1200" + inkscape:window-height="804" + inkscape:window-x="0" + inkscape:window-y="30" + inkscape:window-maximized="1" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Capa 1" + inkscape:groupmode="layer" + id="layer1"> + <path + sodipodi:type="arc" + style="fill:#00ff00;fill-opacity:1;fill-rule:evenodd;stroke:#008100;stroke-width:27.07166862;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path2985" + sodipodi:cx="468.57144" + sodipodi:cy="536.64789" + sodipodi:rx="300" + sodipodi:ry="310" + d="m 768.57144,536.64789 a 300,310 0 1 1 -600,0 300,310 0 1 1 600,0 z" + transform="matrix(1.0494126,0,0,1.0017357,-107.43906,51.925671)" /> + </g> +</svg> |