-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaser.cpp
More file actions
64 lines (57 loc) · 1.22 KB
/
Laser.cpp
File metadata and controls
64 lines (57 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using namespace std;
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h>
#include "Mob.h"
#include "Bullet.h"
GLUquadricObj *quadratic;
Bullet::Bullet() {}
Bullet::~Bullet() { gluDeleteQuadric(quadratic); }
bool Bullet::init()
{
/*glPushMatrix();
glLoadIdentity();
glGetFloatv(GL_MODELVIEW_MATRIX, transforms);
glPopMatrix();*/
quadratic=gluNewQuadric();
gluQuadricNormals(quadratic, GLU_SMOOTH);
//gluQuadricTexture(quadratic, GL_TRUE);
loadMatrix();
glLoadIdentity();
saveMatrix();
velocity.z = -10.0;//20.0*((float) random() / RAND_MAX)-1.0;
return true;
}
void Bullet::draw()
{
glPushMatrix();
//loadMatrix();
glTranslatef(pos.x(), pos.y(), pos.z());
gluSphere(quadratic,0.2f,16,16);
glPopMatrix();
}
void Bullet::update(float dt)
{
loadMatrix();
translate(0.0, 0.0, dt*velocity.z);
saveMatrix();
}
/*void Bullet::rotate(GLfloat angle, GLfloat dx, GLfloat dy, GLfloat dz)
{
loadMatrix();
glRotatef(angle, dx, dy, dz);
saveMatrix();
}*/
/*void Bullet::translate(GLfloat dp, GLfloat daz, GLfloat dh)
{
loadMatrix();
glTranslatef(dx, dy, dz);
saveMatrix();
}*/
/*
void Cube::scale(GLfloat sx, GLfloat sy, GLfloat sz)
{
loadMatrix();
glScalef(sx, sy, sz);
saveMatrix();
}*/