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 addLineDef(const char *name, const char *linkName, const char *message, int x, int y, int width, int height, bool active)
26 LineDef *lineDef = new LineDef();
28 lineDef->set(name, linkName, message, x, y, width, height);
29 lineDef->activated = active;
31 map.addLineDef(lineDef);
34 void showMessageLineDef(const char *linkName, bool show)
36 LineDef *lineDef = (LineDef*)map.lineList.getHead();
38 while (lineDef->next != NULL)
40 lineDef = (LineDef*)lineDef->next;
42 if (strcmp(lineDef->linkName, linkName) == 0)
43 lineDef->activated = show;
49 LineDef *lineDef = (LineDef*)map.lineList.getHead();
53 while (lineDef->next != NULL)
55 lineDef = (LineDef*)lineDef->next;
57 if (lineDef->activated)
60 x = (int)(lineDef->x - engine.playerPosX);
61 y = (int)(lineDef->y - engine.playerPosY);
66 if ((absX < 800) && (absY < 600))
69 graphics.drawRect(x, y, lineDef->width, lineDef->height, graphics.red, graphics.screen);
72 if (player.health < 1)
77 if (Collision::collision(player.x + player.dx, player.y + player.dy, player.width, player.height, lineDef->x, lineDef->y, lineDef->width, lineDef->height))
79 if ((strcmp(lineDef->name, "Exit") == 0) && (!requiredObjectivesCompleted()))
81 config.resetControl(CONTROL::LEFT);
82 config.resetControl(CONTROL::RIGHT);
84 if (player.dx > 0) player.x = (lineDef->x - player.width) - 2;
85 if (player.dx < 0) player.x = (lineDef->x + lineDef->width + 2);
89 if (!map.isBossMission)
91 engine.setInfoMessage("Can't Exit Yet - Objectives Not Met", 1, INFO_HINT);
97 if (strcmp(lineDef->name, "Message") == 0)
99 engine.setInfoMessage(lineDef->activateMessage, 1, INFO_HINT);
100 if (strcmp(lineDef->linkName, "@none@") == 0)
102 lineDef->activated = true;
105 else if (strcmp(lineDef->name, "PlayerOut") == 0)
107 if (game.missionOver == 0)
112 if (player.health > 0)
114 game.setMissionOver(MIS_PLAYEROUT);
118 game.setMissionOver(MIS_PLAYERDEAD);
121 else if (strcmp(lineDef->name, "CheckPoint") == 0)
123 game.setObjectiveCheckPoint();
124 engine.setInfoMessage("Checkpoint Reached", 9, INFO_OBJECTIVE);
125 lineDef->activated = true;
127 else if (strcmp(lineDef->name, "ActivateBoss") == 0)
129 map.mainBossPart->active = true;
130 lineDef->activated = true;
134 checkObjectives(lineDef->name, true);
135 activateTrigger(lineDef->linkName, lineDef->activateMessage, true);
136 lineDef->activated = true;
138 if (strcmp(lineDef->name, "StealCrystal") == 0)
141 lineDef->activated = true;