Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/powerups/src/world_entities/spawning_point.cc @ 6461

Last change on this file since 6461 was 6139, checked in by patrick, 19 years ago

trunk: merged branche network with trunk using command: svn merge -r5999:HEAD, conflicts resolved in favor of the trunk bla

File size: 3.0 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#include "load_param.h"
19#include "factory.h"
20#include "compiler.h"
21#include "world.h" /* only temp. until the object manager is implemented*/
22
23/**
24 *  standard constructor
25 */
26SpawningPoint::SpawningPoint (World* world, const Vector& absCoordinate)
27{
28  this->world = world;
29  this->frequency = 0.5f;
30  this->seed = 0.0f;
31
32  this->init();
33}
34
35
36/**
37 *  constructor
38 */
39SpawningPoint::SpawningPoint (const Vector& position, float frequency,
40                              float seed, ClassID classID, World* world)
41{
42  this->frequency = frequency;
43  this->seed = seed;
44  this->classID = classID;
45  this->world = world;
46
47  this->init();
48}
49
50
51void SpawningPoint::init()
52{
53  this->countDown = 0.0f;
54}
55
56
57/**
58 *  deconstructor
59 */
60SpawningPoint::~SpawningPoint ()
61{}
62
63
64/**
65 * loads the WorldEntity Specific Parameters.
66 * @param root: the XML-Element to load the Data From
67 */
68void SpawningPoint::loadParams(const TiXmlElement* root)
69{
70  /* let the world entity its stuff first */
71  static_cast<WorldEntity*>(this)->loadParams(root);
72
73  /* now load the frequency */
74  LoadParam(root, "frequency", this, SpawningPoint, setSpawningFrequency)
75  .describe("sets the frequency of the spawning point")
76  .defaultValues(1, 1.0f);
77
78
79  /* now load the seed */
80  LoadParam(root, "randomseed", this, SpawningPoint, setPositionSeed)
81      .describe("sets the random position seed (variance in the spawning location around the position)")
82      .defaultValues(1, 0.0f);
83
84  /* now load the seed */
85/*  LoadParam(root, "classid", this, SpawningPoint, setSpawningEntity)
86      .describe("sets the class id of the entity to spawn")
87      .defaultValues(1, CL_WORLD_ENTITY);*/
88}
89
90
91/**
92 *  spawn the entity
93 */
94void SpawningPoint::spawn()
95{
96  PRINTF(5)("Spangingpoint creates a new Entity (id: %i, frequency: %f, seed: %f)\n", this->classID,
97            this->frequency, this->seed);
98  BaseObject* spawningEntity = Factory::fabricate(this->classID);
99  if( likely(this->world != NULL))
100    this->world->spawn(dynamic_cast<WorldEntity*>(spawningEntity));
101}
102
103
104/**
105 *  this method is called every frame
106 * @param time: the time in seconds that has passed since the last tick
107 *
108 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
109 */
110void SpawningPoint::tick(float dt)
111{
112  this->countDown += dt;
113  if( this->countDown > this->frequency)
114  {
115    this->spawn();
116    this->countDown = 0.0f;
117  }
118}
119
120
121/**
122 *  the entity is drawn onto the screen with this function
123 *
124 * This is a central function of an entity: call it to let the entity painted to the screen.
125 * Just override this function with whatever you want to be drawn.
126 */
127void SpawningPoint::draw()
128{}
Note: See TracBrowser for help on using the repository browser.