|
|
|
@ -8,7 +8,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
Node * ListCreateNode(Sprite *data){
|
|
|
|
Node * ListCreateNode(Sprite *data){
|
|
|
|
Node *new = (Node *) malloc(sizeof(Node));
|
|
|
|
Node *new = (Node *) malloc(sizeof(Node));
|
|
|
|
new->data = *data;
|
|
|
|
new->data = data;
|
|
|
|
new->next = 0;
|
|
|
|
new->next = 0;
|
|
|
|
new->prev = 0;
|
|
|
|
new->prev = 0;
|
|
|
|
return new;
|
|
|
|
return new;
|
|
|
|
@ -75,7 +75,7 @@ void ListInsertSorted(List *list, Sprite *data){
|
|
|
|
inserted = 0;
|
|
|
|
inserted = 0;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(data->y <= current->data.y){
|
|
|
|
else if(data->y <= current->data->y){
|
|
|
|
if(current == list->head){
|
|
|
|
if(current == list->head){
|
|
|
|
free(new);
|
|
|
|
free(new);
|
|
|
|
ListInsertFront(list, data);
|
|
|
|
ListInsertFront(list, data);
|
|
|
|
@ -124,11 +124,11 @@ void ListDrawAllSprites(List *list, IsometricMap **map, Camera2D *camera){
|
|
|
|
// drawing some extra corner pixels
|
|
|
|
// drawing some extra corner pixels
|
|
|
|
// if extraPixels == 0 you can see flickering in the corners
|
|
|
|
// if extraPixels == 0 you can see flickering in the corners
|
|
|
|
// Only drawing the Sprites which are within Camera view
|
|
|
|
// Only drawing the Sprites which are within Camera view
|
|
|
|
if( current->data.x > itmp &&
|
|
|
|
if( current->data->x > itmp &&
|
|
|
|
current->data.y > jtmp &&
|
|
|
|
current->data->y > jtmp &&
|
|
|
|
current->data.x < maxI &&
|
|
|
|
current->data->x < maxI &&
|
|
|
|
current->data.y < maxJ){
|
|
|
|
current->data->y < maxJ){
|
|
|
|
DrawSpriteToWorld(¤t->data, map, camera);
|
|
|
|
DrawSpriteToWorld(current->data, map, camera);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current = current->next;
|
|
|
|
current = current->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -144,21 +144,21 @@ void ListActAllSprites(Game *game){
|
|
|
|
int counter = 0;
|
|
|
|
int counter = 0;
|
|
|
|
while (current != 0){
|
|
|
|
while (current != 0){
|
|
|
|
counter ++;
|
|
|
|
counter ++;
|
|
|
|
if(current->data.hasDestination == 1){
|
|
|
|
if(current->data->hasDestination == 1){
|
|
|
|
Vector2 movement = {
|
|
|
|
Vector2 movement = {
|
|
|
|
current->data.destX - current->data.x,
|
|
|
|
current->data->destX - current->data->x,
|
|
|
|
current->data.destY - current->data.y
|
|
|
|
current->data->destY - current->data->y
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if(Vector2Length(movement) < movementSpeed){
|
|
|
|
if(Vector2Length(movement) < movementSpeed){
|
|
|
|
current->data.hasDestination = 0;
|
|
|
|
current->data->hasDestination = 0;
|
|
|
|
current->data.x = current->data.destX;
|
|
|
|
current->data->x = current->data->destX;
|
|
|
|
current->data.y = current->data.destY;
|
|
|
|
current->data->y = current->data->destY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
movement = Vector2Normalize(movement);
|
|
|
|
movement = Vector2Normalize(movement);
|
|
|
|
movement = Vector2Scale(movement, movementSpeed);
|
|
|
|
movement = Vector2Scale(movement, movementSpeed);
|
|
|
|
current->data.x += movement.x;
|
|
|
|
current->data->x += movement.x;
|
|
|
|
current->data.y += movement.y;
|
|
|
|
current->data->y += movement.y;
|
|
|
|
|
|
|
|
|
|
|
|
// Change sprite according to direction
|
|
|
|
// Change sprite according to direction
|
|
|
|
Vector2 nullvektor = {0,0};
|
|
|
|
Vector2 nullvektor = {0,0};
|
|
|
|
@ -168,46 +168,46 @@ void ListActAllSprites(Game *game){
|
|
|
|
|
|
|
|
|
|
|
|
if(angle <= 22.5 && angle >= -22.5){
|
|
|
|
if(angle <= 22.5 && angle >= -22.5){
|
|
|
|
// E
|
|
|
|
// E
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, E);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, E);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(angle > 0 && angle <= 67.5){
|
|
|
|
else if(angle > 0 && angle <= 67.5){
|
|
|
|
// NE
|
|
|
|
// NE
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, NE);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, NE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(angle > 0 && angle <= 112.5){
|
|
|
|
else if(angle > 0 && angle <= 112.5){
|
|
|
|
// N
|
|
|
|
// N
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, N);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, N);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(angle > 0 && angle <= 157.5){
|
|
|
|
else if(angle > 0 && angle <= 157.5){
|
|
|
|
// NW
|
|
|
|
// NW
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, NW);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, NW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(angle < 0 && angle >= -67.5){
|
|
|
|
else if(angle < 0 && angle >= -67.5){
|
|
|
|
// SE
|
|
|
|
// SE
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, SE);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, SE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(angle < 0 && angle >= -112.5){
|
|
|
|
else if(angle < 0 && angle >= -112.5){
|
|
|
|
// S
|
|
|
|
// S
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, S);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, S);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(angle < 0 && angle >= -157.5){
|
|
|
|
else if(angle < 0 && angle >= -157.5){
|
|
|
|
// SW
|
|
|
|
// SW
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, SW);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, SW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
// W
|
|
|
|
// W
|
|
|
|
AnimationChangeAnimation(current->data.animationHandler, W);
|
|
|
|
AnimationChangeAnimation(current->data->animationHandler, W);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SpriteUpdateAnimation(¤t->data);
|
|
|
|
SpriteUpdateAnimation(current->data);
|
|
|
|
// updating z-position according to the tile the sprite stands on
|
|
|
|
// updating z-position according to the tile the sprite stands on
|
|
|
|
Tile *floorTile = IsometricMapGetTileFromWorldCoordinates(game->layers, current->data.x, current->data.y, 0);
|
|
|
|
Tile *floorTile = IsometricMapGetTileFromWorldCoordinates(game->layers, current->data->x, current->data->y, 0);
|
|
|
|
Tile *topTile = IsometricMapGetMostUpperTile(game->layers, floorTile);
|
|
|
|
Tile *topTile = IsometricMapGetMostUpperTile(game->layers, floorTile);
|
|
|
|
current->data.z = topTile->z;
|
|
|
|
current->data->z = topTile->z;
|
|
|
|
|
|
|
|
|
|
|
|
current = current->next;
|
|
|
|
current = current->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|