Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/powerups/src/world_entities/power_ups/power_up.cc @ 6107

Last change on this file since 6107 was 6107, checked in by manuel, 18 years ago

implemented param_power_up.
started some powerup respawn possibilities
powerups don't display yet!

File size: 1.9 KB
Line 
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: Manuel Leuenberger
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18
19#include "power_up.h"
20#include "extendable.h"
21#include "primitive_model.h"
22
23using namespace std;
24
25Model* PowerUp::sphereModel = new PrimitiveModel(PRIM_SPHERE, 7, 5);
26
27PowerUp::PowerUp(float r, float g, float b)
28{
29  this->sphereMaterial = new Material;
30  this->sphereMaterial->setTransparency(.1);
31  this->sphereMaterial->setDiffuse(r, g, b);
32}
33
34PowerUp::~PowerUp ()
35{
36  delete this->sphereMaterial;
37}
38
39
40void PowerUp::loadParams(const TiXmlElement* root)
41{
42  static_cast<WorldEntity*>(this)->loadParams(root);
43}
44
45
46void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
47{
48 if(entity->isA(CL_EXTENDABLE))
49  {
50    if(dynamic_cast<Extendable*>(entity)->pickup(this))
51    {
52      this->setVisibiliy(false);
53    }
54  }
55}
56
57void PowerUp::draw() const
58{
59  WorldEntity::draw();
60
61  glMatrixMode(GL_MODELVIEW);
62  glPushMatrix();
63  float matrix[4][4];
64
65  /* translate */
66  glTranslatef (this->getAbsCoor ().x,
67                this->getAbsCoor ().y,
68                this->getAbsCoor ().z);
69  /* rotate */ // FIXME: devise a new Way to rotate this
70  this->getAbsDir ().matrix (matrix);
71  glMultMatrixf((float*)matrix);
72
73  this->sphereMaterial->select();
74  sphereModel->draw();
75
76  glPopMatrix();
77}
78
79const char* PowerUp::respawnTypes[] = {
80  "none",
81  "time"
82};
83
84void PowerUp::setRespawnType(const char* type)
85{
86  for(int i = 0; i < RESPAWN_size; ++i) {
87    if(strcmp(type, respawnTypes[i]) == 0) {
88      this->respawnType = (PowerUpRespawn)i;
89      break;
90    }
91  }
92}
93
Note: See TracBrowser for help on using the repository browser.