todo list and camera class
This commit is contained in:
@@ -3,6 +3,8 @@ First off, we thank you for taking the time to contribute to the crumpet engine
|
|||||||
|
|
||||||
When contributing or submitting pull requests follow these guidelines or your contribution will not be taken seriously.
|
When contributing or submitting pull requests follow these guidelines or your contribution will not be taken seriously.
|
||||||
|
|
||||||
|
If you want to contribute but don't know what to do, see TODO.txt for a list of tasks that need to be complete, but make sure when you complete one you mark it as such, do not remove it from the list.
|
||||||
|
|
||||||
## Make sure your code is
|
## Make sure your code is
|
||||||
- Functional
|
- Functional
|
||||||
- Maintainable and Scalable
|
- Maintainable and Scalable
|
||||||
|
|||||||
8
TODO.txt
8
TODO.txt
@@ -1,10 +1,14 @@
|
|||||||
CURRENT TODO LIST FOR THE DEVELOPMENT OF THE CRUMPET GAME ENGINE
|
CURRENT TODO LIST FOR THE DEVELOPMENT OF THE CRUMPET GAME ENGINE
|
||||||
|
|
||||||
|
[ ] Fix entity / sprite resizing
|
||||||
|
[ ] Add sprite methods to entity
|
||||||
[ ] Game camera class and redo rendering pipeline
|
[ ] Game camera class and redo rendering pipeline
|
||||||
[ ] Add rotation and flipping for entities and sprites
|
[ ] Add rotation and flipping for entities and sprites
|
||||||
[ ] Camera class
|
[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
|
||||||
[ ] Game coordinate system
|
[ ] Game coordinate system
|
||||||
[ ] Render to game coordinates instead of screen coordinates
|
[ ] Render to GameWorld coordinates instead of screen coordinates
|
||||||
[ ] Each entity and sprite should store a reference to Camera
|
[ ] Each entity and sprite should store a reference to Camera
|
||||||
[ ] GameWorld class with coordinate system
|
[ ] GameWorld class with coordinate system
|
||||||
[ ] Switch between camera modes on GameWorld
|
[ ] Switch between camera modes on GameWorld
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
#include "camera.h"
|
|
||||||
|
|
||||||
Camera::Camera() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Camera::~Camera() {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,24 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "mathHelper.h"
|
#include "mathHelper.h"
|
||||||
|
|
||||||
|
struct AspectRatio {
|
||||||
|
int w, h;
|
||||||
|
AspectRatio(int w, int h) : w(w), h(h) {}
|
||||||
|
};
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
public:
|
public:
|
||||||
Camera();
|
Camera() {
|
||||||
|
this->Zoom = 1.0f;
|
||||||
|
this->Pos = new Vec2(0, 0);
|
||||||
|
this->Rotation = 1.0f;
|
||||||
|
this->Aspectratio = new AspectRatio(16, 9);
|
||||||
|
}
|
||||||
Vec2* Pos;
|
Vec2* Pos;
|
||||||
|
float Zoom;
|
||||||
|
float Rotation;
|
||||||
|
AspectRatio* Aspectratio;
|
||||||
|
|
||||||
virtual ~Camera();
|
virtual ~Camera();
|
||||||
private:
|
private:
|
||||||
SDL_Rect* m_veiw;
|
SDL_Rect* m_veiw;
|
||||||
|
|||||||
@@ -125,7 +125,6 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="camera.cpp" />
|
|
||||||
<ClCompile Include="entity.cpp" />
|
<ClCompile Include="entity.cpp" />
|
||||||
<ClCompile Include="game.cpp" />
|
<ClCompile Include="game.cpp" />
|
||||||
<ClCompile Include="gameWorld.cpp" />
|
<ClCompile Include="gameWorld.cpp" />
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
<ClCompile Include="game.cpp" />
|
<ClCompile Include="game.cpp" />
|
||||||
<ClCompile Include="sprite.cpp" />
|
<ClCompile Include="sprite.cpp" />
|
||||||
<ClCompile Include="logger.cpp" />
|
<ClCompile Include="logger.cpp" />
|
||||||
<ClCompile Include="camera.cpp" />
|
|
||||||
<ClCompile Include="gameWorld.cpp" />
|
<ClCompile Include="gameWorld.cpp" />
|
||||||
<ClCompile Include="level.cpp" />
|
<ClCompile Include="level.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ public:
|
|||||||
|
|
||||||
virtual ~Entity();
|
virtual ~Entity();
|
||||||
protected:
|
protected:
|
||||||
// std::string PATH = "C:/Users/Ben/Desktop/crumpet-engine";
|
std::string PATH = "C:/Users/Ben/Desktop/crumpet-engine";
|
||||||
std::string PATH = "E:/Games/crumpet-engine";
|
//std::string PATH = "E:/Games/crumpet-engine";
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ int main(int argc, char** argv) {
|
|||||||
Game game("Crumpet engine", SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1000 / 60); // 1000 / 60);
|
Game game("Crumpet engine", SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1000 / 60); // 1000 / 60);
|
||||||
Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
|
Entity bay("bay", game.SDLRenderer);
|
||||||
|
bay.LoadTexture("/resources/bay.jpg");
|
||||||
|
|
||||||
Sprite sans("sans", game.SDLRenderer, SpriteType::SPRITE_ANIMATED);
|
Sprite sans("sans", game.SDLRenderer, SpriteType::SPRITE_ANIMATED);
|
||||||
sans.LoadSpriteTextures("/resources/sans-undertale-spritesheet.png");
|
sans.LoadSpriteTextures("/resources/sans-undertale-spritesheet.png");
|
||||||
sans.UseSpriteSheet(SpriteState::STATE_FRONT, 30, 9, 230, 300, 10, 4);
|
sans.UseSpriteSheet(SpriteState::STATE_FRONT, 30, 9, 230, 300, 10, 4);
|
||||||
@@ -45,6 +48,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
game.RenderClear();
|
game.RenderClear();
|
||||||
game.RenderSprite(&sans);
|
game.RenderSprite(&sans);
|
||||||
|
game.RenderEntity(&bay);
|
||||||
game.RenderSprite(&explosion);
|
game.RenderSprite(&explosion);
|
||||||
game.RenderUpdate();
|
game.RenderUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ Renderer::Renderer(std::string title, int width, int height, int targetFramerate
|
|||||||
if (targetFramerate == 1)
|
if (targetFramerate == 1)
|
||||||
SDLRenderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
SDLRenderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
|
|
||||||
|
this->Width = width;
|
||||||
|
this->Height = height;
|
||||||
|
|
||||||
isClosed = false;
|
isClosed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +34,14 @@ void Renderer::RenderSprite(Sprite* sprite) {
|
|||||||
sprite->Render();
|
sprite->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::SetRendererColour(Vec4* col) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::RenderEmptyRect() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::RenderUpdate() {
|
void Renderer::RenderUpdate() {
|
||||||
SDL_SetRenderDrawColor(SDLRenderer, 66, 134, 244, 255);
|
SDL_SetRenderDrawColor(SDLRenderer, 66, 134, 244, 255);
|
||||||
SDL_RenderPresent(SDLRenderer);
|
SDL_RenderPresent(SDLRenderer);
|
||||||
|
|||||||
@@ -14,15 +14,24 @@ public:
|
|||||||
|
|
||||||
void RenderEntity(Entity* entity);
|
void RenderEntity(Entity* entity);
|
||||||
|
|
||||||
void TickSpriteAnimation(Sprite* sprite);
|
|
||||||
void RenderSprite(Sprite* sprite, SpriteState state);
|
void RenderSprite(Sprite* sprite, SpriteState state);
|
||||||
void RenderSprite(Sprite* sprite);
|
void RenderSprite(Sprite* sprite);
|
||||||
|
|
||||||
|
void SetRendererColour(Vec4* col);
|
||||||
|
|
||||||
|
void RenderEmptyRect();
|
||||||
|
void RenderFilledRect();
|
||||||
|
void RenderLines();
|
||||||
|
void RenderTexture();
|
||||||
|
|
||||||
void RenderUpdate();
|
void RenderUpdate();
|
||||||
void RenderClear();
|
void RenderClear();
|
||||||
|
|
||||||
bool IsDisplayClosed();
|
bool IsDisplayClosed();
|
||||||
void CloseDisplay();
|
void CloseDisplay();
|
||||||
|
|
||||||
|
int Width, Height;
|
||||||
|
|
||||||
virtual ~Renderer();
|
virtual ~Renderer();
|
||||||
private:
|
private:
|
||||||
SDL_Window *m_window;
|
SDL_Window *m_window;
|
||||||
|
|||||||
BIN
resources/bay.jpg
Normal file
BIN
resources/bay.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 468 KiB |
Reference in New Issue
Block a user