-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.cpp
More file actions
40 lines (35 loc) · 824 Bytes
/
Bullet.cpp
File metadata and controls
40 lines (35 loc) · 824 Bytes
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
#include "Bullet.h"
#include "Dir.h"
#include <iostream>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
Bullet::Bullet(): GameObject(), Rectangle(), speed(0.0f), dir(LEFT) { }
Bullet::Bullet(float _x, float _y, Direction _dir) : GameObject(_x,_y), Rectangle(_x, _y, 0.8f, 0.8f), Point(_x, _y), speed(1.0f), dir(_dir)
{
}
void Bullet::Tick()
{
switch(dir)
{
case LEFT:
x-=speed;
break;
case RIGHT:
x+=speed;
break;
case UP:
y+=speed;
break;
case DOWN:
y-=speed;
break;
}
}
void Bullet::Render()
{
glColor3ub( 6, 0, 176);
glRectf(x*SCALE, y*SCALE, (x+width)*SCALE, (y+height)*SCALE);
}
void Bullet::Keyboard(int i){}
void Bullet::SpecialKeyboard(int i){}