Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/spawning_point.cc @ 7774

Last change on this file since 7774 was 7357, checked in by patrick, 19 years ago

spawning point reviewed

File size: 2.9 KB
RevLine 
[6080]1
2/*
3   orxonox - the future of 3D-vertical-scrollers
4
5   Copyright (C) 2004 orx
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2, or (at your option)
10   any later version.
11
12### File Specific:
13   main-programmer: Patrick Boenzli
14   co-programmer:
15*/
16
17#include "spawning_point.h"
[6424]18
[7193]19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
[6424]21
[6093]22#include "compiler.h"
[6080]23
[6424]24
[6080]25/**
[7357]26 *  constructor
[6080]27 */
[7357]28SpawningPoint::SpawningPoint (ClassID classID, const Vector& position)
[6084]29{
[7357]30  this->setAbsCoor(position);
31  this->classID = classID;
32  this->mode = SPT_ALL_AT_ONCE;
33  this->delay = 0;
[6088]34
35  this->init();
[6084]36}
[6080]37
38
39/**
[7357]40 *  standard constructor
[6081]41 */
[7357]42SpawningPoint::SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode mode, float delay)
[6081]43{
[7357]44  this->setAbsCoor(position);
[6083]45  this->classID = classID;
[7357]46  this->mode = mode;
47  this->delay = delay;
[6088]48
49  this->init();
50}
51
52
[7357]53
[6088]54void SpawningPoint::init()
55{
[7357]56  this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
[6081]57}
58
59
60/**
[6080]61 *  deconstructor
62 */
63SpawningPoint::~SpawningPoint ()
64{}
65
66
[6081]67/**
[6086]68 * loads the WorldEntity Specific Parameters.
69 * @param root: the XML-Element to load the Data From
70 */
71void SpawningPoint::loadParams(const TiXmlElement* root)
72{
[6087]73  /* let the world entity its stuff first */
[6512]74  WorldEntity::loadParams(root);
[6086]75
[6087]76  /* now load the frequency */
[7357]77  LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)
78      .describe("sets the delay of the spawning point");
[6086]79
[6087]80
81  /* now load the seed */
[7357]82//   LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)
83//       .describe("sets the spawning entity");
[6087]84
85  /* now load the seed */
[6093]86/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
[6088]87      .describe("sets the class id of the entity to spawn")
[7198]88      .defaultValues(CL_WORLD_ENTITY);*/
[6086]89}
90
91
92/**
[6081]93 *  spawn the entity
94 */
95void SpawningPoint::spawn()
[6083]96{
[7357]97  PRINTF(5)("Spangingpoint creates a new Entity (id: %i, delay: %f, mode: %f)\n", this->classID,
98            this->delay, this->mode);
[6424]99
[7357]100  //BaseObject* spawningEntity = Factory::fabricate(this->classID);
101
[6424]102//   if( likely(this->world != NULL))
103//     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
[6083]104}
[6080]105
106
107/**
108 *  this method is called every frame
109 * @param time: the time in seconds that has passed since the last tick
110 *
111 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
112 */
113void SpawningPoint::tick(float dt)
[6084]114{
[7357]115  this->localTimer += dt;
116  if( this->localTimer > this->delay)
[6084]117  {
118    this->spawn();
[7357]119    this->localTimer = 0.0f;
[6084]120  }
121}
[6080]122
123
124/**
125 *  the entity is drawn onto the screen with this function
126 *
127 * This is a central function of an entity: call it to let the entity painted to the screen.
128 * Just override this function with whatever you want to be drawn.
129 */
130void SpawningPoint::draw()
[6087]131{}
Note: See TracBrowser for help on using the repository browser.