refactor square to extend vector2

master
BuildTools 5 years ago
parent f85006c2ff
commit e9e4485dd4
  1. 2
      main.cpp
  2. 27
      stuff/objects/square.h

@ -19,7 +19,7 @@ int main(int argc, char** argv)
surface = SDL_GetWindowSurface(window);
SDL_Event eventHandler;
global::entList.push_back(square(200, 200, 50, 50));
global::entList.push_back(square(200, 200, 50));
while (global::running)
{

@ -1,25 +1,28 @@
#pragma once
#include "SDL.h"
struct square
#include "vector2.h"
/*
squares are the basic 2D entity
*/
struct square : public vector2
{
SDL_Rect rect;
int radius;
square()
{
rect.x = 0;
rect.y = 0;
rect.w = 0;
rect.h = 0;
this->x = 0;
this->y = 0;
this->radius = 0;
}
square(int x_, int y_, int w_, int h_)
square(int x_, int y_, int radius_)
{
rect.x = x_;
rect.y = y_;
rect.w = w_;
rect.h = h_;
this->x = x_;
this->y = y_;
this->radius = radius_;
}
void run(SDL_Surface* surface)
{
SDL_FillRect(surface, &this->rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF));
SDL_Rect rect{ this->x, this->y, this->radius, this->radius };
SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0xFF, 0xFF, 0xFF));
}
};
Loading…
Cancel
Save