Nox Engine
 
Loading...
Searching...
No Matches
Counters.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "Text.h"
9#include <SDL2/SDL_render.h>
10
14struct FPS : public Text {
15public:
16 using Text::Text;
17
18 int value;
19
24 FPS(std::string inStr);
25 ~FPS();
26
31 float calcAvg();
35 void update() override;
39 void reload() override;
40
41private:
42 float frameCounts[SAMPLE_COUNT];
43 int frameIndex;
44};
45
49struct Points : public Text {
50public:
51 using Text::Text;
52
53 int value;
54
59 Points(std::string inStr);
60 ~Points();
61
65 void update() override;
69 void reload() override;
70
71private:
72 int prevValue;
73};
const int SAMPLE_COUNT
Number of frames to average over for FPS calculation.
Definition Constants.h:39
Defines a component for rendering text.
A Text component that automatically calculates and displays the current FPS.
Definition Counters.h:14
void update() override
Updates the FPS calculation and the displayed text.
Definition Counters.cpp:20
int value
The current FPS value.
Definition Counters.h:18
void reload() override
Resets the frame counter history.
Definition Counters.cpp:29
float calcAvg()
Calculates the average FPS over a sample of frames.
Definition Counters.cpp:11
A Text component that displays a score or point value.
Definition Counters.h:49
int value
The numerical score value.
Definition Counters.h:53
void reload() override
Resets the points value to its initial state.
Definition Counters.cpp:50
void update() override
Updates the displayed text if the point value has changed.
Definition Counters.cpp:42
A component that renders a string of text on the screen.
Definition Text.h:16
Text(std::string inStr, int x, int y, float scale, SDL_Color color)
Constructs a fully customized Text component.
Definition Text.cpp:3