diff --git a/Makefile b/Makefile index aef5ea2..d8fde77 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ CC = clang LINK = -lstdc++ -lSDL2 -DBG = -Wall +DBG = -Wall -O3 CC += $(DBG) all: build ; -goals = bin/main.o bin/Color.o bin/Quad.o bin/Vector.o +goals = bin/main.o bin/Color.o bin/Quad.o bin/Vector.o bin/phys_obj.o bin/BoundingBox.o define pro = $(CC) -c $^ -o $@ @@ -13,14 +13,16 @@ endef bin/main.o: src/main.cpp $(pro) -#bin/Cube.o: src/Cube.cpp -# $(pro) +bin/BoundingBox.o: src/BoundingBox.cpp + $(pro) bin/Color.o: src/Color.cpp $(pro) bin/Quad.o: src/Quad.cpp $(pro) bin/Vector.o: src/Vector.cpp $(pro) +bin/phys_obj.o: src/phys_obj.cpp + $(pro) #targets = $(patsubst bin/%.o,src/%.cpp,$(goals)) #$(goals): $(targets) ; diff --git a/src/Window.cpp b/src/Window.cpp index b1f4ee5..40a5df8 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -26,5 +26,4 @@ int Window::initUI() { -1, SDL_RENDERER_ACCELERATED ); -} - +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 831fc98..606a442 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,7 @@ #include #include #include -#include -#include "Quad.h" +#include "phys_obj.h" SDL_Window *win = NULL; SDL_Renderer *rend = NULL; @@ -51,6 +50,10 @@ bool clamp(float *value, float val) { } } +void gravity(phys_obj &obj) { + obj.velocity = Vector(0,obj.velocity.y--); +} + int main() { init(); cc = Color(BLACK); @@ -78,8 +81,8 @@ int main() { Quad rect; - Quad *grav_objs = (Quad *)malloc(0); - std::vector objs; + std::vector objs; + //std::vector yvalues; while(run) { if(modified) { @@ -103,7 +106,7 @@ int main() { case SDL_MOUSEBUTTONUP: printf("Mouse released at %i,%i\n",x2,y2); trackmouse = false; - objs.push_back(rect); + objs.push_back(phys_obj(rect, Vector(0,0))); //grav_objs = (Quad *)calloc(1,sizeof(Quad)); //grav_objs[sizeof(grav_objs)/sizeof(grav_objs[0])] = rect; //printf("grav objs: %lu\n",(sizeof(grav_objs)/sizeof(grav_objs[0]))); @@ -158,6 +161,13 @@ int main() { } break; break; + case SDL_WINDOWEVENT: + switch(event.window.event) { + case SDL_WINDOWEVENT_RESIZED: + SDL_GetWindowSize(win,&w,&h); + break; + } + break; } } //change_vector[0] = clamp(&buffer.x,clamp_min); @@ -167,12 +177,11 @@ int main() { rect.setColor(Color(GREEN)); rect.render(rend); } - /*for(int i=0; i= h)) { + gravity(objs[i]); + } + objs[0].render(rend); } if(change_vector[0]) { if(buffer.x != 0.0) { @@ -193,7 +202,6 @@ int main() { quad.translate(buffer); quad.render(rend); SDL_RenderPresent(rend); - SDL_GetWindowSize(win,&w,&h); SDL_Delay(1000/60); } return 0;