forked from Illiux/Diabolical-Fuckup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform.cpp
73 lines (60 loc) · 1.27 KB
/
platform.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
#include "platform.h"
void Platform::draw() {
glTranslatef(x,y,-1.0);
if (texture->isValid()) {
glEnable( GL_TEXTURE_2D );
} else {
glDisable( GL_TEXTURE_2D );
}
texture->bind();
glBegin(GL_QUADS);
glColor4f(1.0,1.0,1.0,1.0);
glTexCoord2f( 0,0 );
glVertex3f(0,0,0);
glTexCoord2f( (float)width/texture->getWidth(),0 );
glVertex3f(width,0,0);
glTexCoord2f( (float)width/texture->getWidth(),(float)height/texture->getHeight() );
glVertex3f(width,height,0);
glTexCoord2f( 0,(float)height/texture->getHeight() );
glVertex3f(0,height,0);
glEnd();
// Reset original translate
glTranslatef(-x,-y,1.0);
}
float Platform::getX() {
return x;
}
float Platform::getY() {
return y;
}
void Platform::move(float x, float y)
{
this->x += x;
this->y += y;
}
void Platform::setPosition(float x, float y)
{
this->x = x;
this->y = y;
}
Platform::Platform(float x, float y, int width, int height, Texture* texture){
this->texture = texture;
this->x = x;
this->y = y;
this->width = width;
this->height = height;
}
Platform::Platform(float x, float y, int width, int height)
{
this->x = x;
this->y = y;
this->width = width;
this->height = height;
texture = new Texture();
}
float Platform::getWidth() {
return width;
}
float Platform::getHeight() {
return height;
}