3 #include "ge211_color.h" 4 #include "ge211_forward.h" 5 #include "ge211_geometry.h" 6 #include "ge211_time.h" 7 #include "ge211_render.h" 8 #include "ge211_resource.h" 48 friend detail::Engine;
49 friend detail::Placed_sprite;
52 virtual void render(detail::Renderer&,
56 virtual void prepare(detail::Renderer
const&)
const {}
71 class Texture_sprite :
public Sprite 78 void prepare(detail::Renderer
const&)
const override;
80 virtual Texture
const& get_texture_()
const = 0;
91 class Render_sprite :
public Texture_sprite
96 explicit Render_sprite(Dimensions);
100 void fill_surface(Color);
104 void fill_rectangle(Rectangle, Color);
108 void set_pixel(Position, Color);
112 Texture
const& get_texture_()
const override;
116 SDL_Surface* as_surface();
118 static delete_ptr<SDL_Surface> create_surface_(Dimensions);
126 class Rectangle_sprite :
public detail::Render_sprite
171 detail::Texture
const& get_texture_()
const override;
173 static detail::Texture load_texture_(std::string
const& filename);
175 detail::Texture texture_;
202 operator bool()
const;
213 void assert_initialized_()
const;
215 detail::Texture
const& get_texture_()
const override;
217 static detail::Texture create_texture(Builder
const&);
219 detail::Texture texture_;
235 class Text_sprite::Builder
319 std::ostringstream message_;
340 void render(detail::Renderer& renderer,
Position position,
341 Transform const& transform)
const override;
352 const Sprite* sprite;
357 Placed_sprite(Sprite
const&, Position,
int, Transform
const&) noexcept;
359 void render(Renderer&)
const;
362 bool operator<(Placed_sprite
const&, Placed_sprite
const&) noexcept;
389 Sprite_set&
add_sprite(Sprite
const&, Position,
int z = 0);
395 Sprite_set&
add_sprite(Sprite
const&, Position,
int z, Transform
const&);
398 friend detail::Engine;
401 std::vector<detail::Placed_sprite> sprites_;
int word_wrap() const
Gets the wrapping width that will be used.
A Sprite that displays a bitmap image.
Builder(Font const &)
Constructs a new Text_sprite::Builder with the given Font.
void recolor(Color)
Changes the color of this circle sprite.
Text_sprite build() const
Builds the configured Text_sprite.
A class for timing intervals. The result is a Duration.
void reset()
Resets the age of the sprite to 0.
bool antialias() const
Gets whether anti-aliasing will be used.
The game engine namespace.
Circle_sprite(int radius, Color=Color::white())
Constructs a circle sprite from its radius and optionally a Color, which defaults to white...
Builder & operator<<(T const &value)
Adds to the builder's message.
Font const & font() const
Gets the font that will be used.
Represents a font that can be used to render a sprites::Text_sprite.
virtual Dimensions dimensions() const =0
Returns the current dimensions of this Sprite.
Image_sprite(std::string const &filename)
Constructs an image sprite, given the filename of the image to display.
Sprite_set & add_sprite(Sprite const &, Position, int z=0)
Adds the given sprite at the given x–y geometry::Position and optional z coordinate, which defaults to 0.
Color color() const
Gets the color that will be used.
Builder & add_message(T const &value)
Adds to the builder's message.
A Sprite that allows switching between other sprites based on the time at rendering.
A sprite is an image that knows how to render itself to the screen at a given location, under a particular transformation.
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 circle.
Represents the dimensions of an object, or more generally, the displacement between two Basic_positio...
A position in the T-valued Cartesian plane.
std::string message() const
Gets the configured message.
A Sprite that displays text.
bool empty() const
Is this Text_sprite empty? (If so, you shouldn't try to use it.)
static constexpr Color white() noexcept
Solid white.
void reconfigure(Builder const &)
Resets this text sprite with the configuration from the given Builder.
Text_sprite()
Constructs an empty text sprite.
void recolor(Color)
Changes the color of this rectangle sprite.
Rectangle_sprite(Dimensions, Color=Color::white())
Constructs a rectangle sprite from required Dimensions and an optional Color, which defaults to white...
Builder-style API for configuring and constructing Text_sprites.