You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
#include "sprite.h"
|
|
#include "raylib.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "List/list.h"
|
|
|
|
void SpriteAdd(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;
|
|
(sprites + *spriteAmount) -> destX = x;
|
|
(sprites + *spriteAmount) -> destY = y;
|
|
(sprites + *spriteAmount) -> hasDestination = 0;
|
|
(sprites + *spriteAmount) -> selected = 0;
|
|
(*spriteAmount)++;
|
|
}
|
|
else{
|
|
printf("Voll\n");
|
|
}
|
|
}
|
|
|
|
void DrawSprite(Sprite *sprite){
|
|
|
|
if(sprite->selected){
|
|
DrawTexture(*sprite->texture, sprite->x, sprite->y, BLACK);
|
|
}
|
|
else{
|
|
DrawTexture(*sprite->texture, sprite->x, sprite->y, WHITE);
|
|
}
|
|
}
|
|
|
|
void DrawAllSpritesInList(List *list){
|
|
Node *current = list->head;
|
|
|
|
while(current != 0){
|
|
if(current->data.selected){
|
|
DrawTexture(current->data.texture, current->data.x, current->data.y, BLACK);
|
|
}
|
|
else{
|
|
DrawTexture(current->data.texture, current->data.x, current->data.y, WHITE);
|
|
}
|
|
current = current->next;
|
|
}
|
|
}
|
|
|
|
Sprite * SpriteCreate(Texture2D *texture, int x, int y){
|
|
Sprite newSprite = (Sprite *) malloc(sizeof(Sprite));
|
|
|
|
newSprite->texture = texture;
|
|
newSprite->x = x;
|
|
newSprite->y = y;
|
|
newSprite->destX = x;
|
|
newSprite->destY = y;
|
|
newSprite->hasDestination = 0;
|
|
newSprite->selected = 0;
|
|
|
|
return newSprite;
|
|
}
|