Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--icons/roll.svg118
-rw-r--r--physics.py7
-rw-r--r--tools.py26
4 files changed, 152 insertions, 0 deletions
diff --git a/MANIFEST b/MANIFEST
index 602efc6..d76ff48 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -41,6 +41,7 @@ icons/joint.svg
icons/magicpen.svg
icons/polygon.svg
icons/triangle.svg
+icons/roll.svg
olpcgames/__init__.py
olpcgames/_cairoimage.py
olpcgames/_gtkmain.py
diff --git a/icons/roll.svg b/icons/roll.svg
new file mode 100644
index 0000000..adafaed
--- /dev/null
+++ b/icons/roll.svg
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
+<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"
+ version="1.1"
+ x="0px"
+ y="0px"
+ width="55px"
+ height="55px"
+ viewBox="0 0 55 55"
+ enable-background="new 0 0 55 55"
+ xml:space="preserve"
+ id="svg3289"
+ sodipodi:version="0.32"
+ inkscape:version="0.46"
+ sodipodi:docname="roll.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"><metadata
+ id="metadata3299"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
+ id="defs3297"><marker
+ inkscape:stockid="Arrow1Mend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow1Mend"
+ style="overflow:visible;"><path
+ id="path3931"
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;"
+ transform="scale(0.4) rotate(180) translate(10,0)" /></marker><marker
+ inkscape:stockid="Arrow2Lstart"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow2Lstart"
+ style="overflow:visible"><path
+ id="path3940"
+ style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
+ transform="scale(1.1) translate(1,0)" /></marker><marker
+ inkscape:stockid="Arrow1Mstart"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow1Mstart"
+ style="overflow:visible"><path
+ id="path3928"
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
+ transform="scale(0.4) translate(10,0)" /></marker><marker
+ inkscape:stockid="Arrow2Lend"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow2Lend"
+ style="overflow:visible;"><path
+ id="path3943"
+ style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
+ d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
+ transform="scale(1.1) rotate(180) translate(1,0)" /></marker><marker
+ inkscape:stockid="Arrow1Lstart"
+ orient="auto"
+ refY="0.0"
+ refX="0.0"
+ id="Arrow1Lstart"
+ style="overflow:visible"><path
+ id="path3922"
+ d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
+ style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none"
+ transform="scale(0.8) translate(12.5,0)" /></marker><inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 27.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="55 : 27.5 : 1"
+ inkscape:persp3d-origin="27.5 : 18.333333 : 1"
+ id="perspective3301" /></defs><sodipodi:namedview
+ inkscape:window-height="947"
+ inkscape:window-width="1280"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ guidetolerance="10.0"
+ gridtolerance="10.0"
+ objecttolerance="10.0"
+ borderopacity="1.0"
+ bordercolor="#666666"
+ pagecolor="#ffffff"
+ id="base"
+ showgrid="false"
+ inkscape:zoom="8.9818182"
+ inkscape:cx="31.955545"
+ inkscape:cy="24.558404"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:current-layer="svg3289" />
+
+
+
+<path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:0.08579911;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:13.69999981;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ d="M 27.679338,4.6827995 C 37.880686,4.6827995 46.530082,11.374407 49.450862,20.609259 L 45.697151,20.609259 C 42.916953,13.359763 35.902192,8.1952005 27.679338,8.1952005 C 19.456484,8.1952006 12.441723,13.359763 9.661525,20.609259 L 5.907814,20.609259 C 8.828594,11.374407 17.47799,4.6827995 27.679338,4.6827995 z M 49.450862,34.390741 C 46.530082,43.625593 37.880686,50.317202 27.679338,50.3172 C 17.47799,50.3172 8.828593,43.625592 5.907814,34.390741 L 9.661525,34.390741 C 12.441723,41.640237 19.456484,46.804799 27.679338,46.804799 C 35.902193,46.804799 42.916953,41.640236 45.697151,34.390741 L 49.450862,34.390741 z"
+ id="path4280" /><path
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.40237498;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 39.768514,14.969956 C 39.768514,14.969956 40.437224,17.649053 48.010067,22.868827 C 49.856426,13.283876 47.372767,11.277845 47.372767,11.277845"
+ id="path4288"
+ sodipodi:nodetypes="ccc" /><path
+ style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:2.40237498;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ d="M 15.424531,40.206691 C 15.424531,40.206691 14.755821,37.527594 7.182978,32.30782 C 5.336619,41.89277 7.820278,43.898803 7.820278,43.898803"
+ id="path4290"
+ sodipodi:nodetypes="ccc" />
+
+</svg> \ No newline at end of file
diff --git a/physics.py b/physics.py
index 6179206..dba7368 100644
--- a/physics.py
+++ b/physics.py
@@ -56,6 +56,13 @@ class PhysicsGame:
self.currentTool.handleEvents(event)
# Clear Display
self.screen.fill((255,255,255)) #255 for white
+
+ if self.world.run_physics:
+ for body in self.world.world.GetBodyList():
+ if type(body.userData) == type({}):
+ if body.userData.has_key('rollMotor'):
+ diff = body.userData['rollMotor']['targetVelocity']- body.GetAngularVelocity()
+ body.ApplyTorque(body.userData['rollMotor']['strength']*diff*body.getMassData().I)
# Update & Draw World
self.world.update()
diff --git a/tools.py b/tools.py
index a7c4cfd..963e2a8 100644
--- a/tools.py
+++ b/tools.py
@@ -380,6 +380,32 @@ class MotorTool(Tool):
self.jb1 = self.jb1pos = None
def cancel(self):
self.jb1 = self.jb1pos = None
+
+class RollTool(Tool):
+ name = 'Roll'
+ icon = 'roll'
+ toolTip = _("Roll")
+ toolAccelerator = _("r")
+
+ def __init__(self,gameInstance):
+ self.game = gameInstance
+ self.name = 'Roll'
+ self.jb1 = self.jb1pos = None
+ def handleEvents(self,event):
+ #look for default events, and if none are handled then try the custom events
+ if not super(RollTool,self).handleEvents(event):
+ if event.type == MOUSEBUTTONDOWN:
+ if event.button == 1:
+ self.jb1pos = event.pos
+ self.jb1 = self.game.world.get_bodies_at_pos(event.pos)
+ if self.jb1:
+ if type(self.jb1[0].userData) == type({}):
+ self.jb1[0].userData['rollMotor'] = {}
+ self.jb1[0].userData['rollMotor']['targetVelocity'] = -10
+ self.jb1[0].userData['rollMotor']['strength'] = 40
+ self.jb1 = self.jb1pos = None
+ def cancel(self):
+ self.jb1 = self.jb1pos = None
# The destroy tool