working Merge

main
JanEhehalt 3 years ago
parent 4cc6db1a87
commit a4caadbfc4

@ -41,7 +41,7 @@ void mouseInput(struct InputHandler *inputHandler, struct Sprite *sprites, int *
float height = GetMousePosition().y - inputHandler->rectStart.y; float height = GetMousePosition().y - inputHandler->rectStart.y;
if(width + height <= 1){ if(width + height <= 1){
//printf("Klick\n"); //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);
} }
} }

@ -14,12 +14,8 @@ int main(){
texture = LoadTexture("assets/amulet.png"); texture = LoadTexture("assets/amulet.png");
int spriteAmount = 0; 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; struct InputHandler inputHandler;
Camera2D camera = { 0 }; Camera2D camera = { 0 };
@ -27,7 +23,7 @@ int main(){
camera.rotation = 0.0f; camera.rotation = 0.0f;
camera.zoom = 1.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); SetTargetFPS(60);
while(!WindowShouldClose()){ while(!WindowShouldClose()){
@ -39,7 +35,7 @@ int main(){
BeginMode2D(camera); BeginMode2D(camera);
int i; int i;
//int length = sizeof(sprites)/sizeof(sprites[0]); //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); DrawTexture(*sprites[i].texture, sprites[i].x, sprites[i].y, WHITE);
} }
EndMode2D(); EndMode2D();

BIN
main.o

Binary file not shown.

BIN
spiel

Binary file not shown.

@ -1,14 +1,19 @@
#include "sprite.h" #include "sprite.h"
#include "raylib.h" #include "raylib.h"
#include <stdio.h>
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){
if(*j < 100){ if(*spriteAmount < 100){
(cursors + *j) -> texture = texture; (sprites + *spriteAmount) -> texture = texture;
(cursors + *j) -> x = x; (sprites + *spriteAmount) -> x = x;
(cursors + *j) -> y = y; (sprites + *spriteAmount) -> y = y;
(*j)++; (*spriteAmount)++;
} }
else{ else{
printf("Voll\n"); printf("Voll\n");
} }
} }
void DrawSprite(struct Sprite *sprite){
DrawTexture(*sprite->texture, sprite->x, sprite->y, WHITE);
}

@ -11,6 +11,8 @@ typedef struct Sprite {
int hasDestination; int hasDestination;
} Sprite; } 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 #endif

Binary file not shown.
Loading…
Cancel
Save