From: parasti Date: Wed, 13 Oct 2010 21:16:37 +0000 (+0000) Subject: Define gravity constants only once X-Git-Tag: fremantle/1.5.5-2~233 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=92dee6a4b0628d53c398e5274ab3ac0a33c6ff0f;p=neverball Define gravity constants only once git-svn-id: https://s.snth.net/svn/neverball/trunk@3307 78b8d119-cf0a-0410-b17c-f493084dd1d7 --- diff --git a/ball/game_client.c b/ball/game_client.c index 4f0ef50..31e0219 100644 --- a/ball/game_client.c +++ b/ball/game_client.c @@ -61,9 +61,6 @@ struct static void game_run_cmd(const union cmd *cmd) { - static const float gup[] = { 0.0f, +9.8f, 0.0f }; - static const float gdn[] = { 0.0f, -9.8f, 0.0f }; - /* * Neverball <= 1.5.1 does not send explicit tilt axes, rotation * happens directly around view vectors. So for compatibility if @@ -97,9 +94,9 @@ static void game_run_cmd(const union cmd *cmd) /* Compute gravity for particle effects. */ if (status == GAME_GOAL) - game_tilt_grav(v, gup, &dr.tilt); + game_tilt_grav(v, GRAVITY_UP, &dr.tilt); else - game_tilt_grav(v, gdn, &dr.tilt); + game_tilt_grav(v, GRAVITY_DN, &dr.tilt); /* Step particle, goal and jump effects. */ diff --git a/ball/game_common.c b/ball/game_common.c index b439e7e..ce22a03 100644 --- a/ball/game_common.c +++ b/ball/game_common.c @@ -30,6 +30,9 @@ const char *view_to_str(int v) /*---------------------------------------------------------------------------*/ +const float GRAVITY_UP[] = { 0.0f, +9.8f, 0.0f }; +const float GRAVITY_DN[] = { 0.0f, -9.8f, 0.0f }; + void game_tilt_init(struct game_tilt *tilt) { tilt->x[0] = 1.0f; diff --git a/ball/game_common.h b/ball/game_common.h index 641692d..39443bb 100644 --- a/ball/game_common.h +++ b/ball/game_common.h @@ -60,6 +60,9 @@ const char *view_to_str(int); /*---------------------------------------------------------------------------*/ +extern const float GRAVITY_UP[]; +extern const float GRAVITY_DN[]; + struct game_tilt { float x[3], rx; diff --git a/ball/game_server.c b/ball/game_server.c index d1a081c..3632287 100644 --- a/ball/game_server.c +++ b/ball/game_server.c @@ -804,16 +804,13 @@ static int game_step(const float g[3], float dt, int bt) 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; }