| ge211
    2021.5.1
    A student game engine |  | 
 
 
 
    1 #include "ge211_base.hxx" 
    2 #include "ge211_engine.hxx" 
    3 #include "ge211_error.hxx" 
    9 using namespace detail;
 
   17 static int const frames_per_sample = 30;
 
   21     return default_window_dimensions;
 
   26     return default_window_title;
 
   41     if (engine_) 
return engine_->get_window();
 
   44                              "until engine is initialized"};
 
   50         engine_->prepare(sprite);
 
   53             << 
"Abstract_game::prepare: Could not prepare sprite " 
   54             << 
"because engine is not initialized";
 
   58 void Abstract_game::mark_present_() NOEXCEPT
 
   63 void Abstract_game::mark_frame_() NOEXCEPT
 
   66     prev_frame_length_ = frame_start_.reset();
 
   68     if (++sample_counter_ == frames_per_sample) {
 
   69         auto sample_duration = real_time_.reset().seconds();
 
   70         auto busy_duration   = busy_time_.reset().seconds();
 
   71         fps_            = frames_per_sample / sample_duration;
 
   72         load_           = 100 * busy_duration / sample_duration;
 
   77 void Abstract_game::poll_channels_()
 
   79     if (mixer_.is_forced())
 
   80         mixer_->poll_channels_();
 
   85     if (key.
code() == 
'\u001B') quit();
 
 
 
Log_message warn(std::string reason="")
Returns a warn-level log message.
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.
Provides access to the game window and its properties.
An exception that indicates that a logic error was performed by the client.
static const char *const default_window_title
The default initial window title.
static Key code(char32_t c)
Constructs a key with the given Unicode code point code.
static const Color default_background_color
The default background color of the window, if not changed by the derived class.
static constexpr Color black()
Solid black.
Window & get_window() const
Gets the Window that the game is running in.
void prepare(const sprites::Sprite &) const
Prepares a sprites::Sprite for rendering, without actually including it in the scene.
void quit()
Causes the event loop to quit after the current frame finishes.