Commits

Xathos  committed b81ad0b

Started work on physics engine - mainly working on collision.py and colliders.py. All code is a work in progress; working physics system and visualization are a bit of a ways off.

  • Participants
  • Parent commits aa79205

Comments (0)

Files changed (16)

File src/actors/__init__.py

Empty file removed.

File src/actors/controllers.py

-
-def PlayerController (key_input):
-    pass

File src/actors/event.py

-
-class Event (object):
-    pass

File src/actors/tank.py

-from sys import path
-path.append("..")
-from physics.object import GraphicsObject
-
-class Tank (object):
-    pass

File src/graphics/__init__.py

Empty file removed.

File src/graphics/tanks/__init__.py

Empty file removed.

File src/graphics/tanks/default.py

-
-from template import GraphicsPack
-
-class TankGraphicsPack (GraphicsPack):
-    pass

File src/graphics/tanks/template.py

-
-class GraphicsPack (object):
-    pass

File src/physics/__init__.py

Empty file removed.

File src/physics/colliders.py

-
-class Collider (object):
-    pass
-
-class CircleCollider (Collider):
-    pass
-
-class BoxCollider (Collider):
-    pass
-
-class PolyCollider (Collider):
-    pass

File src/physics/object.py

-
-class PhysicsObject (object):
-    pass
-
-class GraphicsObject (PhysicsObject):
-    pass

File src/physics/recording.py

-
-class ObjectRecording (object):
-    pass

File src/physics/rigidbody.py

-
-class Rigidbody (object):
-    pass

File src/physics/simulation.py

-
-class PhysicsSimulation (object):
-    pass

File src/physics/vector2.py

-
-import math
-
-class Vector2 (object):
-    def __init__ (self, x = 0.0, y = 0.0):
-        self.x = float(x)
-        self.y = float(y)
-
-    def __add__ (self, vector):
-        return Vector2(self.x + vector.x, self.y + vector.y)
-
-    def __mul__ (self, scalar):
-        return Vector2(self.x * scalar, self.y * scalar)
-
-    def __div__ (self, scalar):
-        return Vector2(self.x / scalar, self.y / scalar)
-
-    def __sub__ (self, vector):
-        return self.__add__(vector * -1)
-
-    @property
-    def magnitude (self):
-        return math.sqrt(self.x ** 2 + self.y ** 2)
-    
-    def dot (self, vector):
-        return self.x * vector.x + self.y * vector.y
-
-    def normalize (self):
-        return self / self.magnitude()
-
-    def distance (self, other):
-        return math.sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2)
-
-    def project (self, other): 
-        """Project self onto other.
-        (return the component of self that is parallel to other)
-        """
-        return other * (self.dot(other) / (other.magnitude ** 2))
-
-    def perpendicular_project (self, other):
-        """Return the component of self that is perpendicular to other.
-        """
-        return self - self.project(other)
-    
-    def angle (self, other):
-        """Return the angle between self and other in degrees."""
-        # Note: this was pulled directly from safe_atan in utilities.py
-        # (original tanks source)
-        # As such, this is expected to work, but it hasn't been tested yet.
-        delta = self - other
-        if delta.y > 0:
-            if delta.x > 0:
-                return math.degrees(math.atan(delta.y / delta.x))
-            elif delta.x < 0:
-                return 180.0 + math.degrees(math.atan(delta.y / delta.x))
-            else:
-                return 90.0
-        elif delta.y < 0:
-            if delta.x > 0:
-                return math.degrees(math.atan(delta.y / delta.x))
-            elif delta.x < 0:
-                return -180 + math.degrees(math.atan(delta.y / delta.x))
-            else:
-                return -90.0
-        else:
-            if delta.x >= 0:
-                return 0.0
-            else:
-                return 180.0
-            
-            

File src/tournament.py

-
-import pyglet
-from graphics.tanks.default import TankGraphicsPack
-from actors.tanks import Tank
-from actors.events import Event
-from physics.simulation import PhysicsSimulation
-from physics.vector2 import Vector2
-from physics.recording import ObjectRecording