Commit 9442217e authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Fireflies funcionando

parent 74264705
319
\ No newline at end of file
564
\ No newline at end of file
#include "firefly.h"
void updateFirefly(map *m, firefly *first, int *dead, int waittime) {
void updateFirefly(map *m, firefly *first, int *dead) {
firefly *aux = first->next;
int i, j, k, l, n, o;
int i, j, k, l;
while (aux != NULL) {
if (aux->dead) {
for (n = -1; n <= 1; n++) {
for (o = -1; o <= 1; o++) {
if (waittime < 21 && m->grid[i+n][j+o] != '1')
m->grid[i+n][j+o] = 'x';
else if (waittime <= 100 && m->grid[i+n][j+o] != '1')
m->grid[i+n][j+o] = '0';
}
}
} else {
i = aux->x;
j = aux->y;
i = aux->x;
j = aux->y;
if (!aux->dead) {
for (k = -1; k <= 1; k++) {
for (l = -1; l <= 1; l++) {
if (m->grid[i+k][j+l] == '5') {
*dead = true;
aux->dead = true;
m->grid[i][j] = '0';
}
}
}
......@@ -118,7 +110,7 @@ void updateFirefly(map *m, firefly *first, int *dead, int waittime) {
}
break;
}
aux = aux->next;
}
aux = aux->next;
}
}
......@@ -3,6 +3,6 @@
#include "utils.h"
#include "entity.h"
void updateFirefly(map *m, firefly *first, int *dead, int waittime);
void updateFirefly(map *m, firefly *first, int *dead);
#endif
......@@ -279,7 +279,7 @@ void renderMap(map *m, int time) {
}
if (nff && !(time % 6))
updateFirefly(m, firstff, &dead, waittime);
updateFirefly(m, firstff, &dead);
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
......
......@@ -42,7 +42,7 @@ void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time,
m->grid[i][j+1] = 'h';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '5') {
m->grid[i][j+1] = 'h';
m->grid[i][j+1] = '0';
m->grid[i][j] = '0';
*dead = true;
} else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment