Make entityList not a class

This commit is contained in:
2023-11-20 15:27:29 -05:00
parent 579444c4de
commit fb0cfb1cef
7 changed files with 18 additions and 35 deletions

View File

@@ -43,10 +43,10 @@ void pre_render() {
engine->initVideo();
engine->initGL();
auto camera = new(Camera);
entityList.storeEntity(camera);
storeEntity(camera);
getCamera()->position.set(0.0f,0.0f,5.0f);
auto skybox = new(Skybox);
entityList.storeEntity(skybox);
storeEntity(skybox);
}
engine->frameCount++;
process_sdl_events();

View File

@@ -14,7 +14,7 @@
switch (engine->gameState) {
case GAMESTATE::NORMAL:
if(engine->frameCount > 0)
getCamera()->update();
//getCamera()->update();
break;
case GAMESTATE::IN_MAIN_MENU:
break;

View File

@@ -17,10 +17,12 @@ public:
}
void render() {
if (engine->keyState[SDL_SCANCODE_0] == 1) {
this->takingScreenshot = true;
}
if (mode == CameraMode::FREECAM) {
if (engine->keyState[SDL_SCANCODE_0] == 1) {
this->takingScreenshot = true;
}
if (engine->keyState[SDL_SCANCODE_S] == 1) {
move(bAngle(),2);
}
@@ -80,7 +82,7 @@ public:
};
inline Camera* getCamera() {
for (auto& e : entityList.list)
for (auto& e : entityList)
if (auto* c = dynamic_cast<Camera*>(e))
return dynamic_cast<Camera *>(e);
}

View File

@@ -2,15 +2,9 @@
#include <vector>
#include "entity.h"
class EntityList {
public:
std::vector<Entity*> list;
inline void storeEntity(Entity* e) {
this->list.push_back(e);
}
};
//the primary entity list.
EntityList entityList;
std::vector<Entity*> entityList;
inline void storeEntity(Entity* e) {
entityList.push_back(e);
}

View File

@@ -21,7 +21,7 @@ public:
};
inline Player* getPlayer() {
for (auto& e : entityList.list)
for (auto& e : entityList)
if (auto* p = dynamic_cast<Player*>(e) )
return dynamic_cast<Player *>(e);
}

View File

@@ -93,7 +93,7 @@ public:
};
inline Skybox* getSkybox() {
for (auto& e : entityList.list)
for (auto& e : entityList)
if (auto* s = dynamic_cast<Skybox*>(e) )
return dynamic_cast<Skybox *>(e);
}

View File

@@ -8,15 +8,6 @@ public:
float x = 0; //pitch
float y = 0; //yaw
float z = 0; //roll
void normalize() {
float length = sqrt(x * x + y * y + z * z);
if (length != 0.0f) {
x /= length;
y /= length;
z /= length;
}
}
};
class angle : public vector3 {
@@ -27,11 +18,11 @@ public:
if (this->x <= -89.0f)
this->x = -89.0f;
//TODO: Make this seamless by getting the amount they rotated passed -180 and +180 by.
//TODO: Make this entirely seamless by getting the amount they rotated passed -180 and +180 by.
if (this->y <= -180.0f)
this->y = 180.0f;
if (this->y >= 180.01f)
this->y = -179.9f;
this->y = -179.9f;
if (this->z >= 360.0f)
this->z = 0.0;
@@ -43,10 +34,6 @@ public:
class Position : public vector3 {
public:
Position* get() {
return this;
}
void set(Position p) {
this->x = p.x;
this->y = p.y;