2 Copyright (C) 2004 Parallel Realities
3 Copyright (C) 2007 Kővágó Zoltán
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.
23 #include "gettext.hpp"
25 void playIntro(int tx
, int ty
, int delay
)
27 unsigned int frameLimit
= SDL_GetTicks() + 16;
28 unsigned int time
= 0;
30 graphics
.setFontSize(1);
31 graphics
.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
36 for (int i
= 0 ; i
< 3 ; i
++)
38 line
[i
] = strtok(NULL
, "\n");
42 graphics
.showErrorAndExit(_("Malformed Intro Data"), "");
47 if (strcmp(line
[i
], "@none@"))
49 text
[i
] = graphics
.getString(_(line
[i
]), true);
58 engine
.setPlayerPosition((int)player
.x
, (int)player
.y
, map
.limitLeft
, map
.limitRight
, map
.limitUp
, map
.limitDown
);
64 for (int i
= 0 ; i
< 3 ; i
++)
66 graphics
.blit(text
[i
], bx
+ 320, 150 + (i
* 30), graphics
.screen
, true);
68 if (engine
.userAccepts())
71 if (player
.x
< player
.tx
) player
.x
++;
72 if (player
.x
> player
.tx
) player
.x
--;
74 if ((int)player
.x
== player
.tx
)
78 time
= SDL_GetTicks() + (delay
* 1000);
83 if (SDL_GetTicks() > time
)
86 engine
.delay(frameLimit
);
87 frameLimit
= SDL_GetTicks() + 16;
90 for (int i
= 0 ; i
< 3 ; i
++)
92 SDL_FreeSurface(text
[i
]);
97 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
101 graphics
.setFontSize(1);
103 graphics
.drawString(_("Couldn't play intro - Data file is missing."), 320, 150, true, graphics
.screen
);
104 graphics
.drawString(_("This is not a fatal error, but could mean that the intro"), 320, 180, true, graphics
.screen
);
105 graphics
.drawString(_("file has not been found or was not in the expected format."), 320, 210, true, graphics
.screen
);
106 graphics
.drawString(_("However it may also be a sign that the game may not work correctly."), 320, 240, true, graphics
.screen
);
107 graphics
.drawString(_("Press Escape to Continue"), 320, 350, true, graphics
.screen
);
111 graphics
.updateScreen();
113 if (engine
.keyState
[SDLK_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", rand() % 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
;