Skip to content

Commit 0880371

Browse files
author
Thumperrr
committed
AppStateGame inherits SFMLEvent.
Defined AppStateGame ctor. Example implementation of OnLButtonPressed
1 parent e9da36f commit 0880371

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/AppStateGame.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ namespace chesspp
99
display.draw(sf::Sprite(TextureManager::getInstance().Load("../res/img/chessboard_640x640.png")));
1010
}
1111

12-
12+
void AppStateGame::OnLButtonPressed(int x, int y)
13+
{
14+
#ifdef _DEBUG
15+
cout << "Left clicked at (" << x << ", " << y << ")\n";
16+
#endif // _DEBUG
17+
}
1318
}

src/AppStateGame.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,19 @@
1010

1111
namespace chesspp
1212
{
13+
class Application;
1314
class AppStateGame : public AppState
1415
{
15-
Application* app;
16+
Application* app;
1617

1718
public:
18-
AppStateGame(Application*);
19+
AppStateGame(Application* _app) : app(_app) {}
1920
virtual ~AppStateGame() {}
2021

2122
virtual int id();
2223
virtual void OnRender(sf::RenderWindow &display);
24+
25+
virtual void OnLButtonPressed(int x, int y); //example implementation
2326
};
2427
}
2528

0 commit comments

Comments
 (0)