NXEngine v1.0.0.6
[NXEngine.git] / intro / intro.cpp
blob1cb52ec5fbd190718cdd6b055e9a1036ac4513c3
2 #include "../nx.h"
3 #include "../ai/stdai.h"
4 #include "intro.fdh"
6 static int blanktimer;
7 #define EXIT_DELAY 20 // delay between intro and title screen
9 bool intro_init(int param)
11 music(0);
12 fade.set_full(FADE_OUT);
14 game.switchstage.mapno = STAGE_KINGS;
15 game.switchstage.playerx = 0;
16 game.switchstage.playery = 0;
17 game.switchstage.eventonentry = 100;
18 player->hide = true;
20 return 0;
23 void intro_tick()
25 if (blanktimer > 0)
27 ClearScreen(BLACK);
29 if (--blanktimer == 0)
30 game.setmode(GM_TITLE);
31 return;
34 game_tick_normal();
35 player->y = 0;
37 // when script ends with WAI9999, detect it and move on to title screen
38 ScriptInstance *script = GetCurrentScriptInstance();
39 if ((script && script->delaytimer == 9999) || buttonjustpushed())
41 StopScripts();
42 blanktimer = EXIT_DELAY;
45 // lower time for startup
46 if (script && script->delaytimer && script->ip == 5)
48 game.showmapnametime = 0;
49 if (script->delaytimer > 20)
50 script->delaytimer = 20;
55 void c------------------------------() {}
58 INITFUNC(AIRoutines)
60 ONTICK(OBJ_INTRO_KINGS, ai_intro_kings);
61 ONTICK(OBJ_INTRO_CROWN, ai_intro_crown);
62 ONTICK(OBJ_INTRO_DOCTOR, ai_intro_doctor);
66 void c------------------------------() {}
69 // misery/balrog in bubble
70 void ai_intro_kings(Object *o)
72 switch(o->state)
74 case 0:
76 o->state = 1;
78 if (o->dir == LEFT)
80 o->timer = 25;
81 o->y -= 0x640;
84 case 1:
86 if (++o->timer >= 50)
88 o->timer = 0;
89 o->timer2 ^= 1;
92 if (o->timer2)
94 o->y += 0x40;
96 else
98 o->y -= 0x40;
101 break;
105 // demon crown on throne
106 void ai_intro_crown(Object *o)
108 switch(o->state)
110 case 0:
112 o->x += (8 << CSF);
113 o->y += (14 << CSF);
114 o->state = 1;
116 case 1:
118 if ((++o->timer % 8) == 1)
120 effect(o->x + random(-8<<CSF, 8<<CSF),
121 o->y + (8<<CSF),
122 EFFECT_GHOST_SPARKLE);
125 break;
130 void ai_intro_doctor(Object *o)
133 switch(o->state)
135 case 0:
137 o->y -= (8 << CSF);
138 o->state = 1;
140 case 1:
142 o->frame = 0;
144 break;
146 case 10: // chuckle; facing screen
148 o->state = 11;
149 o->frame = 0;
150 o->animtimer = 0;
151 o->timer2 = 0;
153 case 11:
155 ANIMATE_FWD(6);
156 if (o->frame > 1)
158 o->frame = 0;
159 if (++o->timer2 > 7)
160 o->state = 1;
163 break;
165 case 20: // walk
167 o->state = 21;
168 o->frame = 2;
169 o->animtimer = 0;
171 case 21:
173 ANIMATE(10, 2, 5);
174 o->x += 0x100;
176 break;
178 case 30: // face away
180 o->frame = 6;
181 o->state = 31;
183 break;
185 case 40: // chuckle; facing away
187 o->state = 41;
188 o->frame = 6;
189 o->animtimer = 0;
190 o->timer2 = 0;
192 case 41:
194 ANIMATE_FWD(6);
195 if (o->frame > 7)
197 o->frame = 6;
198 if (++o->timer2 > 7)
199 o->state = 30;
202 break;