3 #include "ge211_audio.h" 4 #include "ge211_color.h" 5 #include "ge211_error.h" 6 #include "ge211_event.h" 7 #include "ge211_forward.h" 8 #include "ge211_geometry.h" 9 #include "ge211_random.h" 10 #include "ge211_resource.h" 11 #include "ge211_session.h" 12 #include "ge211_time.h" 137 (void) last_frame_seconds;
206 void quit() noexcept;
235 {
return prev_frame_length_; }
262 friend detail::Engine;
264 void mark_frame_() noexcept;
267 detail::Session session_;
268 std::unique_ptr<audio::
Mixer> mixer_ = audio::
Mixer::open_mixer();
269 detail::Engine* engine_ =
nullptr;
275 Timer fps_sample_start_;
276 int fps_sample_count_{0};
Mouse_button
A representation of a mouse button.
Represents a key on the keyboard.
virtual void on_mouse_up(Mouse_button, Position)
Called by the game engine each time a mouse button is released.
virtual void on_key_down(Key)
Called by the game engine each time a key is depressed.
This is the abstract base class for deriving games.
A class for timing intervals. The result is a Duration.
virtual void on_mouse_down(Mouse_button, Position)
Called by the game engine each time a mouse button 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.
virtual void on_start()
Called by the game engine after initializing the game but before commencing the event loop...
virtual void on_mouse_move(Position)
Called by the game engine each time the mouse moves.
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.
Duration get_prev_frame_length() const noexcept
Returns the duration of the frame right before the frame currently running.
static const Dimensions default_window_dimensions
The default window dimensions, in pixels.
Color background_color
Assign this member variable to change the window's background color in subsequent frames...
Provides access to the game window and its properties.
virtual void on_key(Key)
Called by the game engine for each keypress.
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.
A position in the T-valued Cartesian plane.
double get_frame_rate() const noexcept
Returns an approximation of the current frame rate in Hz.
Time_point get_frame_start_time() const noexcept
Gets the time point at which the current frame started.
virtual void on_quit()
Called by the game engine after exiting the event loop but before the game instance is destroyed...
virtual void on_frame(double last_frame_seconds)
Called by the game engine once per frame.
virtual Dimensions initial_window_dimensions() const
Override this function to specify the initial dimensions of the game's window.
Time_point start_time() const
Returns the actual time when this timer was started or most recently reset.
A collection of positioned sprites ready to be rendered to the screen.
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.
virtual void on_key_up(Key)
Called by the game engine each time a key is released.
void prepare(const sprites::Sprite &) const
Prepares a sprites::Sprite for rendering, without actually including it in the scene.
virtual void draw(Sprite_set &)=0
You must override this function in the derived class to specify how to draw your scene.