ge211
2021.5.1
A student game engine
|
|
3 #include "ge211_audio.hxx"
4 #include "ge211_color.hxx"
5 #include "ge211_error.hxx"
6 #include "ge211_event.hxx"
7 #include "ge211_forward.hxx"
8 #include "ge211_geometry.hxx"
9 #include "ge211_noexcept.hxx"
10 #include "ge211_random.hxx"
11 #include "ge211_resource.hxx"
12 #include "ge211_session.hxx"
13 #include "ge211_time.hxx"
176 (void) last_frame_seconds;
243 void quit() NOEXCEPT;
268 {
return prev_frame_length_; }
299 friend class detail::Engine;
301 void mark_present_() NOEXCEPT;
302 void mark_frame_() NOEXCEPT;
304 void poll_channels_();
306 detail::Session session_;
307 detail::lazy_ptr<
Mixer> mixer_;
308 detail::Engine* engine_ =
nullptr;
318 int sample_counter_ {0};
320 Pausable_timer busy_time_;
double get_frame_rate() const
Returns an approximation of the current frame rate in Hz.
A collection of positioned Sprites ready to be rendered to the screen.
Mouse_button
A representation of a mouse button.
virtual void draw(Sprite_set &)=0
You must override this function in the derived class to specify how to draw your scene.
virtual ~Abstract_game()
Polymorphic classes should have virtual destructors.
virtual void on_mouse_move(Posn< int >)
Called by the game engine each time the mouse moves.
virtual void on_key_down(Key)
Called by the game engine each time a key is depressed.
static const Dims< int > default_window_dimensions
The default window dimensions, in pixels.
virtual std::string initial_window_title() const
Override this function to specify the initial title of the game.
Represents a key on the keyboard.
The game engine namespace.
A sprite is an image that knows how to render itself to the screen at a given location,...
virtual Dims< int > initial_window_dimensions() const
Override this function to specify the initial dimensions of the game's window.
double get_load_percent() const
Returns an approximation of the current machine load due to GE211.
Provides access to the game window and its properties.
Color background_color
Assign this member variable to change the window's background color in subsequent frames.
virtual void on_mouse_up(Mouse_button, Posn< int >)
Called by the game engine each time a mouse button is released.
virtual void on_key(Key)
Called by the game engine for each keypress.
A class for timing intervals. The result is a Duration.
Mixer & mixer() const
Gets access to the audio mixer, which can be used to play music and sound effects.
static const char *const default_window_title
The default initial window title.
virtual void on_mouse_down(Mouse_button, Posn< int >)
Called by the game engine each time a mouse button is depressed.
Time_point get_frame_start_time() const
Gets the time point at which the current frame started.
static const Color default_background_color
The default background color of the window, if not changed by the derived class.
virtual void on_start()
Called by the game engine after initializing the game but before commencing the event loop.
Window & get_window() const
Gets the Window that the game is running in.
The entity that coordinates playing all audio tracks.
void prepare(const sprites::Sprite &) const
Prepares a sprites::Sprite for rendering, without actually including it in the scene.
virtual void on_quit()
Called by the game engine after exiting the event loop but before the game instance is destroyed.
Time_point start_time() const
Returns the actual time when this timer was started or most recently reset.
virtual void on_key_up(Key)
Called by the game engine each time a key is released.
Duration get_prev_frame_length() const
Returns the duration of the frame right before the frame currently running.
void quit()
Causes the event loop to quit after the current frame finishes.
This is the abstract base class for deriving games.
virtual void on_frame(double last_frame_seconds)
Called by the game engine once per frame.