mirror of
https://github.com/PoetryInCode/simple-rigid-sim.git
synced 2025-06-09 11:03:08 -04:00
added method to fetch all yvalues, may remove
This commit is contained in:
parent
d425ac7483
commit
f066dc1760
19
src/Quad.cpp
19
src/Quad.cpp
@ -1,4 +1,6 @@
|
|||||||
#include "Quad.h"
|
#include "Quad.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/*Quad::Quad(Vector topL, Vector topR, Vector botR, Vector botL) {
|
/*Quad::Quad(Vector topL, Vector topR, Vector botR, Vector botL) {
|
||||||
this->topL=topL;
|
this->topL=topL;
|
||||||
@ -6,6 +8,7 @@
|
|||||||
this->botR=botR;
|
this->botR=botR;
|
||||||
this->botL=botL;
|
this->botL=botL;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
Quad::Quad(Vector topLeft, int width, int height) {
|
Quad::Quad(Vector topLeft, int width, int height) {
|
||||||
topL.x = topLeft.x;
|
topL.x = topLeft.x;
|
||||||
topL.y = topLeft.y;
|
topL.y = topLeft.y;
|
||||||
@ -15,6 +18,7 @@ Quad::Quad(Vector topLeft, int width, int height) {
|
|||||||
botR.y = topLeft.y-height;
|
botR.y = topLeft.y-height;
|
||||||
botL.x = topLeft.x;
|
botL.x = topLeft.x;
|
||||||
botL.y = topLeft.y-height;
|
botL.y = topLeft.y-height;
|
||||||
|
center = Vector(abs(topL.x-topR.x),abs(topL.y-botL.y));
|
||||||
}
|
}
|
||||||
Quad::Quad(Vector corner1,Vector corner2) {
|
Quad::Quad(Vector corner1,Vector corner2) {
|
||||||
topL.x = corner1.x;
|
topL.x = corner1.x;
|
||||||
@ -25,6 +29,7 @@ Quad::Quad(Vector corner1,Vector corner2) {
|
|||||||
botR.y = corner2.y;
|
botR.y = corner2.y;
|
||||||
botL.x = corner1.x;
|
botL.x = corner1.x;
|
||||||
botL.y = corner2.y;
|
botL.y = corner2.y;
|
||||||
|
center = Vector(abs(topL.x-topR.x),abs(topL.y-botL.y));
|
||||||
}
|
}
|
||||||
Quad::Quad() {}
|
Quad::Quad() {}
|
||||||
|
|
||||||
@ -61,13 +66,25 @@ void Quad::setColor(Color c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Quad::translate(Vector vec) {
|
void Quad::translate(Vector vec) {
|
||||||
|
if(vec.x != 0) {
|
||||||
topL.x += vec.x;
|
topL.x += vec.x;
|
||||||
topR.x += vec.x;
|
topR.x += vec.x;
|
||||||
botR.x += vec.x;
|
botR.x += vec.x;
|
||||||
botL.x += vec.x;
|
botL.x += vec.x;
|
||||||
|
}
|
||||||
|
if(vec.y != 0) {
|
||||||
topL.y += vec.y;
|
topL.y += vec.y;
|
||||||
topR.y += vec.y;
|
topR.y += vec.y;
|
||||||
botR.y += vec.y;
|
botR.y += vec.y;
|
||||||
botL.y += vec.y;
|
botL.y += vec.y;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> Quad::yvalues() {
|
||||||
|
std::vector<int> values;
|
||||||
|
values.push_back(topL.y);
|
||||||
|
values.push_back(topR.y);
|
||||||
|
values.push_back(botR.y);
|
||||||
|
values.push_back(botL.y);
|
||||||
|
return values;
|
||||||
|
}
|
@ -1,15 +1,18 @@
|
|||||||
#include "Color.h"
|
#include <vector>
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#include "Vector.h"
|
#include "Vector.h"
|
||||||
|
#include "Color.h"
|
||||||
|
|
||||||
class Quad {
|
class Quad {
|
||||||
public:
|
public:
|
||||||
Color color;
|
Color color;
|
||||||
Vector topL,topR,botR,botL;
|
Vector topL,topR,botR,botL;
|
||||||
|
Vector center;
|
||||||
//Quad(Vector topL, Vector topR, Vector botR, Vector botL);
|
//Quad(Vector topL, Vector topR, Vector botR, Vector botL);
|
||||||
Quad(Vector topLeft, int width, int height);
|
Quad(Vector topLeft, int width, int height);
|
||||||
Quad(Vector corner1, Vector corner2);
|
Quad(Vector corner1, Vector corner2);
|
||||||
Quad();
|
Quad();
|
||||||
|
std::vector<int> yvalues();
|
||||||
void setColor(Color c);
|
void setColor(Color c);
|
||||||
void render(SDL_Renderer *renderer);
|
void render(SDL_Renderer *renderer);
|
||||||
void translate(Vector vec);
|
void translate(Vector vec);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user