2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
31 /*---------------------------------------------------------------------------*/
33 static int game_state = 0;
35 static struct s_file file;
36 static struct s_file back;
38 static float timer = 0.f; /* Clock time */
39 static int timer_down = 1; /* Timer go up or down? */
41 static float game_rx; /* Floor rotation about X axis */
42 static float game_rz; /* Floor rotation about Z axis */
44 static float view_a; /* Ideal view rotation about Y axis */
45 static float view_dc; /* Ideal view distance above ball */
46 static float view_dp; /* Ideal view distance above ball */
47 static float view_dz; /* Ideal view distance behind ball */
48 static float view_fov; /* Field of view */
50 static float view_c[3]; /* Current view center */
51 static float view_v[3]; /* Current view vector */
52 static float view_p[3]; /* Current view position */
53 static float view_e[3][3]; /* Current view reference frame */
56 static int coins = 0; /* Collected coins */
57 static int goal_e = 0; /* Goal enabled flag */
58 static float goal_k = 0; /* Goal animation */
59 static int jump_e = 1; /* Jumping enabled flag */
60 static int jump_b = 0; /* Jump-in-progress flag */
61 static float jump_dt; /* Jump duration */
62 static float jump_p[3]; /* Jump destination */
63 static float fade_k = 0.0; /* Fade in/out level */
64 static float fade_d = 0.0; /* Fade in/out direction */
66 /*---------------------------------------------------------------------------*/
69 * This is an abstraction of the game's input state. All input is
70 * encapsulated here, and all references to the input by the game are made
71 * here. This has the effect of homogenizing input for use in replay
72 * recording and playback.
75 * -32767 = -ANGLE_BOUND
76 * +32767 = +ANGLE_BOUND
79 * -32767 = -VIEWR_BOUND
80 * +32767 = +VIEWR_BOUND
92 static struct input input_current;
94 static void input_init(void)
102 static void input_set_x(float x)
104 if (x < -ANGLE_BOUND) x = -ANGLE_BOUND;
105 if (x > ANGLE_BOUND) x = ANGLE_BOUND;
107 input_current.x = (short) (32767.0f * x / ANGLE_BOUND);
110 static void input_set_z(float z)
112 if (z < -ANGLE_BOUND) z = -ANGLE_BOUND;
113 if (z > ANGLE_BOUND) z = ANGLE_BOUND;
115 input_current.z = (short) (32767.0f * z / ANGLE_BOUND);
118 static void input_set_r(float r)
120 if (r < -VIEWR_BOUND) r = -VIEWR_BOUND;
121 if (r > VIEWR_BOUND) r = VIEWR_BOUND;
123 input_current.r = (short) (32767.0f * r / VIEWR_BOUND);
126 static void input_set_c(int c)
128 input_current.c = (short) c;
131 static float input_get_x(void)
133 return ANGLE_BOUND * (float) input_current.x / 32767.0f;
136 static float input_get_z(void)
138 return ANGLE_BOUND * (float) input_current.z / 32767.0f;
141 static float input_get_r(void)
143 return VIEWR_BOUND * (float) input_current.r / 32767.0f;
146 static int input_get_c(void)
148 return (int) input_current.c;
151 int input_put(FILE *fout)
155 put_short(fout, &input_current.x);
156 put_short(fout, &input_current.z);
157 put_short(fout, &input_current.r);
158 put_short(fout, &input_current.c);
165 int input_get(FILE *fin)
169 get_short(fin, &input_current.x);
170 get_short(fin, &input_current.z);
171 get_short(fin, &input_current.r);
172 get_short(fin, &input_current.c);
174 return (feof(fin) ? 0 : 1);
179 /*---------------------------------------------------------------------------*/
181 static int grow = 0; /* Should the ball be changing size? */
182 static float grow_orig = 0; /* the original ball size */
183 static float grow_goal = 0; /* how big or small to get! */
184 static float grow_t = 0.0; /* timer for the ball to grow... */
185 static float grow_strt = 0; /* starting value for growth */
186 static int got_orig = 0; /* Do we know original ball size? */
188 #define GROW_TIME 0.5f /* sec for the ball to get to size. */
189 #define GROW_BIG 1.5f /* large factor */
190 #define GROW_SMALL 0.5f /* small factor */
192 static int grow_state = 0; /* Current state (values -1, 0, +1) */
194 static void grow_init(const struct s_file *fp, int type)
198 grow_orig = fp->uv->r;
199 grow_goal = grow_orig;
200 grow_strt = grow_orig;
207 if (type == ITEM_SHRINK)
215 audio_play(AUD_SHRINK, 1.f);
216 grow_goal = grow_orig * GROW_SMALL;
222 audio_play(AUD_SHRINK, 1.f);
223 grow_goal = grow_orig;
229 else if (type == ITEM_GROW)
234 audio_play(AUD_GROW, 1.f);
235 grow_goal = grow_orig;
241 audio_play(AUD_GROW, 1.f);
242 grow_goal = grow_orig * GROW_BIG;
255 grow_strt = fp->uv->r;
259 static void grow_step(const struct s_file *fp, float dt)
266 /* Calculate new size based on how long since you touched the coin... */
270 if (grow_t >= GROW_TIME)
276 dr = grow_strt + ((grow_goal-grow_strt) * (1.0f / (GROW_TIME / grow_t)));
278 /* No sinking through the floor! Keeps ball's bottom constant. */
280 fp->uv->p[1] += (dr - fp->uv->r);
284 /*---------------------------------------------------------------------------*/
286 static void view_init(void)
288 view_fov = (float) config_get_d(CONFIG_VIEW_FOV);
289 view_dp = (float) config_get_d(CONFIG_VIEW_DP) / 100.0f;
290 view_dc = (float) config_get_d(CONFIG_VIEW_DC) / 100.0f;
291 view_dz = (float) config_get_d(CONFIG_VIEW_DZ) / 100.0f;
314 int game_init(const char *file_name, int t, int e)
316 char *back_name = NULL, *grad_name = NULL;
320 timer = (float) t / 100.f;
321 timer_down = (t > 0);
327 if (!sol_load_gl(&file, config_data(file_name),
328 config_get_d(CONFIG_TEXTURES),
329 config_get_d(CONFIG_SHADOW)))
330 return (game_state = 0);
339 /* Initialize jump and goal states. */
345 goal_k = e ? 1.0f : 0.0f;
347 /* Initialise the level, background, particles, fade, and view. */
352 for (i = 0; i < file.dc; i++)
354 char *k = file.av + file.dv[i].ai;
355 char *v = file.av + file.dv[i].aj;
357 if (strcmp(k, "back") == 0) back_name = v;
358 if (strcmp(k, "grad") == 0) grad_name = v;
361 part_reset(GOAL_HEIGHT);
363 back_init(grad_name, config_get_d(CONFIG_GEOMETRY));
365 sol_load_gl(&back, config_data(back_name),
366 config_get_d(CONFIG_TEXTURES), 0);
368 /* Initialize ball size tracking... */
387 /*---------------------------------------------------------------------------*/
391 return (int) (timer * 100.f);
399 /*---------------------------------------------------------------------------*/
401 static void game_draw_balls(const struct s_file *fp,
402 const float *bill_M, float t)
404 float c[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
409 m_basis(ball_M, fp->uv[0].e[0], fp->uv[0].e[1], fp->uv[0].e[2]);
410 m_basis(pend_M, fp->uv[0].E[0], fp->uv[0].E[1], fp->uv[0].E[2]);
412 glPushAttrib(GL_LIGHTING_BIT);
415 glTranslatef(fp->uv[0].p[0],
416 fp->uv[0].p[1] + BALL_FUDGE,
418 glScalef(fp->uv[0].r,
423 ball_draw(ball_M, pend_M, bill_M, t);
429 static void game_draw_items(const struct s_file *fp, float t)
434 glPushAttrib(GL_LIGHTING_BIT);
436 item_push(ITEM_COIN);
438 for (hi = 0; hi < fp->hc; hi++)
440 if (fp->hv[hi].t == ITEM_COIN && fp->hv[hi].n > 0)
444 glTranslatef(fp->hv[hi].p[0],
447 glRotatef(r, 0.0f, 1.0f, 0.0f);
448 item_draw(&fp->hv[hi], r);
455 item_push(ITEM_SHRINK);
457 for (hi = 0; hi < fp->hc; hi++)
459 if (fp->hv[hi].t == ITEM_SHRINK)
463 glTranslatef(fp->hv[hi].p[0],
466 glRotatef(r, 0.0f, 1.0f, 0.0f);
467 item_draw(&fp->hv[hi], r);
474 item_push(ITEM_GROW);
476 for (hi = 0; hi < fp->hc; hi++)
478 if (fp->hv[hi].t == ITEM_GROW)
482 glTranslatef(fp->hv[hi].p[0],
485 glRotatef(r, 0.0f, 1.0f, 0.0f);
486 item_draw(&fp->hv[hi], r);
496 static void game_draw_goals(const struct s_file *fp, const float *M, float t)
502 /* Draw the goal particles. */
504 glEnable(GL_TEXTURE_2D);
506 for (zi = 0; zi < fp->zc; zi++)
510 glTranslatef(fp->zv[zi].p[0],
514 part_draw_goal(M, fp->zv[zi].r, goal_k, t);
519 glDisable(GL_TEXTURE_2D);
521 /* Draw the goal column. */
523 for (zi = 0; zi < fp->zc; zi++)
527 glTranslatef(fp->zv[zi].p[0],
531 glScalef(fp->zv[zi].r,
542 static void game_draw_jumps(const struct s_file *fp)
546 for (ji = 0; ji < fp->jc; ji++)
550 glTranslatef(fp->jv[ji].p[0],
553 glScalef(fp->jv[ji].r,
563 static void game_draw_swchs(const struct s_file *fp)
567 for (xi = 0; xi < fp->xc; xi++)
574 glTranslatef(fp->xv[xi].p[0],
577 glScalef(fp->xv[xi].r,
581 swch_draw(fp->xv[xi].f, fp->xv[xi].e);
587 /*---------------------------------------------------------------------------*/
589 static void game_draw_tilt(int d)
591 const float *ball_p = file.uv->p;
593 /* Rotate the environment about the position of the ball. */
595 glTranslatef(+ball_p[0], +ball_p[1] * d, +ball_p[2]);
596 glRotatef(-game_rz * d, view_e[2][0], view_e[2][1], view_e[2][2]);
597 glRotatef(-game_rx * d, view_e[0][0], view_e[0][1], view_e[0][2]);
598 glTranslatef(-ball_p[0], -ball_p[1] * d, -ball_p[2]);
601 static void game_refl_all(void)
607 /* Draw the floor. */
614 /*---------------------------------------------------------------------------*/
616 static void game_draw_light(void)
618 const float light_p[2][4] = {
619 { -8.0f, +32.0f, -8.0f, 0.0f },
620 { +8.0f, +32.0f, +8.0f, 0.0f },
622 const float light_c[2][4] = {
623 { 1.0f, 0.8f, 0.8f, 1.0f },
624 { 0.8f, 1.0f, 0.8f, 1.0f },
627 /* Configure the lighting. */
630 glLightfv(GL_LIGHT0, GL_POSITION, light_p[0]);
631 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_c[0]);
632 glLightfv(GL_LIGHT0, GL_SPECULAR, light_c[0]);
635 glLightfv(GL_LIGHT1, GL_POSITION, light_p[1]);
636 glLightfv(GL_LIGHT1, GL_DIFFUSE, light_c[1]);
637 glLightfv(GL_LIGHT1, GL_SPECULAR, light_c[1]);
640 static void game_draw_back(int pose, int d, float t)
646 glRotatef(game_rz * 2, view_e[2][0], view_e[2][1], view_e[2][2]);
647 glRotatef(game_rx * 2, view_e[0][0], view_e[0][1], view_e[0][2]);
650 glTranslatef(view_p[0], view_p[1] * d, view_p[2]);
652 if (config_get_d(CONFIG_BACKGROUND))
654 /* Draw all background layers back to front. */
656 sol_back(&back, BACK_DIST, FAR_DIST, t);
658 sol_back(&back, 0, BACK_DIST, t);
665 static void game_clip_refl(int d)
667 /* Fudge to eliminate the floor from reflection. */
669 GLdouble e[4], k = -0.00001;
676 glClipPlane(GL_CLIP_PLANE0, e);
679 static void game_clip_ball(int d, const float *p)
681 GLdouble r, c[3], pz[4], nz[4];
683 /* Compute the plane giving the front of the ball, as seen from view_p. */
689 pz[0] = view_p[0] - c[0];
690 pz[1] = view_p[1] - c[1];
691 pz[2] = view_p[2] - c[2];
693 r = sqrt(pz[0] * pz[0] + pz[1] * pz[1] + pz[2] * pz[2]);
698 pz[3] = -(pz[0] * c[0] +
702 /* Find the plane giving the back of the ball, as seen from view_p. */
709 /* Reflect these planes as necessary, and store them in the GL state. */
714 glClipPlane(GL_CLIP_PLANE1, nz);
715 glClipPlane(GL_CLIP_PLANE2, pz);
718 static void game_draw_fore(int pose, const float *M, int d, float t)
720 const float *ball_p = file.uv->p;
721 const float ball_r = file.uv->r;
725 /* Rotate the environment about the position of the ball. */
729 /* Compute clipping planes for reflection and ball facing. */
732 game_clip_ball(d, ball_p);
735 glEnable(GL_CLIP_PLANE0);
738 sol_draw(&file, 0, 1);
741 /* Draw the coins. */
743 game_draw_items(&file, t);
745 /* Draw the floor. */
747 sol_draw(&file, 0, 1);
749 /* Draw the ball shadow. */
751 if (d > 0 && config_get_d(CONFIG_SHADOW))
753 shad_draw_set(ball_p, ball_r);
760 game_draw_balls(&file, M, t);
763 /* Draw the particles and light columns. */
765 glEnable(GL_COLOR_MATERIAL);
766 glDisable(GL_LIGHTING);
767 glDepthMask(GL_FALSE);
769 glColor3f(1.0f, 1.0f, 1.0f);
771 sol_bill(&file, M, t);
772 part_draw_coin(M, t);
774 glDisable(GL_TEXTURE_2D);
776 game_draw_goals(&file, M, t);
777 game_draw_jumps(&file);
778 game_draw_swchs(&file);
780 glEnable(GL_TEXTURE_2D);
782 glColor3f(1.0f, 1.0f, 1.0f);
784 glDepthMask(GL_TRUE);
785 glEnable(GL_LIGHTING);
786 glDisable(GL_COLOR_MATERIAL);
789 glDisable(GL_CLIP_PLANE0);
794 void game_draw(int pose, float t)
796 float fov = view_fov;
798 if (jump_b) fov *= 2.f * fabsf(jump_dt - 0.5);
802 config_push_persp(fov, 0.1f, FAR_DIST);
805 float T[16], U[16], M[16], v[3];
807 /* Compute direct and reflected view bases. */
813 m_view(T, view_c, view_p, view_e[1]);
814 m_view(U, view_c, v, view_e[1]);
818 /* Apply current the view. */
820 v_sub(v, view_c, view_p);
822 glTranslatef(0.f, 0.f, -v_len(v));
824 glTranslatef(-view_c[0], -view_c[1], -view_c[2]);
826 if (config_get_d(CONFIG_REFLECTION))
828 glEnable(GL_STENCIL_TEST);
830 /* Draw the mirrors only into the stencil buffer. */
832 glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
833 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
834 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
835 glDepthMask(GL_FALSE);
839 glDepthMask(GL_TRUE);
840 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
841 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
842 glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
844 /* Draw the scene reflected into color and depth buffers. */
849 glScalef(+1.0f, -1.0f, +1.0f);
852 game_draw_back(pose, -1, t);
853 game_draw_fore(pose, U, -1, t);
858 glDisable(GL_STENCIL_TEST);
861 /* Draw the scene normally. */
865 game_draw_back(pose, +1, t);
866 game_draw_fore(pose, T, +1, t);
871 /* Draw the fade overlay. */
877 /*---------------------------------------------------------------------------*/
879 static void game_update_grav(float h[3], const float g[3])
882 float y[3] = { 0.0f, 1.0f, 0.0f };
888 /* Compute the gravity vector from the given world rotations. */
890 z[0] = fsinf(V_RAD(view_a));
892 z[2] = fcosf(V_RAD(view_a));
899 m_rot (Z, z, V_RAD(game_rz));
900 m_rot (X, x, V_RAD(game_rx));
905 static void game_update_view(float dt)
907 float dc = view_dc * (jump_b ? 2.0f * fabsf(jump_dt - 0.5f) : 1.0f);
908 float da = input_get_r() * dt * 90.0f;
911 float M[16], v[3], Y[3] = { 0.0f, 1.0f, 0.0f };
915 /* Center the view about the ball. */
917 v_cpy(view_c, file.uv->p);
918 v_inv(view_v, file.uv->v);
920 view_e[2][0] = fsinf(V_RAD(view_a));
922 view_e[2][2] = fcosf(V_RAD(view_a));
924 switch (input_get_c())
926 case 1: /* Camera 1: Viewpoint chases the ball position. */
928 v_mad(view_e[2], view_e[2], view_v, v_dot(view_v, view_v) * dt / 16);
932 case 2: /* Camera 2: View vector is given by view angle. */
936 default: /* Default: View vector approaches the ball velocity vector. */
938 v_mad(view_e[2], view_e[2], view_v, v_dot(view_v, view_v) * dt / 4);
943 /* Orthonormalize the new view reference frame. */
945 v_crs(view_e[0], view_e[1], view_e[2]);
946 v_crs(view_e[2], view_e[0], view_e[1]);
947 v_nrm(view_e[0], view_e[0]);
948 v_nrm(view_e[2], view_e[2]);
950 /* Compute the new view position. */
952 k = 1.0f + v_dot(view_e[2], view_v) / 10.0f;
954 view_k = view_k + (k - view_k) * dt;
956 if (view_k < 0.5) view_k = 0.5;
958 v_scl(v, view_e[1], view_dp * view_k);
959 v_mad(v, v, view_e[2], view_dz * view_k);
960 m_rot(M, Y, V_RAD(da));
961 m_vxfm(view_p, M, v);
962 v_add(view_p, view_p, file.uv->p);
964 /* Compute the new view center. */
966 v_cpy(view_c, file.uv->p);
967 v_mad(view_c, view_c, view_e[1], dc);
969 /* Note the current view angle. */
971 view_a = V_DEG(fatan2f(view_e[2][0], view_e[2][2]));
974 static void game_update_time(float dt, int b)
976 if (goal_e && goal_k < 1.0f)
979 /* The ticking clock. */
994 static int game_update_state(int bt)
996 struct s_file *fp = &file;
1003 /* Test for an item. */
1005 if (bt && (hp = sol_item_test(fp, p, COIN_RADIUS)))
1010 grow_init(fp, hp->t);
1012 if (hp->t == ITEM_COIN)
1015 audio_play(AUD_COIN, 1.f);
1022 /* Test for a switch. */
1024 if (sol_swch_test(fp, 0))
1025 audio_play(AUD_SWITCH, 1.f);
1027 /* Test for a jump. */
1029 if (jump_e == 1 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 1)
1035 audio_play(AUD_JUMP, 1.f);
1037 if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 0)
1040 /* Test for a goal. */
1042 if (bt && goal_e && (zp = sol_goal_test(fp, p, 0)))
1044 audio_play(AUD_GOAL, 1.0f);
1048 /* Test for time-out. */
1050 if (bt && timer_down && timer <= 0.f)
1052 audio_play(AUD_TIME, 1.0f);
1056 /* Test for fall-out. */
1058 if (bt && fp->uv[0].p[1] < fp->vv[0].p[1])
1060 audio_play(AUD_FALL, 1.0f);
1067 int game_step(const float g[3], float dt, int bt)
1071 struct s_file *fp = &file;
1075 /* Smooth jittery or discontinuous input. */
1077 game_rx += (input_get_x() - game_rx) * dt / RESPONSE;
1078 game_rz += (input_get_z() - game_rz) * dt / RESPONSE;
1082 game_update_grav(h, g);
1089 /* Handle a jump. */
1093 fp->uv[0].p[0] = jump_p[0];
1094 fp->uv[0].p[1] = jump_p[1];
1095 fp->uv[0].p[2] = jump_p[2];
1104 float b = sol_step(fp, h, dt, 0, NULL);
1106 /* Mix the sound of a ball bounce. */
1110 float k = (b - 0.5f) * 2.0f;
1114 if (fp->uv->r > grow_orig) audio_play(AUD_BUMPL, k);
1115 else if (fp->uv->r < grow_orig) audio_play(AUD_BUMPS, k);
1116 else audio_play(AUD_BUMPM, k);
1118 else audio_play(AUD_BUMPM, k);
1123 game_update_view(dt);
1124 game_update_time(dt, bt);
1126 return game_update_state(bt);
1131 /*---------------------------------------------------------------------------*/
1133 void game_set_goal(void)
1135 audio_play(AUD_SWITCH, 1.0f);
1139 void game_clr_goal(void)
1144 /*---------------------------------------------------------------------------*/
1146 void game_set_x(int k)
1148 input_set_x(-ANGLE_BOUND * k / JOY_MAX);
1151 void game_set_z(int k)
1153 input_set_z(+ANGLE_BOUND * k / JOY_MAX);
1156 void game_set_ang(int x, int z)
1162 void game_set_pos(int x, int y)
1164 input_set_x(input_get_x() + 40.0f * y / config_get_d(CONFIG_MOUSE_SENSE));
1165 input_set_z(input_get_z() + 40.0f * x / config_get_d(CONFIG_MOUSE_SENSE));
1168 void game_set_cam(int c)
1173 void game_set_rot(float r)
1178 /*---------------------------------------------------------------------------*/
1180 void game_set_fly(float k)
1182 struct s_file *fp = &file;
1184 float x[3] = { 1.f, 0.f, 0.f };
1185 float y[3] = { 0.f, 1.f, 0.f };
1186 float z[3] = { 0.f, 0.f, 1.f };
1187 float c0[3] = { 0.f, 0.f, 0.f };
1188 float p0[3] = { 0.f, 0.f, 0.f };
1189 float c1[3] = { 0.f, 0.f, 0.f };
1190 float p1[3] = { 0.f, 0.f, 0.f };
1193 z[0] = fsinf(V_RAD(view_a));
1194 z[2] = fcosf(V_RAD(view_a));
1196 v_cpy(view_e[0], x);
1197 v_cpy(view_e[1], y);
1198 v_cpy(view_e[2], z);
1200 /* k = 0.0 view is at the ball. */
1204 v_cpy(c0, fp->uv[0].p);
1205 v_cpy(p0, fp->uv[0].p);
1208 v_mad(p0, p0, y, view_dp);
1209 v_mad(p0, p0, z, view_dz);
1210 v_mad(c0, c0, y, view_dc);
1212 /* k = +1.0 view is s_view 0 */
1214 if (k >= 0 && fp->wc > 0)
1216 v_cpy(p1, fp->wv[0].p);
1217 v_cpy(c1, fp->wv[0].q);
1220 /* k = -1.0 view is s_view 1 */
1222 if (k <= 0 && fp->wc > 1)
1224 v_cpy(p1, fp->wv[1].p);
1225 v_cpy(c1, fp->wv[1].q);
1228 /* Interpolate the views. */
1231 v_mad(view_p, p0, v, k * k);
1234 v_mad(view_c, c0, v, k * k);
1236 /* Orthonormalize the view basis. */
1238 v_sub(view_e[2], view_p, view_c);
1239 v_crs(view_e[0], view_e[1], view_e[2]);
1240 v_crs(view_e[2], view_e[0], view_e[1]);
1241 v_nrm(view_e[0], view_e[0]);
1242 v_nrm(view_e[2], view_e[2]);
1245 void game_look(float phi, float theta)
1247 view_c[0] = view_p[0] + fsinf(V_RAD(theta)) * fcosf(V_RAD(phi));
1248 view_c[1] = view_p[1] + fsinf(V_RAD(phi));
1249 view_c[2] = view_p[2] - fcosf(V_RAD(theta)) * fcosf(V_RAD(phi));
1252 /*---------------------------------------------------------------------------*/
1254 void game_kill_fade(void)
1260 void game_step_fade(float dt)
1262 if ((fade_k < 1.0f && fade_d > 0.0f) ||
1263 (fade_k > 0.0f && fade_d < 0.0f))
1264 fade_k += fade_d * dt;
1278 void game_fade(float d)
1283 /*---------------------------------------------------------------------------*/
1285 const char *status_to_str(int s)
1289 case GAME_NONE: return _("Aborted");
1290 case GAME_TIME: return _("Time-out");
1291 case GAME_GOAL: return _("Success");
1292 case GAME_FALL: return _("Fall-out");
1293 default: return _("Unknown");
1297 /*---------------------------------------------------------------------------*/