Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/world_entities/projectile.cc @ 3633

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

orxonox/trunk: i have discovered the problem: since the player has no constant speed (trackmanager), there are times, when the bullets are faster than the player, and vice versa. i have no incremented the speed of the bullets but its still sometimes too slow… this is a major problem.

File size: 2.2 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:
16*/
17
18
19#include "projectile.h"
20
21#include "world_entity.h"
22#include "objModel.h"
23#include "primitive.h"
24#include "vector.h"
25
26using namespace std;
27
28
29/**
30   \brief standard constructor
31*/
32Projectile::Projectile () : WorldEntity()
33{
34  //this->model = new OBJModel("");
35  this->projectileModel = new Primitive(P_SPHERE);
36  this->flightDirection = NULL;
37  this->speed = 1.1f;
38}
39
40
41/**
42   \brief standard deconstructor
43*/
44Projectile::~Projectile () 
45{
46  /*
47     do not delete the test projectModel, since it is pnode
48     and will be cleaned out by world
49  */
50  //delete this->projectileModel;
51}
52
53
54/**
55   \brief this sets the flight direction of the projectile
56   \param directin in which to flight
57
58   this function will calculate a vector out of this to be used in the
59   tick function
60*/
61void Projectile::setFlightDirection(Quaternion* flightDirection)
62{
63  if( this->flightDirection == NULL)
64    this->flightDirection = new Vector();
65  Vector v(1, 0, 0);
66  *this->flightDirection = flightDirection->apply(v);
67}
68
69
70/**
71   \brief signal tick, time dependent things will be handled here
72   \param time since last tick
73*/
74void Projectile::tick (float time) 
75{
76  *this->flightDirection = *this->flightDirection * speed;
77  this->shiftCoor(this->flightDirection);
78}
79
80/**
81   \brief the projectile gets hit by another entity
82   \param the other entity
83   \param place where it is hit
84*/
85void Projectile::hit (WorldEntity* entity, Vector* place) 
86{}
87
88
89/**
90   \brief the function gets called, when the projectile is destroyed
91*/
92void Projectile::destroy () 
93{}
94
95
96void Projectile::draw () 
97{
98  glMatrixMode(GL_MODELVIEW);
99  glPushMatrix();
100
101  float matrix[4][4]; 
102  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
103  this->getAbsDir().matrix (matrix);
104  glMultMatrixf((float*)matrix); 
105  //this->model->draw();
106  this->projectileModel->draw();
107
108  glPopMatrix();
109}
110
Note: See TracBrowser for help on using the repository browser.