diff --git a/gamestate.c b/gamestate.c index 92031f5..87d76df 100644 --- a/gamestate.c +++ b/gamestate.c @@ -505,7 +505,7 @@ void ser_box(char **out, struct Box *b) ser_V2(out, cp_to_v2(cpShapeGetCenterOfGravity(b->shape))); ser_int(out, b->type); // @Robust separate enum serialization that checks for out of bounds enum - ser_int(out, b->rotation); + ser_int(out, b->compass_rotation); ser_float(out, b->thrust); ser_float(out, b->energy_used); ser_float(out, b->damage); @@ -518,7 +518,7 @@ void des_box(char **in, struct Box *new_box, struct GameState *gs, struct Grid * box_new(new_box, gs, g, pos); des_int(in, (int *)&new_box->type); - des_int(in, (int *)&new_box->rotation); + des_int(in, (int *)&new_box->compass_rotation); des_float(in, &new_box->thrust); des_float(in, &new_box->energy_used); des_float(in, &new_box->damage); @@ -760,7 +760,7 @@ V2 thruster_direction(struct Box *box) assert(box->type == BoxThruster); V2 to_return = (V2){.x = 1.0f, .y = 0.0f}; - to_return = V2rotate(to_return, rotangle(box->rotation)); + to_return = V2rotate(to_return, rotangle(box->compass_rotation)); to_return = V2rotate(to_return, box_rotation(box)); return to_return; @@ -937,7 +937,7 @@ void process(struct GameState *gs, float dt) grid_new(empty_grid, gs, world_build); box_new(&empty_grid->boxes[0], gs, empty_grid, (V2){0}); empty_grid->boxes[0].type = p->input.build_type; - empty_grid->boxes[0].rotation = p->input.build_rotation; + empty_grid->boxes[0].compass_rotation = p->input.build_rotation; cpBodySetVelocity(empty_grid->body, v2_to_cp(p->vel)); } else @@ -958,7 +958,7 @@ void process(struct GameState *gs, float dt) p->spice_taken_away += 0.1f; box_new(empty_box, gs, g, grid_world_to_local(g, world_build)); empty_box->type = p->input.build_type; - empty_box->rotation = p->input.build_rotation; + empty_box->compass_rotation = p->input.build_rotation; } } diff --git a/main.c b/main.c index cdad778..28b52ae 100644 --- a/main.c +++ b/main.c @@ -595,7 +595,7 @@ static void frame(void) } sgp_push_transform(); - sgp_rotate_at(grid_rotation(g) + rotangle(b->rotation), box_pos(b).x, box_pos(b).y); + sgp_rotate_at(grid_rotation(g) + rotangle(b->compass_rotation), box_pos(b).x, box_pos(b).y); if (b->type == BoxThruster) { diff --git a/server.c b/server.c index 47e928d..adf6be2 100644 --- a/server.c +++ b/server.c @@ -25,11 +25,11 @@ void server(void *data) box_new(&gs.grids[0].boxes[3], &gs, &gs.grids[0], (V2){BOX_SIZE, BOX_SIZE*2.0}); gs.grids[0].boxes[3].type = BoxThruster; - gs.grids[0].boxes[3].rotation = Right; + gs.grids[0].boxes[3].compass_rotation = Right; box_new(&gs.grids[0].boxes[4], &gs, &gs.grids[0], (V2){0, BOX_SIZE*3.0}); gs.grids[0].boxes[4].type = BoxThruster; - gs.grids[0].boxes[4].rotation = Up; + gs.grids[0].boxes[4].compass_rotation = Up; grid_new(&gs.grids[1], &gs, (V2){.x = -BOX_SIZE*1.5, .y = 0.0}); diff --git a/types.h b/types.h index e53633e..28e6a36 100644 --- a/types.h +++ b/types.h @@ -71,7 +71,7 @@ enum BoxType BoxLast, }; -enum Rotation +enum CompassRotation { Right, Down, @@ -90,7 +90,7 @@ struct InputFrame V2 build; bool dobuild; enum BoxType build_type; - enum Rotation build_rotation; + enum CompassRotation build_rotation; int grid_index; }; @@ -131,7 +131,7 @@ struct GameState struct Box { enum BoxType type; - enum Rotation rotation; // @Robust rename to compass_rotation + enum CompassRotation compass_rotation; // @Robust rename to compass_rotation // thruster float thrust; // must be between 0 and 1 @@ -148,7 +148,7 @@ struct GameState #define PI 3.14159f // returns in radians -static float rotangle(enum Rotation rot) +static float rotangle(enum CompassRotation rot) { switch (rot) {