added segment constructors for 2 boxes and 2 sprites
This commit is contained in:
parent
c6341d2bfc
commit
7d00cda9bb
|
@ -1,10 +1,15 @@
|
|||
#include "glm/geometric.hpp"
|
||||
#include "extension.hpp"
|
||||
#include "Box.hpp"
|
||||
#include "Segment.hpp"
|
||||
|
||||
Segment::Segment(const glm::vec2& start, const glm::vec2& end) : start(start), end(end) {};
|
||||
|
||||
Segment::Segment() : Segment({0, 0}, {0, 0}) {};
|
||||
|
||||
Segment::Segment(const glm::vec2& location) : Segment(location, location) {};
|
||||
|
||||
Segment::Segment(const glm::vec2& start, const glm::vec2& end) : start(start), end(end) {};
|
||||
Segment::Segment(const Box& start, const Box& end) : Segment(start.get_center(), end.get_center()) {};
|
||||
|
||||
glm::vec2 Segment::get_start() const
|
||||
{
|
||||
|
|
|
@ -6,18 +6,20 @@
|
|||
#include <cmath>
|
||||
|
||||
#include "glm/vec2.hpp"
|
||||
#include "glm/geometric.hpp"
|
||||
|
||||
struct Box;
|
||||
struct Sprite;
|
||||
|
||||
struct Segment
|
||||
{
|
||||
|
||||
glm::vec2 start, end;
|
||||
|
||||
Segment(const glm::vec2&, const glm::vec2&);
|
||||
Segment();
|
||||
Segment(const glm::vec2&);
|
||||
Segment(const glm::vec2&, const glm::vec2&);
|
||||
Segment(const Box&, const Box&);
|
||||
Segment(const Sprite&, const Sprite&);
|
||||
glm::vec2 get_start() const;
|
||||
void set_start(const glm::vec2&);
|
||||
glm::vec2 get_end() const;
|
||||
|
@ -58,7 +60,4 @@ struct Segment
|
|||
|
||||
std::ostream& operator<<(std::ostream&, const Segment&);
|
||||
|
||||
#include "extension.hpp"
|
||||
#include "Box.hpp"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -393,7 +393,7 @@ glm::vec2 Sprite::get_west(int index)
|
|||
return get_box(index).get_west();
|
||||
}
|
||||
|
||||
glm::vec2 Sprite::get_center(int index)
|
||||
glm::vec2 Sprite::get_center(int index) const
|
||||
{
|
||||
return get_box(index).get_center();
|
||||
}
|
||||
|
@ -1043,3 +1043,5 @@ void Frameset::reverse()
|
|||
|
||||
Pixels::Pixels(Sprite& sprite) : Pixels(sprite.get_renderer(), sprite.get_current_frame()) {}
|
||||
Pixels::Pixels(Sprite& sprite, const SDL_Rect& rect) : Pixels(sprite.get_renderer(), sprite.get_current_frame(), rect) {}
|
||||
|
||||
Segment::Segment(const Sprite& start, const Sprite& end) : Segment(start.get_center(), end.get_center()) {}
|
||||
|
|
|
@ -99,7 +99,7 @@ struct Sprite : Node
|
|||
glm::vec2 get_south(int = 0);
|
||||
glm::vec2 get_sw(int = 0);
|
||||
glm::vec2 get_west(int = 0);
|
||||
glm::vec2 get_center(int = 0);
|
||||
glm::vec2 get_center(int = 0) const;
|
||||
void set_top(float);
|
||||
void set_right(float);
|
||||
void set_bottom(float);
|
||||
|
|
|
@ -19,6 +19,9 @@ void Timer::toggle(bool state)
|
|||
void Timer::reset()
|
||||
{
|
||||
elapsed = 0;
|
||||
ticks = SDL_GetTicks();
|
||||
ticks_previous = ticks;
|
||||
frame_duration = 0;
|
||||
}
|
||||
|
||||
float Timer::get_seconds_elapsed()
|
||||
|
|
Loading…
Reference in New Issue