-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcButton.cpp
More file actions
46 lines (40 loc) · 1.31 KB
/
cButton.cpp
File metadata and controls
46 lines (40 loc) · 1.31 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
/*
=================
- cButton.cpp
- Header file for class definition - IMPLEMENTATION
=================
*/
#include "cButton.h"
/*
=================================================================
Defualt Constructor
=================================================================
*/
cButton::cButton() : cSprite()
{
}
/*
=================================================================
Update the sprite position
=================================================================
*/
gameState cButton::update(gameState theCurrentGameState, gameState newGameState, SDL_Point theAreaClicked)
{
SDL_Point areaClicked = theAreaClicked;
if (areaClicked.x > this->getSpritePos().x && areaClicked.x < (this->getSpritePos().x + this->getSpriteDimensions().w) && areaClicked.y > this->getSpritePos().y && areaClicked.y < (this->getSpritePos().y + this->getSpriteDimensions().h))
{
this->buttonClickedRC.x = (int)(areaClicked.x - this->getSpritePos().x) / this->getSpriteDimensions().w;
this->buttonClickedRC.y = (int)(areaClicked.y - this->getSpritePos().y) / this->getSpriteDimensions().h;
this->clicked = true;
return newGameState;
}
return theCurrentGameState;
}
bool cButton::getClicked()
{
return this->clicked;
}
void cButton::setClicked(bool state)
{
this->clicked = state;
}