Camera distance based on speed
[neverball] / ball / game_common.h
1 #ifndef GAME_COMMON_H
2 #define GAME_COMMON_H
3
4 #include "lang.h"
5 #include "solid_vary.h"
6
7 /*---------------------------------------------------------------------------*/
8
9 #define AUD_MENU    "snd/menu.ogg"
10 #define AUD_START _("snd/select.ogg")
11 #define AUD_READY _("snd/ready.ogg")
12 #define AUD_SET   _("snd/set.ogg")
13 #define AUD_GO    _("snd/go.ogg")
14 #define AUD_BALL    "snd/ball.ogg"
15 #define AUD_BUMPS   "snd/bumplil.ogg"
16 #define AUD_BUMPM   "snd/bump.ogg"
17 #define AUD_BUMPL   "snd/bumpbig.ogg"
18 #define AUD_COIN    "snd/coin.ogg"
19 #define AUD_TICK    "snd/tick.ogg"
20 #define AUD_TOCK    "snd/tock.ogg"
21 #define AUD_SWITCH  "snd/switch.ogg"
22 #define AUD_JUMP    "snd/jump.ogg"
23 #define AUD_GOAL    "snd/goal.ogg"
24 #define AUD_SCORE _("snd/record.ogg")
25 #define AUD_FALL  _("snd/fall.ogg")
26 #define AUD_TIME  _("snd/time.ogg")
27 #define AUD_OVER  _("snd/over.ogg")
28 #define AUD_GROW    "snd/grow.ogg"
29 #define AUD_SHRINK  "snd/shrink.ogg"
30
31 /*---------------------------------------------------------------------------*/
32
33 enum
34 {
35     GAME_NONE = 0,
36
37     GAME_TIME,
38     GAME_GOAL,
39     GAME_FALL,
40
41     GAME_MAX
42 };
43
44 const char *status_to_str(int);
45
46 /*---------------------------------------------------------------------------*/
47
48 enum
49 {
50     VIEW_NONE = -1,
51
52     VIEW_CHASE,
53     VIEW_LAZY,
54     VIEW_MANUAL,
55     VIEW_SPEED,
56
57     VIEW_MAX
58 };
59
60 const char *view_to_str(int);
61
62 /*---------------------------------------------------------------------------*/
63
64 extern const float GRAVITY_UP[];
65 extern const float GRAVITY_DN[];
66
67 struct game_tilt
68 {
69     float x[3], rx;
70     float z[3], rz;
71 };
72
73 void game_tilt_init(struct game_tilt *);
74 void game_tilt_axes(struct game_tilt *, float view_e[3][3]);
75 void game_tilt_grav(float h[3], const float g[3], const struct game_tilt *);
76
77 /*---------------------------------------------------------------------------*/
78
79 struct game_view
80 {
81     float dc;                           /* Ideal view distance above ball    */
82     float dp;                           /* Ideal view distance above ball    */
83     float dz;                           /* Ideal view distance behind ball   */
84
85     float c[3];                         /* Current view center               */
86     float p[3];                         /* Current view position             */
87     float e[3][3];                      /* Current view reference frame      */
88
89     float a;                            /* Ideal view rotation about Y axis  */
90 };
91
92 void game_view_init(struct game_view *);
93 void game_view_fly(struct game_view *, const struct s_vary *, float);
94
95 /*---------------------------------------------------------------------------*/
96
97 #define UPS 30
98 #define DT  (1.0f / (float) UPS)
99
100 /*
101  * Simple fixed time step scheme.
102  */
103
104 struct lockstep
105 {
106     void (*step)(float);
107
108     float dt;                           /* Time step length                  */
109     float at;                           /* Accumulator                       */
110     float ts;                           /* Time scale factor                 */
111 };
112
113 void lockstep_clr(struct lockstep *);
114 void lockstep_run(struct lockstep *, float);
115 void lockstep_scl(struct lockstep *, float);
116
117 #define lockstep_blend(ls) ((ls)->at / (ls)->dt)
118
119 /*---------------------------------------------------------------------------*/
120
121 extern struct s_base game_base;
122
123 int  game_base_load(const char *);
124 void game_base_free(const char *);
125
126 /*---------------------------------------------------------------------------*/
127
128 #endif