-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcTower.cpp
64 lines (52 loc) · 1.14 KB
/
cTower.cpp
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
#include "cTower.h"
cTower::cTower()
{
x = GAME_WIDTH / 2;
y = GAME_HEIGHT / 2;
}
cTower::~cTower()
{
}
void cTower::Init()
{
}
void cTower::Update(float tpf)
{
}
void cTower::Render()
{
glLoadIdentity();
//rotate ub arbitrary point (titik yang bukan titik 0)
glTranslated(x, y, 3);
glRotated(angle, 0, 0, 1);
glTranslated(-x, -y, 3);
glColor3f(.5f, .5f, .5f); //.5f = 0.5f
glBegin(GL_QUADS);
glVertex3f(x - 10, y - 5, 3); // kiri bawah
glVertex3f(x + 10, y - 5, 3); // kanan bawah
glVertex3f(x + 10, y + 5, 3); // kanan atas
glVertex3f(x - 10, y + 5, 3); // kiri atas
glEnd();
}
void cTower::ReadKeyboard(unsigned char key, int x, int y, bool press)
{
}
void cTower::ReadSpecialKeyboard(unsigned char key, int x, int y, bool press)
{
}
void cTower::ReadMouse(int button, int state, int x, int y)
{
}
void cTower::ReadPassiveMotion(int x, int y)
{
y = GAME_HEIGHT - y;
float dx = x - this->x;
float dy = y - this->y;
try {
float tan = dy / dx;
angle = atan(tan); //return radian
//redian to degree
angle = angle * 180.0f / (22.0f / 7.0f);
}
catch (int e) {};
}