Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/chris/src/world_entity.cc @ 2097

Last change on this file since 2097 was 2096, checked in by chris, 21 years ago

orxonox/branches/chris: Messed with the Player class, added stuff here and there, debug world now creates a player and bind IO to it. Added some doxygen tags.

File size: 3.6 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer: Christian Meyer
16*/
17
18#include <iostream>
19
20#include "world_entity.h"
21
22#include "vector.h"
23
24using namespace std;
25
26
27/**
28   \brief
29   \param v:
30   \return
31*/
32
33/**
34   \brief Constructor
35
36   This Constructor initializises the all WorldEntities. Everything, that is a part of the game-world is a child of WorldEntity. This class implements empty functions for all sort of operation a WorldEntity has to or can implement.
37This is some sort of standard interface to all WorldEntities...
38*/
39WorldEntity::WorldEntity (bool isFree = false) : bFree(isFree)
40{
41        collisioncluster = NULL;
42        owner = NULL;
43}
44
45WorldEntity::~WorldEntity () {}
46
47Location* WorldEntity::get_location ()
48{
49        return &loc;
50}
51
52Placement* WorldEntity::get_placement ()
53{
54        return &place;
55}
56
57void WorldEntity::set_collision (CollisionCluster* newhull)
58{
59        if( newhull == NULL) return;
60        if( collisioncluster != NULL) delete collisioncluster;
61        collisioncluster = newhull;
62}
63
64/**
65   \brief sets the speed of the entity, if any
66   \param speed: the speed in points (openGL points) per seconds
67*/
68void WorldEntity::setSpeed(float speed)
69{
70  this->speed = speed;
71}
72
73/**
74   \brief gets the speed of the entity, if any
75   \return the speed in points (openGL points) per seconds
76*/
77float WorldEntity::getSpeed()
78{
79  return speed;
80}
81
82/**
83   \brief sets the health of the entity
84   \param health: number for the life count, normaly {0..100}
85*/
86void WorldEntity::setHealth(float health)
87{
88  this->health = health;
89}
90
91/**
92   \brief gets the health of the entity
93   \return number for the life count, normaly {0..100}
94*/
95float WorldEntity::getHealth()
96{
97  return health;
98}
99
100/**
101   \brief this method is called every tick
102   \param time: the time since start of the world
103
104   This function is called before every repaint of the world, to update every time dependent variable of the entity. If the entity moves, it has to calculate the new position every tick here in this function. Do not use this for animations.
105*/
106void WorldEntity::tick(float time) 
107{}
108
109/**
110   \brief the entity is painted to the screen with this function
111
112   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
113*/
114void WorldEntity::draw() 
115{
116  cout << "WorldEntity::draw()" << endl;
117}
118
119/* virtual void WorldEntity::actionEvent(Event* event); */
120/**
121   \brief this function is called, when two entities collide
122   \param we: the world entity, with whom it collides
123   \param loc: place where the collision happens
124*/
125void WorldEntity::collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) {}
126
127/**
128   \brief this function is called, when the ship is hit by a waepon
129   \param weapon: the laser/rocket/shoot that hits.
130   \param loc: place where it is hit
131
132   calculate the damage depending
133*/
134void WorldEntity::hit(WorldEntity* weapon, Vector loc) {}
135
136/**
137   \brief this function is called, if the entity is to be destroied
138   
139   This can be called, if eg. something realy bad happens :)
140*/
141void WorldEntity::destroy() {}
142
143void WorldEntity::init( Location* spawnloc, WorldEntity* spawnowner)
144{
145        loc = *spawnloc;
146        owner = spawnowner;
147}
148
149void WorldEntity::init( Placement* spawnplc, WorldEntity* spawnowner)
150{
151        plc = *spawnplc;
152        owner = spawnowner;
153}
154
Note: See TracBrowser for help on using the repository browser.