]> git.cworth.org Git - akamaru/blobdiff - akamaru.c
Add init functions for various objects, clean up model initializations.
[akamaru] / akamaru.c
index 1d94281b269fc936dbeaa830ae44ab4e6e5fbcd1..d158f3e2da5b3728882025fb3ce9c3598def2aef 100644 (file)
--- a/akamaru.c
+++ b/akamaru.c
@@ -24,6 +24,34 @@ const double elasticity = 0.7;
 const double friction = 1;
 const double gravity = 20;
 
+void
+object_init (Object *object, double x, double y, double mass)
+{
+  object->position.x = x;
+  object->position.y = y;
+  object->previous_position.x = x;
+  object->previous_position.y = y;
+  object->mass = mass;
+}
+
+void
+spring_init (Spring *spring, Object *a, Object *b, double length)
+{
+  spring->a = a;
+  spring->b = b;
+  spring->length = length;
+}
+
+void
+offset_spring_init (OffsetSpring *spring, Object *a, Object *b,
+                   double dx, double dy)
+{
+  spring->a = a;
+  spring->b = b;
+  spring->dx = dx;
+  spring->dy = dy;
+}
+
 void
 polygon_init (Polygon *p, int num_points, ...)
 {