Commits

Daniel Pope committed 5bfa685 Draft

Commit rabbit "game" from Pycon UK sprint

  • Participants

Comments (0)

Files changed (4)

+# Pygame boilerplate
+import pygame
+pygame.init()
+screen = pygame.display.set_mode((800, 600))
+
+# Our background will be black
+BACKGROUND = pygame.color.Color('black')
+
+# load a sprite
+rabbit = pygame.image.load('rabbit.png')
+
+# loop forever, drawing out scene
+x = 0
+while x < 700:
+    screen.fill(BACKGROUND)  # paint the background
+    x += 1
+    screen.blit(rabbit, (x, 50))    # draw the rabbit
+    pygame.display.flip()  # show what we've drawn
+
+# program ends after this
+# Pygame boilerplate
+import pygame
+pygame.init()
+screen = pygame.display.set_mode((800, 600))
+
+# Our background will be black
+BACKGROUND = pygame.color.Color('black')
+
+# load a sprite
+rabbit = pygame.image.load('rabbit.png')
+
+# loop forever, drawing out scene
+x = 0
+while True:
+    # make pygame read input from keys etc
+    pygame.event.pump()
+
+    # get the keys that were pressed
+    pressed = pygame.key.get_pressed()
+    if pressed[pygame.K_LEFT]:
+        x = x - 1
+    elif pressed[pygame.K_RIGHT]:
+        x = x + 1
+
+    screen.fill(BACKGROUND)  # paint the background
+    screen.blit(rabbit, (x, 50))    # draw the rabbit
+    pygame.display.flip()  # show what we've drawn
+
+# program ends after this

rabbit.png

Added
New image
+<?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="744.09448819"
+   height="1052.3622047"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.48.3.1 r9886"
+   sodipodi:docname="New document 1">
+  <defs
+     id="defs4" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="1"
+     inkscape:cx="375"
+     inkscape:cy="731.2457"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     showgrid="false"
+     inkscape:window-width="1301"
+     inkscape:window-height="744"
+     inkscape:window-x="65"
+     inkscape:window-y="24"
+     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="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1">
+    <g
+       id="g3008"
+       transform="matrix(0.55070105,0,0,0.55070105,95.476028,69.809825)">
+      <path
+         id="path2985"
+         d="m 201.5,155.375 c -4.155,0 -7.5,3.345 -7.5,7.5 l 0,31.75 c -4.41812,4.64 -7.15625,11.01252 -7.15625,18.03125 0,8.0299 3.59933,15.1907 9.1875,19.90625 -11.35424,4.1904 -19.1875,12.96168 -19.1875,23.09375 0,6.88553 3.62408,13.13431 9.5,17.75 -0.7702,-0.0334 -1.55192,-0.0312 -2.34375,-0.0312 -12.15026,0 -22,4.02944 -22,9 0,4.97056 9.84974,9 22,9 12.15026,0 22,-4.02944 22,-9 0,-0.45573 -0.0902,-0.90622 -0.25,-1.34375 1.75285,0.2072 3.57577,0.34375 5.40625,0.34375 1.07759,0 2.1353,-0.0521 3.1875,-0.125 -0.2274,0.52003 -0.34375,1.07986 -0.34375,1.625 0,5.24671 10.96902,9.5 24.5,9.5 13.53098,0 24.5,-4.25329 24.5,-9.5 0,-5.24671 -10.96902,-9.5 -24.5,-9.5 -0.86728,0 -1.71848,-0.003 -2.5625,0.0312 5.87592,-4.61569 9.5,-10.86447 9.5,-17.75 0,-9.87304 -7.42768,-18.44092 -18.3125,-22.75 5.82549,-4.70688 9.5625,-12.02346 9.5625,-20.25 0,-7.80293 -3.36951,-14.78413 -8.6875,-19.5 l 0,-30.28125 c 0,-4.155 -3.345,-7.5 -7.5,-7.5 -4.155,0 -7.5,3.345 -7.5,7.5 l 0,24.09375 c -0.4043,-0.0201 -0.80962,-0.0312 -1.21875,-0.0312 -0.93563,0 -1.8724,0.0526 -2.78125,0.15625 l 0,-24.21875 c 0,-4.155 -3.345,-7.5 -7.5,-7.5 z"
+         style="color:#000000;fill:#b3b3b3;fill-opacity:1;fill-rule:nonzero;stroke:#1a1a1a;stroke-width:3.63173461;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+         inkscape:connector-curvature="0" />
+      <path
+         d="m 206,205.36218 c 0,2.20914 -1.79086,4 -4,4 -2.20914,0 -4,-1.79086 -4,-4 0,-2.20914 1.79086,-4 4,-4 2.20914,0 4,1.79086 4,4 z"
+         sodipodi:ry="4"
+         sodipodi:rx="4"
+         sodipodi:cy="205.36218"
+         sodipodi:cx="202"
+         id="path3000"
+         style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#1a1a1a;stroke-width:3.63173461;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+         sodipodi:type="arc" />
+      <path
+         transform="translate(19,0)"
+         sodipodi:type="arc"
+         style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#1a1a1a;stroke-width:3.63173461;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+         id="path3002"
+         sodipodi:cx="202"
+         sodipodi:cy="205.36218"
+         sodipodi:rx="4"
+         sodipodi:ry="4"
+         d="m 206,205.36218 c 0,2.20914 -1.79086,4 -4,4 -2.20914,0 -4,-1.79086 -4,-4 0,-2.20914 1.79086,-4 4,-4 2.20914,0 4,1.79086 4,4 z" />
+      <rect
+         y="225.36218"
+         x="204"
+         height="9"
+         width="14"
+         id="rect3004"
+         style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+      <path
+         inkscape:connector-curvature="0"
+         id="path3006"
+         d="m 200,222.36218 c 11,10 24,0 24,0"
+         style="fill:none;stroke:#000000;stroke-width:3.63173461;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
+    </g>
+  </g>
+</svg>