git repos / blockattack-game

commit a44568bd

sago007 · 2018-03-26 11:13
a44568bd9f40c9674396e65859e5a5eba4ad1a81 patch · browse files
parent 1a09fcd5bacde08518db81a0412c04ecb0314d3e

Added a frame counter for the menu

Changed files

M source/code/MenuSystem.cpp before
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index 494c2e4..dd4aa3c 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp
@@ -301,6 +301,22 @@ bool Menu::IsActive() {
void Menu::Draw(SDL_Renderer* target) {
placeButtons();
drawSelf(target);
+#if DEBUG
+ static unsigned long int Frames;
+ static unsigned long int Ticks;
+ static char FPS[10];
+ Frames++;
+ if (SDL_GetTicks() >= Ticks + 1000) {
+ if (Frames > 999) {
+ Frames=999;
+ }
+ snprintf(FPS, sizeof(FPS), "%lu fps", Frames);
+ Frames = 0;
+ Ticks = SDL_GetTicks();
+ }
+
+ globalData.standard_blue_font.draw(globalData.screen, 800, 4, FPS);
+#endif
}
void Menu::ProcessInput(const SDL_Event& event, bool& processed) {
if (isUpEvent(event)) {