-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcPelor.cpp
86 lines (72 loc) · 1.85 KB
/
cPelor.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "cPelor.h"
#include "cGame.h"
#include "cPlayer.h"
cPelor::cPelor()
{
}
cPelor::~cPelor()
{
}
void cPelor::Render()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, bulletSheet->at(animControl->Index())->Texture());
glBegin(GL_QUADS);
glTexCoord2f(bulletSheet->at(animControl->Index())->X0(), bulletSheet->at(animControl->Index())->Y1()); glVertex3i(x, y, 50);
glTexCoord2f(bulletSheet->at(animControl->Index())->X1(), bulletSheet->at(animControl->Index())->Y1()); glVertex3i(x + Width(), y, 50);
glTexCoord2f(bulletSheet->at(animControl->Index())->X1(), bulletSheet->at(animControl->Index())->Y0()); glVertex3i(x + Width(), y + Height(), 50);
glTexCoord2f(bulletSheet->at(animControl->Index())->X0(), bulletSheet->at(animControl->Index())->Y0()); glVertex3i(x, y + Height(), 50);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void cPelor::Init()
{
animControl = new cAnimControl();
animControl->AddAnim("NoLoop", "bullet_forward", 0, 0, 0.2f);
}
void cPelor::Update(float tpf)
{
animControl->UpdateAnim(tpf);
if (keys[32]) {
if (
animControl->ActiveName() != "bullet_forward")
animControl->SetActiveAnim("bullet_forward");
}
if (y < GAME_HEIGHT && y>0) {
y += 15 * unitpersec;
}
//TODO: sepertinya ngebug disini , pelurunya tetep maju biarpun tembus viewport , kalo didiemin lama dia abort() langsung crash
}
void cPelor::ReadKeyboard(unsigned char key, int x, int y, bool press)
{
if (press)
{
keys[key] = true;
}
else
{
keys[key] = false;
}
}
void cPelor::ReadSpecialKeyboard(unsigned char key, int x, int y, bool press)
{
if (press)
{
keys[key] = true;
}
else
{
keys[key] = false;
}
}
void cPelor::ReadMouse(int button, int state, int x, int y)
{
}
void cPelor::sety(int y)
{
this->y = y;
}
void cPelor::setx(int x)
{
this->x = x;
}