AND THE RAYS THEY MARCH ON AND ON AND ON! THE RAYS THEY MARCH ON AND ON AND ON AND ON AND ON!

master
BuildTools 5 years ago
parent 233d07b573
commit 59eb847be5
  1. 13
      main.cpp
  2. 4
      stuff/objects/cube.h
  3. 4
      stuff/objects/entityList2D.h
  4. 4
      stuff/objects/entityList3D.h
  5. 2
      stuff/objects/ray2D.h
  6. 4
      stuff/objects/square.h

@ -32,18 +32,17 @@ int main(int argc, char** argv)
{
callbacks::handleCallbacks(&eventHandler);
//SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, 0, 0, 0));
ray2D ray = ray2D::trace(vector2(0, 201), vector2(.01, 0));
ray2D ray2 = ray2D::trace(vector2(201, 0), vector2(0, .01));
ray2D ray = ray2D::trace(vector2(0, 200), vector2(1, 0));
//SDL_RenderClear(renderer);
SDL_RenderDrawLine(renderer, ray.start.x, ray.start.y, ray.end.x, ray.end.y);
SDL_RenderPresent(renderer);
SDL_RenderDrawLine(renderer, ray2.start.x, ray2.start.y, ray2.end.x, ray2.end.y);
//global::entList.run(surface);
//global::entList3D.run(surface);
global::entList.run(renderer);
global::entList3D.run(renderer);
//SDL_UpdateWindowSurface(window);
SDL_RenderPresent(renderer);
SDL_Delay(1);
}
SDL_DestroyWindow(window);

@ -14,9 +14,9 @@ struct cube : public square
{
this->z = z_;
}
void run(SDL_Surface* surface)
void run(SDL_Renderer* renderer)
{
//SDL_Rect rect{ this->x, this->y, this->radius, this->radius };
//SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF));
//SDL_RenderFillRect(renderer, &rect);
}
};

@ -9,11 +9,11 @@ entityList2D is the 2D entity container class
class entityList2D : public std::vector<square>
{
public:
void run(SDL_Surface* surface)
void run(SDL_Renderer* renderer)
{
for (square entity : *this)
{
entity.run(surface);
entity.run(renderer);
}
}
};

@ -9,11 +9,11 @@ entityList3D is the 3D entity container class
class entityList3D : public std::vector<cube>
{
public:
void run(SDL_Surface* surface)
void run(SDL_Renderer* renderer)
{
for (cube entity : *this)
{
entity.run(surface);
entity.run(renderer);
}
}
};

@ -23,7 +23,7 @@ struct ray2D
{
for (square object : global::entList)
{
if (inRect(point, vector2(object.x - (object.radius / 2), object.y - (object.radius / 2)), vector2(object.x + (object.radius / 2), object.y + (object.radius / 2))))
if (inRect(point, vector2(object.x, object.y), vector2(object.x + object.radius, object.y + object.radius)))
{
ray.start = start;
ray.end = point;

@ -16,9 +16,9 @@ struct square : public vector2
{
this->radius = radius_;
}
void run(SDL_Surface* surface)
void run(SDL_Renderer* renderer)
{
SDL_Rect rect{ this->x, this->y, this->radius, this->radius };
SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF));
SDL_RenderFillRect(renderer, &rect);
}
};
Loading…
Cancel
Save