Added 'zooming', maybe not a great way to do it but it'll do for now.

This commit is contained in:
2022-10-29 23:29:58 -05:00
parent 4018c8bad2
commit 897186928e
7 changed files with 33 additions and 11 deletions
+2
View File
@@ -0,0 +1,2 @@
bin/
obj/
BIN
View File
Binary file not shown.
+5
View File
@@ -1,6 +1,11 @@
#ifndef LIST_H #ifndef LIST_H
#define LIST_H #define LIST_H
#include <SDL2/SDL_rect.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL.h>
typedef struct { typedef struct {
unsigned int Capcity; unsigned int Capcity;
unsigned int Size; unsigned int Size;
-7
View File
@@ -1,7 +0,0 @@
#include "list.h"
#define DEFAULTLISTSIZE 64
List* CreateList(void) {
}
BIN
View File
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
#include "../includes/list.h"
#include <stdlib.h>
#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;
}
+10 -4
View File
@@ -21,6 +21,7 @@
const int SCREEN_WIDTH = 1280; const int SCREEN_WIDTH = 1280;
const int SCREEN_HEIGHT = 720; const int SCREEN_HEIGHT = 720;
int MouseDown = 0; int MouseDown = 0;
float ZoomLevel = 1;
typedef struct { typedef struct {
SDL_Window *window; SDL_Window *window;
@@ -87,14 +88,14 @@ int main(int argc, char** argv){
//SDL_SetRelativeMouseMode(SDL_TRUE); //SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_Rect rect; SDL_FRect rect;
rect.x = SCREEN_WIDTH / SCREEN_HEIGHT; rect.x = SCREEN_WIDTH / SCREEN_HEIGHT;
rect.y = SCREEN_WIDTH / SCREEN_HEIGHT; rect.y = SCREEN_WIDTH / SCREEN_HEIGHT;
rect.w = SCREEN_WIDTH / 2; rect.w = SCREEN_WIDTH / 2;
rect.h = SCREEN_HEIGHT / 2; rect.h = SCREEN_HEIGHT / 2;
SDL_Rect rect2; SDL_FRect rect2;
rect2.x = 250;// / SCREEN_HEIGHT; rect2.x = 250;// / SCREEN_HEIGHT;
rect2.y = 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_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_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); SDL_RenderPresent(app.renderer);
@@ -159,6 +160,11 @@ void HandleInput(void) {
XRel += event.motion.xrel; XRel += event.motion.xrel;
YRel += event.motion.yrel; 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_TEXTINPUT:
case SDL_KEYDOWN: case SDL_KEYDOWN:
default: default: