ge211
2021.5.1
A student game engine
|
|
3 #include "ge211_color.hxx"
4 #include "ge211_forward.hxx"
5 #include "ge211_geometry.hxx"
6 #include "ge211_noexcept.hxx"
7 #include "ge211_time.hxx"
8 #include "ge211_render.hxx"
9 #include "ge211_resource.hxx"
53 friend class detail::Engine;
54 friend struct detail::Placed_sprite;
57 virtual void render(detail::Renderer&,
61 virtual void prepare(detail::Renderer
const&)
const {}
76 class Texture_sprite :
public Sprite
82 void render(detail::Renderer&, Posn<int>, Transform
const&)
const override;
83 void prepare(detail::Renderer
const&)
const override;
85 virtual Texture
const& get_texture_()
const = 0;
161 detail::Texture texture_;
163 detail::Texture
const& get_texture_()
const override;
169 static detail::Uniq_SDL_Surface
223 detail::Texture
const& get_texture_()
const override;
225 static detail::Texture load_texture_(
std::string const& filename);
227 detail::Texture texture_;
305 explicit operator bool()
const;
316 void assert_initialized_()
const;
318 detail::Texture
const& get_texture_()
const override;
320 static detail::Texture create_texture(
Builder const&);
322 detail::Texture texture_;
382 template <
typename PRINTABLE>
402 template <
typename PRINTABLE>
467 void render(detail::Renderer& renderer,
Posn<int> position,
468 Transform const& transform)
const override;
486 void render(Renderer&)
const;
489 bool operator<(Placed_sprite
const&, Placed_sprite
const&) NOEXCEPT;
548 friend class detail::Engine;
bool can_paint() const
Returns whether we can paint to this Render_sprite.
Image_sprite(std::string const &filename)
Constructs an image sprite, given the filename of the image to display.
A collection of positioned Sprites ready to be rendered to the screen.
void recolor(Color)
Changes the color of this circle sprite.
A Sprite that renders as a solid circle.
bool antialias() const
Gets whether anti-aliasing will be used.
void fill_surface(Color)
Fills the whole surface with the given color.
Circle_sprite(int radius, Color=Color::white())
Constructs a circle sprite from its radius and optionally a Color, which defaults to white.
void fill_rectangle(Rect< int >, Color)
Fills the given rectangle in the given color.
Render_sprite(Dims< int >)
Constructs a Render_sprite with the given pixel dimensions.
int word_wrap() const
Gets the wrapping width that will be used.
Borrowed< SDL_Surface > raw_surface()
Gains access to the underlying SDL_Surface☛.
static constexpr Color white()
Solid white.
The game engine namespace.
bool empty() const
Is this Text_sprite empty? (If so, you shouldn't try to use it.)
void reset()
Resets the age of the sprite to 0.
Rectangle_sprite(Dims< int >, Color=Color::white())
Constructs a rectangle sprite from required Dims and an optional Color, which defaults to white.
Font const & font() const
Gets the font that will be used.
A sprite is an image that knows how to render itself to the screen at a given location,...
Text_sprite()
Constructs an empty text sprite.
void recolor(Color)
Changes the color of this rectangle sprite.
Text_sprite build() const
Builds the configured Text_sprite.
virtual Dims< int > dimensions() const =0
Returns the current dimensions of this Sprite.
A class for timing intervals. The result is a Duration.
virtual const Sprite & select_(Duration age) const =0
Override this to specify what sprite to render, based on the age of this sprite.
A Sprite that renders as a solid rectangle.
A Sprite that displays text.
A Sprite that allows switching between other sprites based on the time at rendering.
Builder(Font const &)
Constructs a new Text_sprite::Builder with the given Font.
A Render_sprite works by allowing its derived classes to render themselves pixel-by-pixel onto an SDL...
void set_pixel(Posn< int >, Color)
Sets one pixel to the given color.
Represents a font that can be used to render a sprites::Text_sprite.
void reconfigure(Builder const &)
Resets this text sprite with the configuration from the given Builder.
Represents a positioned rectangle.
Sprite_set & add_sprite(Sprite const &sprite, Posn< int > xy, int z=0, Transform const &transform=Transform())
Adds the given sprite to the sprite set to render it in the next frame.
Builder & add_message(PRINTABLE const &value)
Adds to the builder's message.
Color color() const
Gets the color that will be used.
Builder & operator<<(PRINTABLE const &value)
Adds to the builder's message.
std::string message() const
Gets the configured message.
A Sprite that displays a bitmap image.
Builder-style API for configuring and constructing Text_sprites.
OBJECT_TYPE * Borrowed
Type alias to indicate that the given pointer does not own its object.