diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbbd0b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/ +obj/ \ No newline at end of file diff --git a/bin/game b/bin/game deleted file mode 100755 index 674de52..0000000 Binary files a/bin/game and /dev/null differ diff --git a/list.h b/includes/list.h similarity index 59% rename from list.h rename to includes/list.h index ae6fff7..033b8ad 100644 --- a/list.h +++ b/includes/list.h @@ -1,6 +1,11 @@ #ifndef LIST_H #define LIST_H +#include +#include +#include +#include + typedef struct { unsigned int Capcity; unsigned int Size; diff --git a/list.c b/list.c deleted file mode 100644 index 076dbd5..0000000 --- a/list.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "list.h" - -#define DEFAULTLISTSIZE 64 - -List* CreateList(void) { - -} \ No newline at end of file diff --git a/obj/main.o b/obj/main.o deleted file mode 100644 index e43f637..0000000 Binary files a/obj/main.o and /dev/null differ diff --git a/src/list.c b/src/list.c new file mode 100644 index 0000000..bdb5e97 --- /dev/null +++ b/src/list.c @@ -0,0 +1,16 @@ +#include "../includes/list.h" +#include + +#define DEFAULTLISTSIZE 64 + +List* CreateList(void) { + List* list = calloc(1, sizeof(List)); + + list->Strings = calloc(DEFAULTLISTSIZE, sizeof(char*)); + + list->Capcity = DEFAULTLISTSIZE; + list->Size = 0; + + return list; +} + diff --git a/src/main.c b/src/main.c index 36e188f..9bded46 100644 --- a/src/main.c +++ b/src/main.c @@ -21,6 +21,7 @@ const int SCREEN_WIDTH = 1280; const int SCREEN_HEIGHT = 720; int MouseDown = 0; +float ZoomLevel = 1; typedef struct { SDL_Window *window; @@ -87,14 +88,14 @@ int main(int argc, char** argv){ //SDL_SetRelativeMouseMode(SDL_TRUE); - SDL_Rect rect; + SDL_FRect rect; rect.x = SCREEN_WIDTH / SCREEN_HEIGHT; rect.y = SCREEN_WIDTH / SCREEN_HEIGHT; rect.w = SCREEN_WIDTH / 2; rect.h = SCREEN_HEIGHT / 2; - SDL_Rect rect2; + SDL_FRect rect2; rect2.x = 250;// / SCREEN_HEIGHT; rect2.y = 250;// / SCREEN_HEIGHT; @@ -124,11 +125,11 @@ int main(int argc, char** argv){ // } SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0); - SDL_RenderFillRect(app.renderer, &(SDL_Rect){rect.x + XRel, rect.y + YRel, rect.w, rect.h}); + SDL_RenderFillRectF(app.renderer, &(SDL_FRect){rect.x + XRel, rect.y + YRel, rect.w * ZoomLevel, rect.h * ZoomLevel}); SDL_SetRenderDrawColor(app.renderer, 128, 0, 0, 0); - SDL_RenderFillRect(app.renderer, &(SDL_Rect){rect2.x + XRel, rect2.y + YRel, rect2.w, rect2.h}); + SDL_RenderFillRectF(app.renderer, &(SDL_FRect){rect2.x + XRel, rect2.y + YRel, rect2.w * ZoomLevel, rect2.h * ZoomLevel}); SDL_RenderPresent(app.renderer); @@ -159,6 +160,11 @@ void HandleInput(void) { XRel += event.motion.xrel; YRel += event.motion.yrel; } + break; + case SDL_MOUSEWHEEL: + if (event.wheel.y > 0 && ZoomLevel < 2) ZoomLevel += .05; + else if (event.wheel.y < 0 && ZoomLevel > 0.25) ZoomLevel -= .05; + break; case SDL_TEXTINPUT: case SDL_KEYDOWN: default: