2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 void playIntro(int tx, int ty, int delay)
26 unsigned int frameLimit = SDL_GetTicks() + 16;
27 unsigned int time = 0;
29 graphics.setFontSize(1);
30 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
35 for (int i = 0 ; i < 3 ; i++)
37 line[i] = strtok(NULL, "\n");
41 graphics.showErrorAndExit("Malformed Intro Data", "");
46 if (strcmp(line[i], "@none@"))
48 text[i] = graphics.getString(line[i], true);
57 engine.setPlayerPosition((int)player.x, (int)player.y, map.limitLeft, map.limitRight, map.limitUp, map.limitDown);
63 for (int i = 0 ; i < 3 ; i++)
65 graphics.blit(text[i], 320, 150 + (i * 30), graphics.screen, true);
67 if (engine.userAccepts())
70 if (player.x < player.tx) player.x++;
71 if (player.x > player.tx) player.x--;
73 if ((int)player.x == player.tx)
77 time = SDL_GetTicks() + (delay * 1000);
82 if (SDL_GetTicks() > time)
85 engine.delay(frameLimit);
86 frameLimit = SDL_GetTicks() + 16;
89 for (int i = 0 ; i < 3 ; i++)
91 SDL_FreeSurface(text[i]);
96 SDL_FillRect(graphics.screen, NULL, graphics.black);
100 graphics.setFontSize(1);
102 graphics.drawString("Couldn't play intro - Data file is missing.", 320, 150, true, graphics.screen);
103 graphics.drawString("This is not a fatal error, but could mean that the intro", 320, 180, true, graphics.screen);
104 graphics.drawString("file has not been found or was not in the expected format.", 320, 210, true, graphics.screen);
105 graphics.drawString("However it may also be a sign that the game may not work correctly.", 320, 240, true, graphics.screen);
106 graphics.drawString("Press Escape to Continue", 320, 350, true, graphics.screen);
110 graphics.updateScreen();
113 if (engine.keyState[SDL_SCANCODE_ESCAPE])
119 void parseIntroCommand()
122 char command[25], param[25];
124 line = strtok(NULL, "\n");
125 sscanf(line, "%s %s", command, param);
127 if (strcmp(command, "SPAWN") == 0)
129 SpawnPoint *sp = (SpawnPoint*)map.spawnList.getHead();
131 while (sp->next != NULL)
133 sp = (SpawnPoint*)sp->next;
135 if (strcmp(param, sp->name) == 0)
147 game.setMapName("data/introMap");
151 for (int i = 0 ; i < 4 ; i++)
153 addItem(101, "CherryPlant", Math::prand() % 640, 9050, "CherryPlant", 100, 1, 0, false);
156 if (!engine.loadData(_("data/introText")))
159 return SECTION_TITLE;
162 player.health = -100;
166 char *line = strtok((char*)engine.dataBuffer, "\n");
170 line = strtok(NULL, "\n");
171 sscanf(line, "%d %d %d", &x, &y, &delay);
178 playIntro(x, y, delay);
180 if (engine.userAccepts())
184 if (!engine.userAccepts())
187 graphics.fadeToBlack();
192 return SECTION_TITLE;