-
Notifications
You must be signed in to change notification settings - Fork 2
/
intro.cpp
149 lines (117 loc) · 3.73 KB
/
intro.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* --------------------------------------------------------------------
EXTREME TUXRACER
Copyright (C) 1999-2001 Jasmin F. Patry (Tuxracer)
Copyright (C) 2010 Extreme Tuxracer Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
---------------------------------------------------------------------*/
#include "audio.h"
#include "keyframe.h"
#include "course_render.h"
#include "ogl.h"
#include "view.h"
#include "tux.h"
#include "env.h"
#include "hud.h"
#include "course.h"
#include "track_marks.h"
#include "particles.h"
#include "game_ctrl.h"
static CKeyframe *startframe;
void IntroKeys (unsigned int key, bool special, bool release, int x, int y);
void abort_intro (CControl *ctrl) {
TVector2 start_pt = Course.GetStartPoint ();
Winsys.SetMode (RACING);
ctrl->orientation_initialized = false;
ctrl->view_init = false;
ctrl->cpos.x = start_pt.x;
ctrl->cpos.z = start_pt.y;
}
// =================================================================
void intro_init(void) {
int i, num_items;
TItem *item_locs;
CControl *ctrl = Players.GetCtrl (g_game.player_id);
TVector2 start_pt = Course.GetStartPoint ();
ctrl->orientation_initialized = false;
ctrl->view_init = false;
ctrl->cpos.x = start_pt.x;
ctrl->cpos.z = start_pt.y;
startframe = Char.GetKeyframe (g_game.char_id, START);
if (startframe->loaded) {
// startframe->Init (ctrl->cpos, -0.05);
CCharShape *sh = Char.GetShape (g_game.char_id);
startframe->Init (ctrl->cpos, -0.05, sh);
}
// reset of result values
g_game.herring = 0;
g_game.score = 0;
g_game.time = 0.0;
g_game.race_result = -1;
g_game.raceaborted = false;
ctrl->Init ();
ctrl->cvel = MakeVector (0, 0, 0);
clear_particles();
set_view_mode (ctrl, ABOVE);
SetCameraDistance (4.0);
SetStationaryCamera (false);
update_view (ctrl, EPS);
num_items = Course.numNocoll;
item_locs = Course.NocollArr;
for (i = 0; i < num_items; i++) {
if (item_locs[i].collectable != -1) {
item_locs[i].collectable = 1;
}
}
InitSnow (ctrl);
InitWind ();
Music.PlayTheme (g_game.theme_id, MUS_RACING);
param.show_hud = true;
g_game.loopdelay = 1;
}
void intro_loop (double time_step) {
int width, height;
CControl *ctrl = Players.GetCtrl (g_game.player_id);
width = param.x_resolution;
height = param.y_resolution;
check_gl_error();
if (startframe->active) {
startframe->Update (time_step, ctrl);
} else Winsys.SetMode (RACING);
ClearRenderContext ();
Env.SetupFog ();
update_view (ctrl, time_step);
SetupViewFrustum (ctrl);
Music.Update ();
Env.DrawSkybox (ctrl->viewpos);
Env.DrawFog ();
Env.SetupLight ();
RenderCourse ();
DrawTrackmarks ();
DrawTrees ();
UpdateWind (time_step, ctrl);
UpdateSnow (time_step, ctrl);
DrawSnow (ctrl);
Char.Draw (g_game.char_id);
DrawHud (ctrl);
Reshape (width, height);
Winsys.SwapBuffers ();
}
void IntroTerm () {
}
// -----------------------------------------------------------------------
void IntroKeys (unsigned int /*key*/, bool /*special*/, bool release, int /*x*/, int /*y*/) {
CControl *ctrl = Players.GetCtrl (g_game.player_id);
if (release) return;
abort_intro (ctrl);
}
void intro_register() {
Winsys.SetModeFuncs (INTRO, intro_init, intro_loop, IntroTerm,
IntroKeys, NULL, NULL, NULL, NULL, NULL);
}