Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

spawning point reviewed

File size: 2.9 KB
Line 
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"
18
19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
21
22#include "compiler.h"
23
24
25/**
26 *  constructor
27 */
28SpawningPoint::SpawningPoint (ClassID classID, const Vector& position)
29{
30  this->setAbsCoor(position);
31  this->classID = classID;
32  this->mode = SPT_ALL_AT_ONCE;
33  this->delay = 0;
34
35  this->init();
36}
37
38
39/**
40 *  standard constructor
41 */
42SpawningPoint::SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode mode, float delay)
43{
44  this->setAbsCoor(position);
45  this->classID = classID;
46  this->mode = mode;
47  this->delay = delay;
48
49  this->init();
50}
51
52
53
54void SpawningPoint::init()
55{
56  this->setClassID(CL_SPAWNING_POINT, "SpawningPoint");
57}
58
59
60/**
61 *  deconstructor
62 */
63SpawningPoint::~SpawningPoint ()
64{}
65
66
67/**
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{
73  /* let the world entity its stuff first */
74  WorldEntity::loadParams(root);
75
76  /* now load the frequency */
77  LoadParam(root, "delay", this, SpawningPoint, setSpawningDelay)
78      .describe("sets the delay of the spawning point");
79
80
81  /* now load the seed */
82//   LoadParam(root, "entity", this, SpawningPoint, setSpawningEntity)
83//       .describe("sets the spawning entity");
84
85  /* now load the seed */
86/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
87      .describe("sets the class id of the entity to spawn")
88      .defaultValues(CL_WORLD_ENTITY);*/
89}
90
91
92/**
93 *  spawn the entity
94 */
95void SpawningPoint::spawn()
96{
97  PRINTF(5)("Spangingpoint creates a new Entity (id: %i, delay: %f, mode: %f)\n", this->classID,
98            this->delay, this->mode);
99
100  //BaseObject* spawningEntity = Factory::fabricate(this->classID);
101
102//   if( likely(this->world != NULL))
103//     this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
104}
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)
114{
115  this->localTimer += dt;
116  if( this->localTimer > this->delay)
117  {
118    this->spawn();
119    this->localTimer = 0.0f;
120  }
121}
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()
131{}
Note: See TracBrowser for help on using the repository browser.