Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6788 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
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
[6086]19#include "load_param.h"
[6093]20#include "factory.h"
[6424]21
[6093]22#include "compiler.h"
[6080]23
[6424]24
[6080]25/**
[6081]26 *  standard constructor
[6080]27 */
[6093]28SpawningPoint::SpawningPoint (World* world, const Vector& absCoordinate)
[6084]29{
30  this->world = world;
31  this->frequency = 0.5f;
32  this->seed = 0.0f;
[6088]33
34  this->init();
[6084]35}
[6080]36
37
38/**
[6081]39 *  constructor
40 */
[6083]41SpawningPoint::SpawningPoint (const Vector& position, float frequency,
[6093]42                              float seed, ClassID classID, World* world)
[6081]43{
[6083]44  this->frequency = frequency;
45  this->seed = seed;
46  this->classID = classID;
47  this->world = world;
[6088]48
49  this->init();
50}
51
52
53void SpawningPoint::init()
54{
[6084]55  this->countDown = 0.0f;
[6081]56}
57
58
59/**
[6080]60 *  deconstructor
61 */
62SpawningPoint::~SpawningPoint ()
63{}
64
65
[6081]66/**
[6086]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{
[6087]72  /* let the world entity its stuff first */
[6512]73  WorldEntity::loadParams(root);
[6086]74
[6087]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);
[6086]79
[6087]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 */
[6093]87/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
[6088]88      .describe("sets the class id of the entity to spawn")
[6093]89      .defaultValues(1, CL_WORLD_ENTITY);*/
[6086]90}
91
92
93/**
[6081]94 *  spawn the entity
95 */
96void SpawningPoint::spawn()
[6083]97{
98  PRINTF(5)("Spangingpoint creates a new Entity (id: %i, frequency: %f, seed: %f)\n", this->classID,
[6087]99            this->frequency, this->seed);
[6083]100  BaseObject* spawningEntity = Factory::fabricate(this->classID);
[6424]101
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{
115  this->countDown += dt;
116  if( this->countDown > this->frequency)
117  {
118    this->spawn();
119    this->countDown = 0.0f;
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.