2 /***************************************************************************
3 gameobjs_bridge.cpp - description
6 copyright : (C) 2004 by Ricardo Cruz
8 ***************************************************************************/
10 /***************************************************************************
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
17 ***************************************************************************/
19 #include "gameobjs_bridge.h"
21 #include "object/coin.h"
22 #include "object/block.h"
23 #include "object/invisible_block.h"
24 #include "object/platform.h"
25 #include "object/bullet.h"
26 #include "object/rock.h"
27 #include "badguy/jumpy.h"
28 #include "badguy/snowball.h"
29 #include "badguy/bouncing_snowball.h"
30 #include "badguy/flame.h"
31 #include "badguy/flyingsnowball.h"
32 #include "badguy/mriceblock.h"
33 #include "badguy/mrbomb.h"
34 #include "badguy/dispenser.h"
35 #include "badguy/spike.h"
36 #include "badguy/spiky.h"
37 #include "badguy/nolok_01.h"
38 #include "trigger/door.h"
39 #include "trigger/sequence_trigger.h"
40 #include "trigger/secretarea_trigger.h"
42 std::string object_type_to_string(int kind)
49 case INVISIBLE_BLOCK_OBJECT:
50 return "invisible-block";
60 case BOUNCING_SNOWBALL_BADGUY:
61 return "bouncingsnowball";
64 case FLYING_SNOWBALL_BADGUY:
65 return "flyingsnowball";
66 case MRICEBLOCK_BADGUY:
70 case DISPENSER_BADGUY:
82 std::cerr << "Warning: object not recognized.\n";
83 return ""; // should not happen
85 return ""; // avoids warnings
88 GameObjectsType object_name_to_type(const std::string& name)
93 else if(name == "invisible-block")
94 return INVISIBLE_BLOCK_OBJECT;
95 else if(name == "platform")
96 return PLATFORM_OBJECT;
97 else if(name == "rock")
100 else if(name == "jumpy")
102 else if(name == "snowball")
103 return SNOWBALL_BADGUY;
104 else if(name == "bouncingsnowball")
105 return BOUNCING_SNOWBALL_BADGUY;
106 else if(name == "flame")
108 else if(name == "flyingsnowball")
109 return FLYING_SNOWBALL_BADGUY;
110 else if(name == "mriceblock")
111 return MRICEBLOCK_BADGUY;
112 else if(name == "mrbomb")
113 return MRBOMB_BADGUY;
114 else if(name == "dispenser")
115 return DISPENSER_BADGUY;
116 else if(name == "spike")
118 else if(name == "spiky")
120 else if(name == "nolok_01")
121 return NOLOK_01_BADGUY;
123 else if(name == "door")
126 // Object not recognized
127 return NOT_RECOGNIZED_GAMEOBJECT;
130 bool is_object(const std::string& name)
132 if(object_name_to_type(name) == NOT_RECOGNIZED_GAMEOBJECT)
137 GameObject* create_object(GameObjectsType kind, const lisp::Lisp& reader)
143 case INVISIBLE_BLOCK_OBJECT:
144 std::cerr << "Error: This object doesn't yet supported a Lisp argument.\n";
146 // return new Coin(reader);
147 // return new InvisibleBlock(reader);
148 case PLATFORM_OBJECT:
149 return new Platform(reader);
151 return new Rock(reader);
154 return new Jumpy(reader);
155 case SNOWBALL_BADGUY:
156 return new SnowBall(reader);
157 case BOUNCING_SNOWBALL_BADGUY:
158 return new BouncingSnowball(reader);
160 return new Flame(reader);
161 case FLYING_SNOWBALL_BADGUY:
162 return new FlyingSnowBall(reader);
163 case MRICEBLOCK_BADGUY:
164 return new MrIceBlock(reader);
166 return new MrBomb(reader);
167 case DISPENSER_BADGUY:
168 return new Dispenser(reader);
170 return new Spike(reader);
172 return new Spiky(reader);
173 case NOLOK_01_BADGUY:
174 return new Nolok_01(reader);
177 return new Door(reader);
179 std::cerr << "Warning: object not recognized.\n";
180 return NULL; // object not recognized
182 return NULL; // avoids warnings
185 GameObject* create_object(GameObjectsType kind, const Vector& pos)
191 return new Coin(pos);
192 case INVISIBLE_BLOCK_OBJECT:
193 return new InvisibleBlock(pos);
194 case PLATFORM_OBJECT:
198 case DISPENSER_BADGUY:
200 std::cerr << "Error: This object doesn't yet support a position argument.\n";
202 // return new Platform(pos);
203 // return new Rock(pos);
205 // return new Jumpy(pos.x,pos.y,LEFT);
206 // return new Flame(pos.x,pos.y,LEFT);
207 // return new Dispenser(pos.x,pos.y,LEFT);
208 // return new Spiky(pos.x,pos.y,LEFT);
209 case SNOWBALL_BADGUY:
210 return new SnowBall(pos.x,pos.y,LEFT);
211 case BOUNCING_SNOWBALL_BADGUY:
212 return new BouncingSnowball(pos.x,pos.y,LEFT);
213 case FLYING_SNOWBALL_BADGUY:
214 return new FlyingSnowBall(pos.x,pos.y);
215 case MRICEBLOCK_BADGUY:
216 return new MrIceBlock(pos.x,pos.y,LEFT);
218 return new MrBomb(pos.x,pos.y,LEFT);
220 return new Spike(pos,Spike::WEST);
221 case NOLOK_01_BADGUY:
222 return new Nolok_01(pos.x,pos.y);
225 return new Door((int)pos.x,(int)pos.y,"","");
227 std::cerr << "Warning: object not recognized.\n";
228 return NULL; // object not recognized
230 return NULL; // avoids warnings