summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-12-07 21:20:39 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-12-07 21:20:39 -0500
commit7efbd44a641b32285499b07dc4f5461fec8dc8d5 (patch)
tree94bc8ac146f6b0584c6dd61a9a334b34b5693b16
parent3268bcf528723c6a6bde373707db8f7f234ec2ea (diff)
rotating platforms
-rw-r--r--sim.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/sim.cpp b/sim.cpp
index a1b3f49..a2bdaf1 100644
--- a/sim.cpp
+++ b/sim.cpp
@@ -247,12 +247,14 @@ static b2Body *platform_to_body(State *state, Platform *platform) {
b2BodyDef body_def;
body_def.type = b2_kinematicBody;
body_def.position.Set(center.x, center.y);
+ body_def.angle = platform->angle;
b2Body *body = world->CreateBody(&body_def);
b2PolygonShape shape;
- shape.SetAsBox(half_size, state->platform_thickness, b2Vec2(0, 0), platform->angle);
+ shape.SetAsBox(half_size, state->platform_thickness);
body->CreateFixture(&shape, 0.0f);
- body->SetLinearVelocity(b2Vec2(0, 10.0f));
+ body->SetLinearVelocity(b2Vec2(0, 3.0f));
+ body->SetAngularVelocity(2.0f);
return body;
}
@@ -420,6 +422,7 @@ void sim_frame(Frame *frame) {
b2Vec2 platform_pos = platform->body->GetPosition();
platform->center.x = platform_pos.x * B2_INV_SCALE;
platform->center.y = platform_pos.y * B2_INV_SCALE;
+ platform->angle = platform->body->GetAngle();
}
}