// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
#include <config.h>
#include <memory>
#include <stdexcept>
#include <iostream>
#include <fstream>
+#include <sstream>
#include <stdexcept>
#include "sector.h"
#include "object/block.h"
#include "object/invisible_block.h"
#include "object/bullet.h"
+#include "object/text_object.h"
#include "badguy/jumpy.h"
#include "badguy/spike.h"
#include "trigger/sequence_trigger.h"
#include "player_status.h"
+#include "scripting/script_interpreter.h"
+#include "scripting/sound.h"
+#include "scripting/scripted_object.h"
+#include "scripting/text.h"
//#define USE_GRID
spawnpoint_lisp->get("x", sp->pos.x);
spawnpoint_lisp->get("y", sp->pos.y);
spawnpoints.push_back(sp);
+ } else if(token == "init-script") {
+ iter.value()->get(init_script);
} else {
GameObject* object = parse_object(token, *(iter.lisp()));
if(object) {
} else {
activate(sp->pos);
}
+
+ // Run init script
+ if(init_script != "") {
+ try {
+ ScriptInterpreter* interpreter = new ScriptInterpreter(this);
+ std::string sourcename = std::string("Sector(") + name + ") - init";
+ std::istringstream in(init_script);
+ interpreter->load_script(in, sourcename);
+ interpreter->start_script();
+ add_object(interpreter);
+ init_script = "";
+ } catch(std::exception& e) {
+ std::cerr << "Couldn't execute init script: " << e.what() << "\n";
+ }
+ }
}
void
}
void
-Sector::action(float elapsed_time)
+Sector::update(float elapsed_time)
{
player->check_bounds(camera);
if(!object->is_valid())
continue;
- object->action(elapsed_time);
+ object->update(elapsed_time);
}
#else
/* update objects */
if(!object->is_valid())
continue;
- object->action(elapsed_time);
+ object->update(elapsed_time);
}
#endif
const Tile* tile = solids->get_tile(x, y);
if(!tile)
continue;
+ // skip non-solid tiles
if(!(tile->getAttributes() & Tile::SOLID))
continue;
- if((tile->getAttributes() & Tile::UNISOLID) && object->movement.y < 0)
- continue;
+ // only handle unisolid when the player is falling down and when he was
+ // above the tile before
+ if(tile->getAttributes() & Tile::UNISOLID) {
+ if(object->movement.y < 0 || object->get_bbox().p2.y > y*32)
+ continue;
+ }
if(tile->getAttributes() & Tile::SLOPE) { // slope tile
AATriangle triangle;