static void game_cmd_updball(void)
{
cmd.type = CMD_BALL_POSITION;
- memcpy(cmd.ballpos.p, file.uv[0].p, sizeof (float) * 3);
+ v_cpy(cmd.ballpos.p, file.uv[0].p);
game_proxy_enq(&cmd);
cmd.type = CMD_BALL_BASIS;
static void game_cmd_updview(void)
{
cmd.type = CMD_VIEW_POSITION;
- memcpy(cmd.viewpos.p, view.p, sizeof (float) * 3);
+ v_cpy(cmd.viewpos.p, view.p);
game_proxy_enq(&cmd);
cmd.type = CMD_VIEW_CENTER;
- memcpy(cmd.viewcenter.c, view.c, sizeof (float) * 3);
+ v_cpy(cmd.viewcenter.c, view.c);
game_proxy_enq(&cmd);
cmd.type = CMD_VIEW_BASIS;
/*---------------------------------------------------------------------------*/
+static struct lockstep server_step;
+
int game_server_init(const char *file_name, int t, int e)
{
struct
game_cmd_init_balls();
game_cmd_init_items();
+ lockstep_clr(&server_step);
+
return server_state;
}
/* Test for a switch. */
- if (sol_swch_test(fp, 0))
+ if (sol_swch_test(fp, 0) == SWCH_TRIGGER)
audio_play(AUD_SWITCH, 1.f);
/* Test for a jump. */
- if (jump_e == 1 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 1)
+ if (jump_e == 1 && jump_b == 0 && (sol_jump_test(fp, jump_p, 0) ==
+ JUMP_TRIGGER))
{
jump_b = 1;
jump_e = 0;
game_cmd_jump(1);
}
- if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 0)
+ if (jump_e == 0 && jump_b == 0 && (sol_jump_test(fp, jump_p, 0) ==
+ JUMP_OUTSIDE))
{
jump_e = 1;
game_cmd_jump(0);
return GAME_NONE;
}
-void game_server_step(float dt)
+static void game_server_iter(float dt)
{
- static const float gup[] = { 0.0f, +9.8f, 0.0f };
- static const float gdn[] = { 0.0f, -9.8f, 0.0f };
-
switch (status)
{
- case GAME_GOAL: game_step(gup, dt, 0); break;
- case GAME_FALL: game_step(gdn, dt, 0); break;
+ case GAME_GOAL: game_step(GRAVITY_UP, dt, 0); break;
+ case GAME_FALL: game_step(GRAVITY_DN, dt, 0); break;
case GAME_NONE:
- if ((status = game_step(gdn, dt, 1)) != GAME_NONE)
+ if ((status = game_step(GRAVITY_DN, dt, 1)) != GAME_NONE)
game_cmd_status();
break;
}
game_cmd_eou();
}
+static struct lockstep server_step = { game_server_iter, DT };
+
+void game_server_step(float dt)
+{
+ lockstep_run(&server_step, dt);
+}
+
/*---------------------------------------------------------------------------*/
void game_set_goal(void)
void game_set_pos(int x, int y)
{
- input_set_x(input_get_x() + 40.0f * y / config_get_d(CONFIG_MOUSE_SENSE));
- input_set_z(input_get_z() + 40.0f * x / config_get_d(CONFIG_MOUSE_SENSE));
+ const float range = ANGLE_BOUND * 2;
+
+ input_set_x(input_get_x() + range * y / config_get_d(CONFIG_MOUSE_SENSE));
+ input_set_z(input_get_z() + range * x / config_get_d(CONFIG_MOUSE_SENSE));
}
void game_set_cam(int c)