Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/power_ups/turret_power_up.cc @ 5435

Last change on this file since 5435 was 5435, checked in by bensch, 19 years ago

orxonox/trunk: power-ups implemented (simple-mode)

File size: 2.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: Benjamin Grauer
13   co-programmer: ...
14*/
15
16
17#include "turret_power_up.h"
18#include "factory.h"
19#include "state.h"
20#include "list.h"
21
22using namespace std;
23
24CREATE_FACTORY(TurretPowerUp);
25
26GLUquadricObj* TurretPowerUp_sphereObj = NULL;
27Material*      TurretPowerUp_sphereMat = NULL;
28
29
30TurretPowerUp::TurretPowerUp ()
31{
32  this->init();
33}
34
35TurretPowerUp::TurretPowerUp(const TiXmlElement* root)
36{
37  this->init();
38
39  this->loadParams(root);
40}
41
42
43TurretPowerUp::~TurretPowerUp () {
44
45}
46
47
48void TurretPowerUp::init()
49{
50  this->setClassID(CL_TURRET_POWER_UP, "TurretPowerUp");
51  this->loadModelWithScale("models/guns/turret1.obj", 2.0);
52
53  if (TurretPowerUp_sphereObj == NULL)
54    TurretPowerUp_sphereObj = gluNewQuadric();
55  if(TurretPowerUp_sphereMat == NULL)
56  {
57    TurretPowerUp_sphereMat = new Material("TurretPowerUp_Sphere");
58    TurretPowerUp_sphereMat->setTransparency(.1);
59  }
60  this->rotation = Vector(0,1,0);
61  this->cycle    = 0;
62}
63
64
65void TurretPowerUp::loadParams(const TiXmlElement* root)
66{
67  static_cast<PowerUp*>(this)->loadParams(root);
68
69}
70
71
72/**
73 * this function is called, when two entities collide
74 * @param entity: the world entity with whom it collides
75 *
76 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
77 */
78void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location)
79{
80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
81 if (entity->isA(CL_PLAYER))
82  State::getWorldEntityList()->remove(this);
83}
84
85/**
86 *  this method is called every frame
87 * @param time: the time in seconds that has passed since the last tick
88 *
89 * Handle all stuff that should update with time inside this method (movement, animation, etc.)
90*/
91void TurretPowerUp::tick(float dt)
92{
93  this->shiftDir(Quaternion(dt, this->rotation));
94  this->cycle+=dt;
95
96}
97
98/**
99 *  the entity is drawn onto the screen with this function
100 *
101 * This is a central function of an entity: call it to let the entity painted to the screen.
102 * Just override this function with whatever you want to be drawn.
103*/
104void TurretPowerUp::draw()
105{  glMatrixMode(GL_MODELVIEW);
106  glPushMatrix();
107  /* translate */
108  glTranslatef (this->getAbsCoor ().x,
109                this->getAbsCoor ().y + cos(this->cycle*3.0)*2.0,
110                this->getAbsCoor ().z);
111  /* rotate */
112  Vector tmpRot = this->getAbsDir().getSpacialAxis();
113  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
114  TurretPowerUp_sphereMat->select();
115//  gluSphere(TurretPowerUp_sphereObj, 3, 5, 5);
116  this->model->draw();
117  glPopMatrix();
118
119}
120
Note: See TracBrowser for help on using the repository browser.