diff --git a/Makefile b/Makefile index 2450243..0f0d972 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ -spiel: main.o - gcc -o spiel main.o -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 +spiel: main.o sprite.o + gcc -o spiel main.o sprite.o -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 main.o: main.c gcc -c main.c -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 +sprite.o: sprite.c + gcc -c sprite.c -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 + clean: - rm *.o + rm *.o spiel diff --git a/main.c b/main.c index c24c249..e37e162 100644 --- a/main.c +++ b/main.c @@ -10,7 +10,7 @@ int main(){ InitWindow(800, 450, "basic window"); Texture2D texture; - struct Sprite sprites[100]; + Sprite sprites[100]; int destX = 0; int destY = 0; @@ -22,14 +22,14 @@ int main(){ texture = LoadTexture("amulet.png"); int j = 0; - struct Sprite cursor = {&texture, 450, 225}; + Sprite cursor = {&texture, 450, 225}; Camera2D camera = { 0 }; camera.target = (Vector2){400, 225}; camera.rotation = 0.0f; camera.zoom = 1.0f; - addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y); + SpriteAdd(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y); @@ -43,7 +43,7 @@ int main(){ BeginMode2D(camera); int i; - int length = sizeof(sprites)/sizeof(sprites[0]); + //int length = sizeof(sprites)/sizeof(sprites[0]); for(i=0; i < j; i++){ DrawTexture(*sprites[i].texture, sprites[i].x, sprites[i].y, WHITE); } @@ -57,7 +57,7 @@ int main(){ /* if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){ printf("Klick\n"); - addSprite(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y); + SpriteAdd(sprites, &j, &texture, cursor.x + camera.target.x, cursor.y + camera.target.y); } */ diff --git a/main.o b/main.o index 6b235b6..8506279 100644 Binary files a/main.o and b/main.o differ diff --git a/spiel b/spiel index f6c02a6..ad1e946 100755 Binary files a/spiel and b/spiel differ diff --git a/sprite.c b/sprite.c new file mode 100644 index 0000000..42cd1d5 --- /dev/null +++ b/sprite.c @@ -0,0 +1,14 @@ +#include "sprite.h" +#include "raylib.h" + +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)++; + } + else{ + printf("Voll\n"); + } +} \ No newline at end of file diff --git a/sprite.h b/sprite.h index bf2bf58..cf7d6f5 100644 --- a/sprite.h +++ b/sprite.h @@ -1,17 +1,13 @@ -struct Sprite{ +#ifndef SPRITE_H_ +#define SPRITE_H_ +#include "raylib.h" + +typedef struct Sprite { Texture2D *texture; float x; float y; } Sprite; -void addSprite(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)++; - } - else{ - printf("Voll\n"); - } -} \ No newline at end of file +void SpriteAdd(struct Sprite *cursors, int *j, Texture2D *texture, int x, int y); + +#endif \ No newline at end of file diff --git a/sprite.o b/sprite.o new file mode 100644 index 0000000..8da654d Binary files /dev/null and b/sprite.o differ