1 #include "ge211_base.h" 2 #include "ge211_engine.h" 3 #include "ge211_error.h" 9 using namespace detail;
17 static int const frames_per_sample = 60;
21 return default_window_dimensions;
26 return default_window_title;
41 if (engine_)
return engine_->get_window();
44 "until engine is initialized"};
60 engine_->prepare(sprite);
62 warn() <<
"Abstract_game::prepare: Could not prepare sprite " 63 <<
"because engine is not initialized";
67 void Abstract_game::mark_frame_() noexcept
69 prev_frame_length_ = frame_start_.reset();
71 if (! (fps_sample_count_ = (fps_sample_count_ + 1) % frames_per_sample))
72 fps_ = frames_per_sample / fps_sample_start_.reset().seconds();
77 if (key.
code() ==
'\u001B') quit();
Represents a key on the keyboard.
virtual void on_key_down(Key)
Called by the game engine each time a key is depressed.
virtual std::string initial_window_title() const
Override this function to specify the initial title of the game.
The game engine namespace.
static const char *const default_window_title
The default initial window title.
A pseudo-random number generator.
Random & get_random() const noexcept
Gets the pseudo-random number generator associated with this game.
Mixer * get_mixer() const noexcept
Gets the audio mixer, which can be used to play music.
static const Dimensions default_window_dimensions
The default window dimensions, in pixels.
Provides access to the game window and its properties.
A sprite is an image that knows how to render itself to the screen at a given location, under a particular transformation.
The entity that coordinates playing all audio tracks.
Represents the dimensions of an object, or more generally, the displacement between two Basic_positio...
Window & get_window() const
Gets the Window that the game is running in.
static Key code(char32_t c)
Constructs a key with the given Unicode code point code.
static constexpr Color black() noexcept
Solid black.
An exception that indicates that a logic error was performed by the client.
virtual Dimensions initial_window_dimensions() const
Override this function to specify the initial dimensions of the game's window.
Basic_dimensions< int > Dimensions
Type alias for the most common use of Basic_dimensions, which is with a coordinate type of int...
static const Color default_background_color
The default background color of the window, if not changed by the derived class.
void quit() noexcept
Causes the event loop to quit after the current frame finishes.
void prepare(const sprites::Sprite &) const
Prepares a sprites::Sprite for rendering, without actually including it in the scene.