84bbd123 |
1 | /* |
2 | * Elite - The New Kind. |
3 | * |
4 | * Reverse engineered from the BBC disk version of Elite. |
5 | * Additional material by C.J.Pinder. |
6 | * |
7 | * The original Elite code is (C) I.Bell & D.Braben 1984. |
8 | * This version re-engineered in C by C.J.Pinder 1999-2001. |
9 | * |
10 | * email: <christian@newkind.co.uk> |
11 | * |
12 | * |
13 | */ |
14 | |
15 | /* |
16 | * intro.c |
17 | * |
18 | * Run the two intro screens. |
19 | * First is a rolling Cobra MkIII. |
20 | * Second is a parade of the various ships. |
21 | * |
22 | */ |
23 | |
24 | |
25 | #include <stdlib.h> |
26 | |
27 | #include "config.h" |
28 | #include "elite.h" |
29 | #include "gfx.h" |
c597a4f2 |
30 | #include "keyboard.h" |
84bbd123 |
31 | #include "vector.h" |
32 | #include "shipdata.h" |
33 | #include "shipface.h" |
34 | #include "threed.h" |
35 | #include "space.h" |
36 | #include "stars.h" |
37 | |
38 | static int ship_no; |
39 | static int show_time; |
40 | static int direction; |
41 | |
42 | |
43 | static int min_dist[NO_OF_SHIPS+1] = {0, 200, 800, 200, 200, 200, 300, 384, 200, |
44 | 200, 200, 420, 900, 500, 800, 384, 384, |
45 | 384, 384, 384, 200, 384, 384, 384, 0, |
46 | 384, 0, 384, 384, 700, 384, 0, 0, |
47 | 900}; |
48 | |
49 | |
50 | static Matrix intro_ship_matrix; |
51 | |
c597a4f2 |
52 | static int ship_bump; |
84bbd123 |
53 | |
54 | void initialise_intro1 (void) |
55 | { |
56 | clear_universe(); |
57 | set_init_matrix (intro_ship_matrix); |
58 | add_new_ship (SHIP_COBRA3, 0, 0, 4500, intro_ship_matrix, -127, -127); |
59 | } |
60 | |
61 | |
62 | void initialise_intro2 (void) |
63 | { |
64 | ship_no = 0; |
65 | show_time = 0; |
66 | direction = 100; |
c597a4f2 |
67 | ship_bump = +1; |
84bbd123 |
68 | |
69 | clear_universe(); |
70 | create_new_stars(); |
71 | set_init_matrix (intro_ship_matrix); |
72 | add_new_ship (1, 0, 0, 5000, intro_ship_matrix, -127, -127); |
73 | } |
74 | |
75 | |
76 | |
77 | void update_intro1 (void) |
78 | { |
79 | universe[0].location.z -= 100; |
80 | |
81 | if (universe[0].location.z < 384) |
82 | universe[0].location.z = 384; |
83 | |
84 | gfx_clear_display(); |
85 | |
86 | flight_roll = 1; |
87 | update_universe(); |
88 | |
89 | gfx_draw_sprite(IMG_ELITE_TXT, -1, 10); |
90 | |
91 | gfx_display_centre_text (310, "Original Game (C) I.Bell & D.Braben.", 120, GFX_COL_WHITE); |
92 | gfx_display_centre_text (330, "Re-engineered by C.J.Pinder.", 120, GFX_COL_WHITE); |
93 | gfx_display_centre_text (360, "Load New Commander (Y/N)?", 140, GFX_COL_GOLD); |
94 | } |
95 | |
c597a4f2 |
96 | static void next_ship(int bump) |
97 | { |
98 | do |
99 | { |
100 | ship_no += bump; |
101 | if (ship_no > NO_OF_SHIPS) |
102 | ship_no = 1; |
103 | if (ship_no < 1) |
104 | ship_no = NO_OF_SHIPS; |
105 | } while (min_dist[ship_no] == 0); |
106 | |
107 | show_time = 0; |
108 | direction = -100; |
109 | |
110 | ship_count[universe[0].type] = 0; |
111 | universe[0].type = 0; |
112 | |
113 | add_new_ship (ship_no, 0, 0, 4500, intro_ship_matrix, -127, |
114 | -127); |
115 | ship_bump = +1; |
116 | } |
84bbd123 |
117 | |
118 | void update_intro2 (void) |
119 | { |
120 | show_time++; |
121 | |
c597a4f2 |
122 | if (direction < 0) { |
123 | if (kbd_left_pressed == 1) { |
124 | ship_bump = -1; |
125 | direction = -direction; |
126 | } else if (kbd_right_pressed == 1) { |
127 | ship_bump = +1; |
128 | direction = -direction; |
129 | } else if (show_time >= 140) |
130 | direction = -direction; |
131 | } |
84bbd123 |
132 | |
133 | universe[0].location.z += direction; |
134 | |
135 | if (universe[0].location.z < min_dist[ship_no]) |
136 | universe[0].location.z = min_dist[ship_no]; |
137 | |
138 | if (universe[0].location.z > 4500) |
c597a4f2 |
139 | next_ship(ship_bump); |
84bbd123 |
140 | |
141 | |
142 | gfx_clear_display(); |
143 | update_starfield(); |
144 | update_universe(); |
145 | |
146 | gfx_draw_sprite (IMG_ELITE_TXT, -1, 10); |
147 | |
148 | gfx_display_centre_text (360, "Press Fire or Space, Commander.", 140, GFX_COL_GOLD); |
149 | gfx_display_centre_text (330, ship_list[ship_no]->name, 120, GFX_COL_WHITE); |
150 | } |
151 | |