-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathButtonFieldFire.cpp
More file actions
68 lines (56 loc) · 2 KB
/
ButtonFieldFire.cpp
File metadata and controls
68 lines (56 loc) · 2 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
65
66
67
68
#include "ButtonFieldFire.h"
#include "TextureManager.h"
#include "resource.h"
extern TextureManager textureManager;
/// <summary>
/// The default constructor for the ButtonFieldFire class.
/// </summary>
/// <param name="StartX: ">The X position of the ButtonField.</param>
/// <param name="StartY: ">The Y position of the ButtonField.</param>
ButtonFieldFire::ButtonFieldFire(int StartX, int StartY)
{
this->StartX = StartX;
this->StartY = StartY;
this->Cells[0][0].ButtonID = BF_MOVE_LEFT;
this->Cells[0][1].ButtonID = BF_MOVE_LEFT;
this->Cells[0][2].ButtonID = BF_MOVE_UP;
this->Cells[1][0].ButtonID = BF_MOVE_DOWN;
this->Cells[1][1].ButtonID = BF_RANDOMAIM;
this->Cells[1][2].ButtonID = BF_MOVE_UP;
this->Cells[2][0].ButtonID = BF_MOVE_DOWN;
this->Cells[2][1].ButtonID = BF_MOVE_RIGHT;
this->Cells[2][2].ButtonID = BF_MOVE_RIGHT;
this->Cells[3][0].ButtonID = BF_FIRE;
this->Cells[3][1].ButtonID = BF_FIRE;
this->Cells[3][2].ButtonID = BF_FIRE;
}
/// <summary>
/// Changes OpenGL coordinates to ButtonField coordinates.
/// </summary>
/// <param name="coordinates: ">The coordinates of the click to be converted.</param>
/// <returns>Wether or not the user has clicked on the ButtonField.</returns>
bool ButtonFieldFire::Click(POINT& coordinates)
{
if (coordinates.x >= this->StartX && coordinates.y >= this->StartY && coordinates.x < ButtonFieldW + this->StartX && coordinates.y < ButtonFieldH + this->StartY)
{
coordinates.x -= this->StartX;
coordinates.y -= this->StartY;
return true;
}
return false;
}
/// <summary>
/// Draws the ButtonField.
/// </summary>
void ButtonFieldFire::Draw()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureManager.ButtonFieldFireTextureID);
glBegin(GL_QUADS);
glTexCoord2d(0, 0); glVertex2f(this->StartX, this->StartY);
glTexCoord2d(1, 0); glVertex2f(this->StartX + 4, this->StartY);
glTexCoord2d(1, 1); glVertex2f(this->StartX + 4, this->StartY + 3);
glTexCoord2d(0, 1); glVertex2f(this->StartX, this->StartY + 3);
glEnd();
glDisable(GL_TEXTURE_2D);
}