Added 'zooming', maybe not a great way to do it but it'll do for now.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
bin/
|
||||
obj/
|
||||
@@ -1,6 +1,11 @@
|
||||
#ifndef 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 {
|
||||
unsigned int Capcity;
|
||||
unsigned int Size;
|
||||
@@ -1,7 +0,0 @@
|
||||
#include "list.h"
|
||||
|
||||
#define DEFAULTLISTSIZE 64
|
||||
|
||||
List* CreateList(void) {
|
||||
|
||||
}
|
||||
BIN
Binary file not shown.
+16
@@ -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
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user