diff --git a/crumpet-engine/entity.cpp b/crumpet-engine/entity.cpp index cecec19..dfa882c 100644 --- a/crumpet-engine/entity.cpp +++ b/crumpet-engine/entity.cpp @@ -49,6 +49,14 @@ void Entity::SetRect(Vec2 pos, Vec2 size) { m_rect = { pos.x, pos.y, size.x, size.y }; } +void Entity::SetVecPoints(std::vector points) { + this->m_linePoints = points; +} + +void Entity::AddVecPoint(Vec4 point) { + this->m_linePoints.push_back(point); +} + void Entity::Render() { if (Rendertype == RenderType::MODE_TEXTURE) SDL_RenderCopy(m_SDLRenderer, m_texture, NULL, NULL); @@ -58,6 +66,12 @@ void Entity::Render() { SDL_RenderFillRect(m_SDLRenderer, &m_rect); if (Drawtype == PolyDrawType::DRAW_OUTLINE_RECT) SDL_RenderDrawRect(m_SDLRenderer, &m_rect); + + if (Drawtype == PolyDrawType::DRAW_LINES) { + for (unsigned int i = 0; i < m_linePoints.size(); i++) { + SDL_RenderDrawLine(m_SDLRenderer, m_linePoints[i].x, m_linePoints[i].y, m_linePoints[i].z, m_linePoints[i].w); + } + } } } diff --git a/crumpet-engine/entity.h b/crumpet-engine/entity.h index 793fe99..ca36082 100644 --- a/crumpet-engine/entity.h +++ b/crumpet-engine/entity.h @@ -34,8 +34,8 @@ public: void SetRect(Vec2 pos, Vec2 size); - void SetVecPoints(std::vector linePoints); - void AddVecPoint(Vec2 point); + void SetVecPoints(std::vector points); + void AddVecPoint(Vec4 point); void Render(); @@ -49,7 +49,7 @@ private: Vec4 m_col; - std::vector m_linePoints; + std::vector m_linePoints; SDL_Texture* m_texture; // std::string PATH = "C:/Users/Ben/Desktop/crumpet-engine"; diff --git a/crumpet-engine/main.cpp b/crumpet-engine/main.cpp index adccccc..7748baa 100644 --- a/crumpet-engine/main.cpp +++ b/crumpet-engine/main.cpp @@ -19,6 +19,10 @@ int main(int argc, char** argv) { outlineBox.SetDrawColour(Vec4(0x00, 0xFF, 0x00, 0xFF)); outlineBox.SetRect(Vec2(SCREEN_WIDTH / 6, SCREEN_HEIGHT / 6), Vec2(SCREEN_WIDTH * 2 / 3, SCREEN_HEIGHT * 2 / 3)); + Entity lineMesh("line mesh", game.SDLRenderer, PolyDrawType::DRAW_LINES); + lineMesh.SetDrawColour(Vec4(0x00, 0x00, 0xFF, 0xFF)); + lineMesh.AddVecPoint(Vec4(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + while (!game.IsDisplayClosed()) { game.PollEvents(); @@ -28,6 +32,7 @@ int main(int argc, char** argv) { game.RenderEntity(&box); game.RenderEntity(&outlineBox); + game.RenderEntity(&lineMesh); game.RenderUpdate(); } diff --git a/crumpet-engine/mathHelper.h b/crumpet-engine/mathHelper.h index 3089ace..e0de74f 100644 --- a/crumpet-engine/mathHelper.h +++ b/crumpet-engine/mathHelper.h @@ -59,36 +59,3 @@ struct Vec2f { float x, y; }; - - -/* struct Vec2SInt16 { - Vec2SInt16(Sint16 x, Sint16 y) { - this->x = x; - this->y = y; - } - - Sint16 x; - Sint16 y; -}; - -struct Vec2UInt16 { - Vec2UInt16(Uint16 x, Uint16 y) { - this->x = x; - this->y = y; - } - - Uint16 x; - Uint16 y; -}; - -struct RectVect { - RectVect(Vec2SInt16 pos, Vec2UInt16 size) - : pos(1, 1), - size(1, 1) { - this->pos = pos; - this->size = size; - } - - Vec2SInt16 pos; - Vec2UInt16 size; -}; */ diff --git a/crumpet-engine/sprite.cpp b/crumpet-engine/sprite.cpp new file mode 100644 index 0000000..6adbce5 --- /dev/null +++ b/crumpet-engine/sprite.cpp @@ -0,0 +1,9 @@ +#include "sprite.h" + +Sprite::Sprite() { + +} + +Sprite::~Sprite() { + +} diff --git a/crumpet-engine/sprite.h b/crumpet-engine/sprite.h new file mode 100644 index 0000000..90fcdad --- /dev/null +++ b/crumpet-engine/sprite.h @@ -0,0 +1,10 @@ +#pragma once + +#include "entity.h"; + +class Sprite : public Entity { +public: + Sprite(); + virtual ~Sprite(); +}; + diff --git a/resources/sans-undertale-spritesheet.png b/resources/sans-undertale-spritesheet.png new file mode 100644 index 0000000..816bd9c Binary files /dev/null and b/resources/sans-undertale-spritesheet.png differ