basic 3d stuff

master
BuildTools 5 years ago
parent e9e4485dd4
commit 4cac2beb4f
  1. 2
      main.cpp
  2. 2
      stuff/globals/globals.cpp
  3. 6
      stuff/globals/globals.h
  4. 22
      stuff/objects/cube.h
  5. 6
      stuff/objects/entityList2D.h
  6. 19
      stuff/objects/entityList3D.h
  7. 8
      stuff/objects/square.h
  8. 8
      stuff/objects/vector3.h
  9. 6
      threedee.vcxproj
  10. 14
      threedee.vcxproj.filters

@ -3,7 +3,7 @@
#include "SDL.h"
#include "stuff/objects/vector2.h"
#include "stuff/objects/vector.h"
#include "stuff/objects/vector3.h"
#include "stuff/globals/globals.h"
#include "stuff/callbacks/callbacks.h"

@ -2,4 +2,4 @@
bool global::running = true;
vector2 global::mousePos;
entityList global::entList;
entityList2D global::entList;

@ -1,9 +1,9 @@
#pragma once
#include "../objects/vector.h"
#include "../objects/entityList.h"
#include "../objects/vector3.h"
#include "../objects/entityList2D.h"
namespace global
{
extern bool running;
extern vector2 mousePos;
extern entityList entList;
extern entityList2D entList;
}

@ -0,0 +1,22 @@
#pragma once
#include "square.h"
/*
cubes are the basic 3D entity
*/
struct cube : public square
{
float z;
cube() : square()
{
this->z = 0;
}
cube(float x_, float y_, float z_, int radius_) : square(x_, y_, radius_)
{
this->z = z_;
}
void run(SDL_Surface* surface)
{
SDL_Rect rect{ this->x, this->y, this->radius, this->radius };
SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF));
}
};

@ -3,8 +3,10 @@
#include "SDL.h"
#include "square.h"
class entityList : public std::vector<square>
/*
entityList2D is the 2D entity container class
*/
class entityList2D : public std::vector<square>
{
public:
void run(SDL_Surface* surface)

@ -0,0 +1,19 @@
#pragma once
#include <vector>
#include "SDL.h"
#include "cube.h"
/*
entityList3D is the 3D entity container class
*/
class entityList3D : public std::vector<cube>
{
public:
void run(SDL_Surface* surface)
{
for (cube entity : *this)
{
entity.run(surface);
}
}
};

@ -8,16 +8,12 @@ squares are the basic 2D entity
struct square : public vector2
{
int radius;
square()
square() : vector2()
{
this->x = 0;
this->y = 0;
this->radius = 0;
}
square(int x_, int y_, int radius_)
square(float x_, float y_, int radius_) : vector2(x_, y_)
{
this->x = x_;
this->y = y_;
this->radius = radius_;
}
void run(SDL_Surface* surface)

@ -1,18 +1,18 @@
#pragma once
#include "vector2.h"
/*
vectors extend vector2s and hold 3D cartesian coordinates
vector3s extend vector2s and hold 3D cartesian coordinates
*/
struct vector : public vector2
struct vector3 : public vector2
{
float z;
vector()
vector3()
{
this->x = 0.f;
this->y = 0.f;
this->z = 0.f;
}
vector(float x_, float y_, float z_)
vector3(float x_, float y_, float z_)
{
this->x = x_;
this->y = y_;

@ -241,11 +241,13 @@
<ClInclude Include="sdl\include\SDL_video.h" />
<ClInclude Include="sdl\include\SDL_vulkan.h" />
<ClInclude Include="stuff\callbacks\callbacks.h" />
<ClInclude Include="stuff\objects\entityList3D.h" />
<ClInclude Include="stuff\globals\globals.h" />
<ClInclude Include="stuff\objects\entityList.h" />
<ClInclude Include="stuff\objects\cube.h" />
<ClInclude Include="stuff\objects\entityList2D.h" />
<ClInclude Include="stuff\objects\square.h" />
<ClInclude Include="stuff\objects\vector2.h" />
<ClInclude Include="stuff\objects\vector.h" />
<ClInclude Include="stuff\objects\vector3.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />

@ -276,9 +276,6 @@
<ClInclude Include="stuff\objects\vector2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stuff\objects\vector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stuff\globals\globals.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -288,7 +285,16 @@
<ClInclude Include="stuff\objects\square.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stuff\objects\entityList.h">
<ClInclude Include="stuff\objects\cube.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stuff\objects\vector3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stuff\objects\entityList2D.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stuff\objects\entityList3D.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

Loading…
Cancel
Save