[8338] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #include "collision_probe.h" |
---|
| 19 | |
---|
| 20 | #include "util/loading/factory.h" |
---|
| 21 | #include "util/loading/load_param.h" |
---|
| 22 | |
---|
[8346] | 23 | #include "md2/md2Model.h" |
---|
[8338] | 24 | |
---|
| 25 | |
---|
| 26 | using namespace std; |
---|
| 27 | |
---|
| 28 | CREATE_FACTORY(CollisionProbe, CL_COLLISION_PROBE); |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | /** |
---|
| 32 | * destructs the spaceship, deletes alocated memory |
---|
| 33 | */ |
---|
| 34 | CollisionProbe::~CollisionProbe () |
---|
| 35 | {} |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * creates a new Spaceship from Xml Data |
---|
| 40 | * @param root the xml element containing spaceship data |
---|
| 41 | |
---|
| 42 | @todo add more parameters to load |
---|
| 43 | */ |
---|
| 44 | CollisionProbe::CollisionProbe(const TiXmlElement* root) |
---|
| 45 | { |
---|
| 46 | this->init(); |
---|
[8341] | 47 | |
---|
[8338] | 48 | if (root != NULL) |
---|
| 49 | this->loadParams(root); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | /** |
---|
| 54 | * initializes a Spaceship |
---|
| 55 | */ |
---|
| 56 | void CollisionProbe::init() |
---|
| 57 | { |
---|
| 58 | this->setClassID(CL_COLLISION_PROBE, "CollisionProbe"); |
---|
| 59 | |
---|
| 60 | bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false; |
---|
| 61 | |
---|
| 62 | this->setHealthMax(100); |
---|
| 63 | this->setHealth(80); |
---|
| 64 | |
---|
[8343] | 65 | this->toList(OM_GROUP_00); |
---|
[8338] | 66 | this->loadMD2Texture("maps/dr_freak.pcx"); |
---|
| 67 | this->loadModel("models/dr_freak.md2"); |
---|
[8341] | 68 | |
---|
| 69 | this->localVelocity = Vector(0,-4,0); |
---|
[8338] | 70 | } |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * loads the Settings of a CollisionProbe from an XML-element. |
---|
| 75 | * @param root the XML-element to load the Spaceship's properties from |
---|
| 76 | */ |
---|
| 77 | void CollisionProbe::loadParams(const TiXmlElement* root) |
---|
| 78 | { |
---|
| 79 | Playable::loadParams(root); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | * draws the spaceship after transforming it. |
---|
| 86 | */ |
---|
| 87 | void CollisionProbe::draw () const |
---|
| 88 | { |
---|
| 89 | WorldEntity::draw(); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | /** |
---|
| 94 | * the function called for each passing timeSnap |
---|
| 95 | * @param time The timespan passed since last update |
---|
| 96 | */ |
---|
| 97 | void CollisionProbe::tick (float time) |
---|
| 98 | { |
---|
| 99 | if( likely(this->getModel(0) != NULL)) |
---|
| 100 | ((MD2Model*)this->getModel(0))->tick(time); |
---|
[8341] | 101 | |
---|
| 102 | this->shiftCoor(this->localVelocity * time); |
---|
[8338] | 103 | } |
---|
| 104 | |
---|
[8341] | 105 | |
---|
[8338] | 106 | /** |
---|
| 107 | * @todo switch statement ?? |
---|
| 108 | */ |
---|
| 109 | void CollisionProbe::process(const Event &event) |
---|
| 110 | { |
---|
| 111 | |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|