2 Copyright (C) 2004 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 void playIntro(int tx, int ty, int delay)
25 unsigned int frameLimit = SDL_GetTicks() + 16;
26 unsigned int time = 0;
28 graphics.setFontSize(1);
29 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
34 for (int i = 0 ; i < 3 ; i++)
36 line[i] = strtok(NULL, "\n");
40 graphics.showErrorAndExit("Malformed Intro Data", "");
45 if (strcmp(line[i], "@none@"))
47 text[i] = graphics.getString(line[i], true);
56 engine.setPlayerPosition((int)player.x, (int)player.y, map.limitLeft, map.limitRight, map.limitUp, map.limitDown);
62 for (int i = 0 ; i < 3 ; i++)
64 graphics.blit(text[i], 320, 150 + (i * 30), graphics.screen, true);
66 if (engine.userAccepts())
69 if (player.x < player.tx) player.x++;
70 if (player.x > player.tx) player.x--;
72 if ((int)player.x == player.tx)
76 time = SDL_GetTicks() + (delay * 1000);
81 if (SDL_GetTicks() > time)
84 engine.delay(frameLimit);
85 frameLimit = SDL_GetTicks() + 16;
88 for (int i = 0 ; i < 3 ; i++)
90 SDL_FreeSurface(text[i]);
95 SDL_FillRect(graphics.screen, NULL, graphics.black);
99 graphics.setFontSize(1);
101 graphics.drawString("Couldn't play intro - Data file is missing.", 320, 150, true, graphics.screen);
102 graphics.drawString("This is not a fatal error, but could mean that the intro", 320, 180, true, graphics.screen);
103 graphics.drawString("file has not been found or was not in the expected format.", 320, 210, true, graphics.screen);
104 graphics.drawString("However it may also be a sign that the game may not work correctly.", 320, 240, true, graphics.screen);
105 graphics.drawString("Press Escape to Continue", 320, 350, true, graphics.screen);
109 graphics.updateScreen();
112 if (engine.keyState[SDLK_ESCAPE])
118 void parseIntroCommand()
121 char command[25], param[25];
123 line = strtok(NULL, "\n");
124 sscanf(line, "%s %s", command, param);
126 if (strcmp(command, "SPAWN") == 0)
128 SpawnPoint *sp = (SpawnPoint*)map.spawnList.getHead();
130 while (sp->next != NULL)
132 sp = (SpawnPoint*)sp->next;
134 if (strcmp(param, sp->name) == 0)
146 game.setMapName("data/introMap");
150 for (int i = 0 ; i < 4 ; i++)
152 addItem(101, "CherryPlant", Math::prand() % 640, 9050, "CherryPlant", 100, 1, 0, false);
155 if (!engine.loadData(_("data/introText")))
158 return SECTION_TITLE;
161 player.health = -100;
165 char *line = strtok((char*)engine.dataBuffer, "\n");
169 line = strtok(NULL, "\n");
170 sscanf(line, "%d %d %d", &x, &y, &delay);
177 playIntro(x, y, delay);
179 if (engine.userAccepts())
183 if (!engine.userAccepts())
186 graphics.fadeToBlack();
191 return SECTION_TITLE;