Implement a server/client-like game/replay architecture
[neverball] / ball / game_common.c
1 #include "game_common.h"
2 #include "vec3.h"
3
4 const char *status_to_str(int s)
5 {
6     switch (s)
7     {
8     case GAME_NONE:    return _("Aborted");
9     case GAME_TIME:    return _("Time-out");
10     case GAME_GOAL:    return _("Success");
11     case GAME_FALL:    return _("Fall-out");
12     default:           return _("Unknown");
13     }
14 }
15
16 void game_comp_grav(float h[3], const float g[3],
17                     float view_a,
18                     float game_rx,
19                     float game_rz)
20 {
21     float x[3];
22     float y[3] = { 0.0f, 1.0f, 0.0f };
23     float z[3];
24     float X[16];
25     float Z[16];
26     float M[16];
27
28     /* Compute the gravity vector from the given world rotations. */
29
30     z[0] = fsinf(V_RAD(view_a));
31     z[1] = 0.0f;
32     z[2] = fcosf(V_RAD(view_a));
33
34     v_crs(x, y, z);
35     v_crs(z, x, y);
36     v_nrm(x, x);
37     v_nrm(z, z);
38
39     m_rot (Z, z, V_RAD(game_rz));
40     m_rot (X, x, V_RAD(game_rx));
41     m_mult(M, Z, X);
42     m_vxfm(h, M, g);
43 }