/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: */ #include "spawning_point.h" #include "util/loading/load_param.h" #include "util/loading/factory.h" #include "compiler.h" /** * constructor */ SpawningPoint::SpawningPoint (ClassID classID, const Vector& position) { this->setAbsCoor(position); this->classID = classID; this->mode = SPT_ALL_AT_ONCE; this->delay = 0; this->init(); } /** * standard constructor */ SpawningPoint::SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode mode, float delay) { this->setAbsCoor(position); this->classID = classID; this->mode = mode; this->delay = delay; this->init(); } void SpawningPoint::init() { this->setClassID(CL_SPAWNING_POINT, "SpawningPoint"); } /** * deconstructor */ SpawningPoint::~SpawningPoint () {} /** * loads the WorldEntity Specific Parameters. * @param root: the XML-Element to load the Data From */ void SpawningPoint::loadParams(const TiXmlElement* root) { /* let the world entity its stuff first */ WorldEntity::loadParams(root); /* now load the frequency */ LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay) .describe("sets the delay of the spawning point"); /* now load the seed */ // LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity) // .describe("sets the spawning entity"); /* now load the seed */ /* LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity) .describe("sets the class id of the entity to spawn") .defaultValues(CL_WORLD_ENTITY);*/ } /** * spawn the entity */ void SpawningPoint::spawn() { PRINTF(5)("Spangingpoint creates a new Entity (id: %i, delay: %f, mode: %f)\n", this->classID, this->delay, this->mode); //BaseObject* spawningEntity = Factory::fabricate(this->classID); // if( likely(this->world != NULL)) // this->world->spawn(dynamic_cast(spawningEntity)); } /** * this method is called every frame * @param time: the time in seconds that has passed since the last tick * * Handle all stuff that should update with time inside this method (movement, animation, etc.) */ void SpawningPoint::tick(float dt) { this->localTimer += dt; if( this->localTimer > this->delay) { this->spawn(); this->localTimer = 0.0f; } } /** * the entity is drawn onto the screen with this function * * This is a central function of an entity: call it to let the entity painted to the screen. * Just override this function with whatever you want to be drawn. */ void SpawningPoint::draw() {}