static float goal_k = 0; /* Goal animation */
static int jump_e = 1; /* Jumping enabled flag */
static int jump_b = 0; /* Jump-in-progress flag */
-static int jump_u = 0; /* Which ball is jumping? */
static float jump_dt; /* Jump duration */
+static int jump_u = 0; /* Which ball is jumping? */
static float jump_p[3]; /* Jump destination */
static float fade_k = 0.0; /* Fade in/out level */
static float fade_d = 0.0; /* Fade in/out direction */
/*---------------------------------------------------------------------------*/
+/*
+ * Here for any possible future implementations, eg network play
+ */
+
+static void game_handle_balls(struct s_file *fp)
+{
+}
+
+/*---------------------------------------------------------------------------*/
+
static void game_draw_balls(const struct s_file *fp,
const float *bill_M, float t)
{
{
float fov = view_fov;
- if (jump_b)
- {
- if (jump_u == 0)
- fov *= 2.0f * fabsf(jump_dt - 0.5f);
+ if (jump_b && jump_u)
+ fov /= 1.9f * fabsf(jump_dt - 0.5f);
- else
- fov /= 1.9f * fabsf(jump_dt - 0.5f);
- }
+ else if (jump_b)
+ fov *= 2.0f * fabsf(jump_dt - 0.5f);
if (game_state)
{
/* Test for a jump. */
+ if (!jump_u && jump_e == 1 && jump_b == 0 &&
+ sol_jump_test(fp, jump_p, 0) == 1)
+ {
+ jump_b = 1;
+ jump_e = 0;
+ jump_dt = 0.f;
+ jump_u = 0;
+
+ audio_play(AUD_JUMP, 1.f);
+ }
+ if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 0)
+ jump_e = 1;
+ if (!jump_b && !jump_u && sol_jump_test(fp, jump_p, 0) == 0)
+ jump_u = 0;
+
for (i = 0; i < fp->uc; i++)
{
- if (jump_e == 1 &&
- jump_b == 0 &&
+ if (!jump_u && jump_e == 1 && jump_b == 0 &&
sol_jump_test(fp, jump_p, i) == 1)
{
jump_b = 1;
jump_e = 0;
jump_dt = 0.f;
- jump_u = i;
+ jump_u = i + 1;
audio_play(AUD_JUMP, 1.f);
}
-
- if (jump_e == 0 &&
- jump_b == 0 &&
- jump_u == i &&
+ if (jump_e == 0 && jump_b == 0 &&
sol_jump_test(fp, jump_p, i) == 0)
- {
- /* Enable jumping after jump finished */
jump_e = 1;
- }
+ if (!jump_b && jump_u && i == jump_u - 1 &&
+ sol_jump_test(fp, jump_p, i) == 0)
+ jump_u = 0;
}
/* Test for a goal. */
float b = sol_step(fp, h, dt, 0, NULL);
+ game_handle_balls(fp);
+
/* Mix the sound of a ball bounce. */
if (b > 0.5f)
* Set ball B's play state as S. Additional values can be used for b:
* -1: Set current ball to s
* -2: Set all balls to s
+ *
*/
void game_set_play(int b, int s)
* If there are any, reset the proper
* ball's play state
*/
- for (j = i + 1; j < fp->uc; j++)
+ for (j = i + 1; j < fp->uc && (i > curr_party() || config_get_d(CONFIG_BALL_COLLISIONS)); j++)
{
struct s_ball *u2p = fp->uv + j;
float d[3];
static void game_draw_balls(const struct s_file *fp,
const float *bill_M, float t)
{
- static const GLfloat color[5][4] = {
+ static const GLfloat color[6][4] = {
{ 1.0f, 1.0f, 1.0f, 0.7f },
{ 1.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 1.0f, 0.0f, 1.0f },
int i = 0;
- if (jump_b)
- {
- if (jump_u == ball)
- fov *= 2.0f * fabsf(jump_dt - 0.5f);
+ if (config_get_d(CONFIG_BALL_COLLISIONS) && jump_b && jump_u != ball * 2)
+ fov /= 1.9f * fabsf(jump_dt - 0.5f);
- else
- fov /= 1.9f * fabsf(jump_dt - 0.5f);
- }
+ else if (jump_b)
+ fov *= 2.0f * fabsf(jump_dt - 0.5f);
config_push_persp(fov, 0.1f, FAR_DIST);
glPushAttrib(GL_LIGHTING_BIT);
/* Test for a jump. */
- for (i = 0; i < fp->uc; i++)
+ if (config_get_d(CONFIG_BALL_COLLISIONS))
+ {
+ for (i = 0; i < fp->uc; i++)
+ {
+ if (!jump_u && jump_e == 1 && jump_b == 0 &&
+ sol_jump_test(fp, jump_p, i) == 1)
+ {
+ jump_b = 1;
+ jump_e = 0;
+ jump_dt = 0.f;
+ jump_u = i;
+
+ audio_play(AUD_JUMP, 1.f);
+ }
+ if (jump_e == 0 && jump_b == 0 &&
+ sol_jump_test(fp, jump_p, i) == 0)
+ jump_e = 1;
+ if (!jump_b && jump_u && i == jump_u / 2 &&
+ sol_jump_test(fp, jump_p, i) == 0)
+ jump_u = 0;
+ }
+ }
+ else
{
- if (jump_e == 1 &&
- jump_b == 0 &&
- sol_jump_test(fp, jump_p, i) == 1)
+ if (jump_e == 1 && jump_b == 0 && sol_jump_test(fp, jump_p, ball) == 1)
{
- /* Initialize a jump */
jump_b = 1;
jump_e = 0;
jump_dt = 0.f;
- jump_u = i;
audio_play(AUD_JUMP, 1.f);
}
- if (jump_e == 0 &&
- jump_b == 0 &&
- jump_u == i &&
- sol_jump_test(fp, jump_p, i) == 0)
- {
- /* Enable jumping after jump finished */
+ if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, ball) == 0)
jump_e = 1;
- }
}
/* Test for fall-out. */
- if (fp->uv[ball].p[1] < -10.f)
+ if (fp->uv[ball].p[1] < -10.0f)
return GAME_FALL;
/* Test for a goal or stop. */
- if (t > 1.f)
+ if (t > 1.0f)
{
- t = 0.f;
+ t = 0.0f;
switch (sol_goal_test(fp, p, ball) & ((fp->uv[ball].P) ? (3) : (1)))
{
if (jump_b)
{
- jump_dt += dt;
+ if (config_get_d(CONFIG_BALL_COLLISIONS))
+ {
+ jump_dt += dt;
- /* Handle a jump. */
+ /* Handle a jump. */
- if (0.5 < jump_dt)
- {
- fp->uv[jump_u].p[0] = jump_p[0];
- fp->uv[jump_u].p[1] = jump_p[1];
- fp->uv[jump_u].p[2] = jump_p[2];
+ if (0.5 < jump_dt)
+ {
+ fp->uv[jump_u].p[0] = jump_p[0];
+ fp->uv[jump_u].p[1] = jump_p[1];
+ fp->uv[jump_u].p[2] = jump_p[2];
+ }
+
+ if (1.f < jump_dt)
+ {
+ jump_b = 0;
+ }
}
- if (1.f < jump_dt)
+ else
{
- jump_b = 0;
+ jump_dt += dt;
+
+ /* Handle a jump. */
+
+ if (0.5 < jump_dt)
+ {
+ fp->uv[ball].p[0] = jump_p[0];
+ fp->uv[ball].p[1] = jump_p[1];
+ fp->uv[ball].p[2] = jump_p[2];
+ }
+ if (1.f < jump_dt)
+ jump_b = 0;
}
}
else
* friction too early and stopping the ball prematurely.
*/
- file.uv[ball].v[0] = -4.f * view_e[2][0] * view_m;
- file.uv[ball].v[1] = -4.f * view_e[2][1] * view_m + BALL_FUDGE;
- file.uv[ball].v[2] = -4.f * view_e[2][2] * view_m;
+ if (config_get_d(CONFIG_BALL_COLLISIONS))
+ {
+ file.uv[ball].v[0] = -4.f * view_e[2][0] * view_m;
+ file.uv[ball].v[1] = -4.f * view_e[2][1] * view_m + BALL_FUDGE;
+ file.uv[ball].v[2] = -4.f * view_e[2][2] * view_m;
+ }
+
+ else
+ {
+ file.uv[ball].v[0] = -4.f * view_e[2][0] * view_m;
+ file.uv[ball].v[1] = -4.f * view_e[2][1] * view_m + BALL_FUDGE;
+ file.uv[ball].v[2] = -4.f * view_e[2][2] * view_m;
+ }
view_m = 0.f;
}
}
/*---------------------------------------------------------------------------*/
-
if (p <= party)
{
- for (h = 1; h <= hole && h < count; h++)
+ for (h = 1; h <= hole && h <= 18; h++)
T += score_v[h][p];
sprintf(str, "%d", T);
if (p <= party)
{
- for (h = 1; h <= hole && h <= count / 2; h++)
+ for (h = 1; h <= hole && h <= 9; h++)
T += score_v[h][p];
sprintf(str, "%d", T);
static void title_timer(int id, float dt)
{
- float g[3] = { 0.f, -9.8f, 0.f };
+ float g[3] = { 0.0f, -9.8f, 0.0f };
game_step(g, dt);
game_set_fly(fcosf(time_state() / 10.f));
static void stroke_timer(int id, float dt)
{
- float g[3] = { 0.f, -9.8f, 0.f };
+ float g[3] = { 0.0f, -9.8f, 0.0f };
float k;
static void roll_timer(int id, float dt)
{
- float g[3] = { 0.f, -9.8f, 0.f };
+ float g[3] = { 0.0f, -9.8f, 0.0f };
switch (game_step(g, dt))
{
static void stop_timer(int id, float dt)
{
- float g[3] = { 0.f, -9.8f, 0.f };
+ float g[3] = { 0.0f, -9.8f, 0.0f };
game_update_view(dt);
game_step(g, dt);
v_mad(p, q, n, up->r);
/* Return the "energy" of the impact, to determine the sound amplitude. */
-
return fabsf(v_dot(n, d));
}
t = u;
}
}
+
return t;
}
if ((d = v_dot(r, g) / (v_len(r) * v_len(g))) > 0.999f)
{
- if ((e = (v_len(up->v) - dt)) > 0.0f)
+ if ((e = (v_len(up->v) - dt)) > 0.0f) /* GDB tells me this is where the problem lies. I'll look into it */
{
/* Scale the linear velocity. */
}
/*---------------------------------------------------------------------------*/
-
* d Dictionary (struct s_dict)
* i Index (int)
* a Text (char)
+
*
* The Ys are as follows:
*