diff --git a/inputHandling.h b/inputHandling.h index 8642c82..a0d3da7 100644 --- a/inputHandling.h +++ b/inputHandling.h @@ -41,7 +41,7 @@ void mouseInput(struct InputHandler *inputHandler, struct Sprite *sprites, int * float height = GetMousePosition().y - inputHandler->rectStart.y; if(width + height <= 1){ //printf("Klick\n"); - addSprite(sprites, spriteAmount, texture, inputHandler->cursorPos.x + (*camera).target.x - (texture->width)/2, inputHandler->cursorPos.y + (*camera).target.y - (texture->height)/2); + SpriteAdd(sprites, spriteAmount, texture, inputHandler->cursorPos.x + (*camera).target.x - (texture->width)/2, inputHandler->cursorPos.y + (*camera).target.y - (texture->height)/2); } } diff --git a/main.c b/main.c index a8f8f3d..07f47f1 100644 --- a/main.c +++ b/main.c @@ -14,12 +14,8 @@ int main(){ texture = LoadTexture("assets/amulet.png"); int spriteAmount = 0; - struct Sprite cursorSprite = {&texture, 450, 225}; + Sprite cursorSprite = {&texture, 450, 225}; - texture = LoadTexture("amulet.png"); - - int j = 0; - Sprite cursor = {&texture, 450, 225}; struct InputHandler inputHandler; Camera2D camera = { 0 }; @@ -27,7 +23,7 @@ int main(){ camera.rotation = 0.0f; camera.zoom = 1.0f; - SpriteAdd(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y); + SpriteAdd(sprites, &spriteAmount, &texture, 400, 400); SetTargetFPS(60); while(!WindowShouldClose()){ @@ -39,7 +35,7 @@ int main(){ BeginMode2D(camera); int i; //int length = sizeof(sprites)/sizeof(sprites[0]); - for(i=0; i < j; i++){ + for(i=0; i < spriteAmount; i++){ DrawTexture(*sprites[i].texture, sprites[i].x, sprites[i].y, WHITE); } EndMode2D(); diff --git a/main.o b/main.o new file mode 100644 index 0000000..3d96a59 Binary files /dev/null and b/main.o differ diff --git a/spiel b/spiel new file mode 100755 index 0000000..9259a8f Binary files /dev/null and b/spiel differ diff --git a/sprite.c b/sprite.c index 894a25f..14f3f9a 100644 --- a/sprite.c +++ b/sprite.c @@ -1,14 +1,19 @@ #include "sprite.h" #include "raylib.h" +#include -void SpriteAdd(struct Sprite *cursors, int *j, Texture2D *texture, int x, int y){ - if(*j < 100){ - (cursors + *j) -> texture = texture; - (cursors + *j) -> x = x; - (cursors + *j) -> y = y; - (*j)++; +void SpriteAdd(struct Sprite *sprites, int *spriteAmount, Texture2D *texture, int x, int y){ + if(*spriteAmount < 100){ + (sprites + *spriteAmount) -> texture = texture; + (sprites + *spriteAmount) -> x = x; + (sprites + *spriteAmount) -> y = y; + (*spriteAmount)++; } else{ printf("Voll\n"); } } + +void DrawSprite(struct Sprite *sprite){ + DrawTexture(*sprite->texture, sprite->x, sprite->y, WHITE); +} diff --git a/sprite.h b/sprite.h index 44e32ad..f060300 100644 --- a/sprite.h +++ b/sprite.h @@ -11,6 +11,8 @@ typedef struct Sprite { int hasDestination; } Sprite; -void SpriteAdd(struct Sprite *cursors, int *j, Texture2D *texture, int x, int y); +void SpriteAdd(struct Sprite *sprites, int *spriteAmount, Texture2D *texture, int x, int y); + +void DrawSprite(struct Sprite *sprite); #endif diff --git a/sprite.o b/sprite.o index 459c435..673167d 100644 Binary files a/sprite.o and b/sprite.o differ