Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6683 was 6512, checked in by bensch, 19 years ago

orxonox/trunk: loadParams is now virtual.
ALL THE CLASSES HAVE TO CALL

SuperClass::loadParams(root);

isntead of:
static_cast<SuperClass*>(this)→loadParams(root);

which was quite stupid anyways

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 "load_param.h"
20#include "factory.h"
21
22#include "compiler.h"
23
24
25/**
26 *  standard constructor
27 */
28SpawningPoint::SpawningPoint (World* world, const Vector& absCoordinate)
29{
30  this->world = world;
31  this->frequency = 0.5f;
32  this->seed = 0.0f;
33
34  this->init();
35}
36
37
38/**
39 *  constructor
40 */
41SpawningPoint::SpawningPoint (const Vector& position, float frequency,
42                              float seed, ClassID classID, World* world)
43{
44  this->frequency = frequency;
45  this->seed = seed;
46  this->classID = classID;
47  this->world = world;
48
49  this->init();
50}
51
52
53void SpawningPoint::init()
54{
55  this->countDown = 0.0f;
56}
57
58
59/**
60 *  deconstructor
61 */
62SpawningPoint::~SpawningPoint ()
63{}
64
65
66/**
67 * loads the WorldEntity Specific Parameters.
68 * @param root: the XML-Element to load the Data From
69 */
70void SpawningPoint::loadParams(const TiXmlElement* root)
71{
72  /* let the world entity its stuff first */
73  WorldEntity::loadParams(root);
74
75  /* now load the frequency */
76  LoadParam(root, "frequency", this, SpawningPoint, setSpawningFrequency)
77  .describe("sets the frequency of the spawning point")
78  .defaultValues(1, 1.0f);
79
80
81  /* now load the seed */
82  LoadParam(root, "randomseed", this, SpawningPoint, setPositionSeed)
83      .describe("sets the random position seed (variance in the spawning location around the position)")
84      .defaultValues(1, 0.0f);
85
86  /* now load the seed */
87/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
88      .describe("sets the class id of the entity to spawn")
89      .defaultValues(1, CL_WORLD_ENTITY);*/
90}
91
92
93/**
94 *  spawn the entity
95 */
96void SpawningPoint::spawn()
97{
98  PRINTF(5)("Spangingpoint creates a new Entity (id: %i, frequency: %f, seed: %f)\n", this->classID,
99            this->frequency, this->seed);
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->countDown += dt;
116  if( this->countDown > this->frequency)
117  {
118    this->spawn();
119    this->countDown = 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.