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;
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);
}
}

@ -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();

BIN
main.o

Binary file not shown.

BIN
spiel

Binary file not shown.

@ -1,14 +1,19 @@
#include "sprite.h"
#include "raylib.h"
#include <stdio.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)++;
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);
}

@ -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

Binary file not shown.
Loading…
Cancel
Save