Updated files, new rect plan and updated TODO.txt
This commit is contained in:
16
TODO.txt
16
TODO.txt
@@ -2,11 +2,25 @@ CURRENT TODO LIST FOR THE DEVELOPMENT OF THE CRUMPET GAME ENGINE
|
||||
|
||||
[ ] Fix entity / sprite resizing
|
||||
[ ] Add sprite methods to entity
|
||||
[ ] Logger class
|
||||
[ ] Maybe use preprocessor statements
|
||||
[ ] Time and other useful logging methods
|
||||
[ ] Empty constructor, instance method
|
||||
[ ] Rect class to extend SDL_Rect and add conversion capabilitys, colision and intersection to it
|
||||
[ ] Camera class to use Rect* instead of SLD_Rect*
|
||||
[ ] Add and subtract (+ -) operators to add rectangles and subtract them together
|
||||
[ ] Equal and not equal (!= ==) operators to return true / flase if the rectangles match
|
||||
[ ] ToString function for easy logging
|
||||
[ ] Setposition and translate methods
|
||||
[ ] Intersects, contains methods
|
||||
[ ] x,y,w,h properties
|
||||
[ ] Center point
|
||||
[ ] Maybe a point class
|
||||
[ ] Game camera class and redo rendering pipeline
|
||||
[ ] Add rotation and flipping for entities and sprites
|
||||
[x] Camera class
|
||||
[ ] Make the camera class control the rendering of the active scene
|
||||
[ ] Change every class to use vector pointers and remove the initalization lists
|
||||
[ ] Change every class / constructor to use vector pointers and remove the initalization lists
|
||||
[ ] Game coordinate system
|
||||
[ ] Render to GameWorld coordinates instead of screen coordinates
|
||||
[ ] Each entity and sprite should store a reference to Camera
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include "mathHelper.h"
|
||||
|
||||
struct AspectRatio {
|
||||
int w, h;
|
||||
AspectRatio(int w, int h) : w(w), h(h) {}
|
||||
};
|
||||
#include "rect.h"
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
Camera() {
|
||||
this->Zoom = 1.0f;
|
||||
this->Pos = new Vec2(0, 0);
|
||||
this->Rotation = 1.0f;
|
||||
this->Aspectratio = new AspectRatio(16, 9);
|
||||
}
|
||||
Vec2* Pos;
|
||||
float Zoom;
|
||||
float Rotation;
|
||||
AspectRatio* Aspectratio;
|
||||
Camera();
|
||||
void TranslateView(Vec2* offset);
|
||||
void TranslateViewX(int x);
|
||||
void TranslateViewY(int y);
|
||||
void SetSize(Vec2* size);
|
||||
|
||||
void SetCenter(Vec2* point);
|
||||
|
||||
virtual ~Camera();
|
||||
private:
|
||||
SDL_Rect* m_veiw;
|
||||
Rect* m_view;
|
||||
};
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
<ClCompile Include="level.cpp" />
|
||||
<ClCompile Include="logger.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="rect.cpp" />
|
||||
<ClCompile Include="renderer.cpp" />
|
||||
<ClCompile Include="sprite.cpp" />
|
||||
</ItemGroup>
|
||||
@@ -142,6 +143,7 @@
|
||||
<ClInclude Include="level.h" />
|
||||
<ClInclude Include="logger.h" />
|
||||
<ClInclude Include="mathHelper.h" />
|
||||
<ClInclude Include="rect.h" />
|
||||
<ClInclude Include="renderer.h" />
|
||||
<ClInclude Include="sprite.h" />
|
||||
<ClInclude Include="timer.h" />
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<ClCompile Include="logger.cpp" />
|
||||
<ClCompile Include="gameWorld.cpp" />
|
||||
<ClCompile Include="level.cpp" />
|
||||
<ClCompile Include="rect.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="headers">
|
||||
@@ -46,5 +47,8 @@
|
||||
<ClInclude Include="level.h">
|
||||
<Filter>headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rect.h">
|
||||
<Filter>headers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "entity.h"
|
||||
|
||||
Entity::Entity(std::string name, SDL_Renderer* SDLRenderer)
|
||||
: m_rectPos(0, 0),
|
||||
m_rectSize(0, 0),
|
||||
m_col(0, 0, 0, 0),
|
||||
Pos(0, 0),
|
||||
Size(0, 0) {
|
||||
: m_rectPos(0, 0)
|
||||
, m_rectSize(0, 0)
|
||||
, m_col(0, 0, 0, 0)
|
||||
, Pos(0, 0)
|
||||
, Size(0, 0) {
|
||||
|
||||
this->m_name = name;
|
||||
this->m_SDLRenderer = SDLRenderer;
|
||||
|
||||
@@ -9,9 +9,6 @@ int main(int argc, char** argv) {
|
||||
Game game("Crumpet engine", SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1000 / 60); // 1000 / 60);
|
||||
Timer timer;
|
||||
|
||||
Entity bay("bay", game.SDLRenderer);
|
||||
bay.LoadTexture("/resources/bay.jpg");
|
||||
|
||||
Sprite sans("sans", game.SDLRenderer, SpriteType::SPRITE_ANIMATED);
|
||||
sans.LoadSpriteTextures("/resources/sans-undertale-spritesheet.png");
|
||||
sans.UseSpriteSheet(SpriteState::STATE_FRONT, 30, 9, 230, 300, 10, 4);
|
||||
@@ -48,7 +45,6 @@ int main(int argc, char** argv) {
|
||||
|
||||
game.RenderClear();
|
||||
game.RenderSprite(&sans);
|
||||
game.RenderEntity(&bay);
|
||||
game.RenderSprite(&explosion);
|
||||
game.RenderUpdate();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
const float DEG2RAD = 0.01745329251994329576923690768f;
|
||||
const float RAD2DEG = 57.2957795130823208767981548141f;
|
||||
|
||||
inline float ToRadian(const float Degree) {
|
||||
return (Degree * DEG2RAD);
|
||||
}
|
||||
|
||||
inline float ToDegree(const float Radian) {
|
||||
return (Radian * RAD2DEG);
|
||||
}
|
||||
|
||||
struct Vec4 {
|
||||
int x, y, z, w;
|
||||
Vec4(int x, int y, int z, int w) : x(x), y(y), z(z), w(w) {}
|
||||
|
||||
9
crumpet-engine/rect.cpp
Normal file
9
crumpet-engine/rect.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "rect.h"
|
||||
|
||||
Rect::Rect() {
|
||||
|
||||
}
|
||||
|
||||
Rect::~Rect() {
|
||||
|
||||
}
|
||||
7
crumpet-engine/rect.h
Normal file
7
crumpet-engine/rect.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
class Rect {
|
||||
public:
|
||||
Rect();
|
||||
virtual ~Rect();
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "sprite.h"
|
||||
|
||||
Sprite::Sprite(std::string name, SDL_Renderer* SDLRenderer, SpriteType mode)
|
||||
: Entity(name, SDLRenderer),
|
||||
Pos(0, 0) {
|
||||
: Entity(name, SDLRenderer)
|
||||
, Pos(0, 0) {
|
||||
|
||||
this->m_SDLRenderer = SDLRenderer;
|
||||
this->Spritetype = mode;
|
||||
@@ -55,20 +55,26 @@ void Sprite::TickAninmation() {
|
||||
}
|
||||
|
||||
// TODO: get this and the next method done correct
|
||||
//at the moment the SpriteState(i) will just check for
|
||||
//sprites with that state, and if they exist it will
|
||||
//resize them, it needs to resize only the sprites
|
||||
//in the std::map m_spriteSize
|
||||
void Sprite::ResizeSprites(Vec2* newSize) {
|
||||
for (auto i = 0; i < m_spriteSize.size(); i++) {
|
||||
for (unsigned int i = 0; i < m_spriteSize.size(); i++) {
|
||||
m_spriteSize[SpriteState(i)]->x = newSize->x;
|
||||
m_spriteSize[SpriteState(i)]->y = newSize->y;
|
||||
}
|
||||
}
|
||||
|
||||
void Sprite::ResizeSpritesByFactor(float factor) {
|
||||
for (auto i = 0; i < m_spriteSize.size(); i++) {
|
||||
for (unsigned int i = 0; i < m_spriteSize.size(); i++) {
|
||||
m_spriteSize[SpriteState(i)]->x *= factor;
|
||||
m_spriteSize[SpriteState(i)]->y *= factor;
|
||||
}
|
||||
}
|
||||
|
||||
//These 2 methods work as they change a spesific and predefined
|
||||
//sprite state
|
||||
void Sprite::ResizeSpriteState(SpriteState state, Vec2* newSize) {
|
||||
m_spriteSize[state]->x = newSize->x;
|
||||
m_spriteSize[state]->y = newSize->y;
|
||||
@@ -79,6 +85,11 @@ void Sprite::ResizeSpriteStateByFactor(SpriteState state, float factor) {
|
||||
m_spriteSize[state]->y *= factor;
|
||||
}
|
||||
|
||||
void Sprite::Move(Vec2* offset) {
|
||||
Pos.x += offset->x;
|
||||
Pos.y += offset->y;
|
||||
}
|
||||
|
||||
void Sprite::Render() {
|
||||
SDL_Rect* currentFrameClip = m_spriteMaps[Spritestate][m_currentFrame];
|
||||
Vec2* currentRenderSize = m_spriteSize[Spritestate];
|
||||
|
||||
@@ -57,7 +57,9 @@ public:
|
||||
void ResizeSpriteState(SpriteState state, Vec2* newSize);
|
||||
void ResizeSpriteStateByFactor(SpriteState state, float factor);
|
||||
|
||||
void Move();
|
||||
void Move(Vec2* offest);
|
||||
void MoveX(int offest);
|
||||
void MoveY(int offest);
|
||||
|
||||
Vec2 Pos;
|
||||
void Render();
|
||||
|
||||
Reference in New Issue
Block a user