Commit 14474f66 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Adicionado movimento aos fireflies

parent f947697f
260
105
\ No newline at end of file
......@@ -16,17 +16,17 @@
1667677666666766727676666767676677667671
1777667672776776677766767666276776676671
1666667667777226667677267677626677777761
17677wzwzwzw2zwzwz7666676zwzwzw2zwzwzw61
17677wwwwwww2zzzzz7666676zzzzzz2wwwwww61
17277z00000000000w6776667w00000000000z61
17676w05400000000z6776667z00000000000w61
17667z00000000000w6266776w00000000000w61
17667w00000000000z7777676z00000000000z71
16777z00000000000w7667276w00000000000w71
16666w00000000000z7667766z00000000000z61
17677z00000000000wzwzwzwzw00000000000w61
17677z00000000000wwwwwwwww00000000000w61
17677w0000000000000000000000000000000z61
16667z00000000000z2676676w00000000000w61
16667w00000000000w7726767z00000000000z61
17766z00000000000z6667677w00000000000w61
17722wzwzwzwzwzwzw7666777zwzwzwzwzwzwz71
17722wwwwwwwwwwwww7666777zzzzzzzzzzzzz71
1111111111111111111111111111111111111111
......@@ -12,18 +12,22 @@ void updateFirefly(map *m, firefly *first) {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
aux->x--;
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
aux->y--;
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
aux->x++;
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
aux->y++;
}
break;
case(4):
......@@ -31,18 +35,22 @@ void updateFirefly(map *m, firefly *first) {
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
aux->y++;;
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
aux->x--;
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
aux->y--;
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
aux->x++;
}
break;
case(6):
......@@ -50,18 +58,22 @@ void updateFirefly(map *m, firefly *first) {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
aux->y--;
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
aux->x++;
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
aux->y++;
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
aux->x--;
}
break;
case(2):
......@@ -69,18 +81,22 @@ void updateFirefly(map *m, firefly *first) {
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
aux->x++;
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
aux->y++;
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
aux->x--;
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
aux->y--;
}
break;
}
......
......@@ -2,8 +2,8 @@
map level;
menu me;
int menuaction;
int load = false;
int menuaction = 0;
int load = true;
void run(int ismenu, int running) {
double last_time, current_time, delta = FPS;
......
......@@ -24,7 +24,7 @@ int colors[8][3];
char input[WIDTH];
rockford player;
firefly *firstff, *auxff;
firefly *firstff, *lastff;
int alter;
int dead;
int offy, offx;
......@@ -36,7 +36,7 @@ int hold;
int extx, exty;
int pushdelay;
int highscore;
int fireflyblink;
int blink1, blink2, blink3;
int nff;
FILE *lastscorefile;
FILE *highscorefile;
......@@ -44,7 +44,11 @@ FILE *highscorefile;
void readFileMap(map *m, int mapn, int pscore) {
int i, j;
done = lightning = false;
blink1 = 4;
blink2 = 5;
blink3 = 6;
hold = 0;
nff = 0;
pushdelay = 0;
mapnumber = mapn;
waittime = 0;
......@@ -55,6 +59,10 @@ void readFileMap(map *m, int mapn, int pscore) {
for (j = 0; j < 3; j++)
fscanf(m->sprite, "%d", &colors[i][j]);
firstff = (firefly*) malloc(sizeof(firefly));
lastff = firstff;
lastff->next = NULL;
for (i = 0; i < HEIGHT; i++) {
fscanf(m->sprite, "%s", input);
for (j = 0; j < WIDTH; j++) {
......@@ -69,17 +77,12 @@ void readFileMap(map *m, int mapn, int pscore) {
extx = i;
exty = j;
} else if (input[j] == 'M') {
if (!nff) {
firstff = (firefly*) malloc(sizeof(firefly));
firstff->x = j;
firstff->y = i;
auxff = firstff;
} else {
auxff->next = (firefly*) malloc(sizeof(firefly));
auxff->next->x = j;
auxff->next->y = i;
auxff = auxff->next;
}
lastff->next = (firefly*) malloc(sizeof(firefly));
lastff = lastff->next;
lastff->x = j;
lastff->y = i;
lastff->dir = 8;
lastff->next = NULL;
nff++;
}
m->grid[j][i] = input[j];
......@@ -233,7 +236,7 @@ void updateMap(map *m, int action, int *ismenu) {
void renderMap(map *m, int time) {
int i, j, k, l;
if (!(time % 4))
if (nff && !(time % 4))
updateFirefly(m, firstff);
m->grid[3][0] = ((m->diamonds / 10) % 10) + 'A';
......@@ -269,8 +272,11 @@ void renderMap(map *m, int time) {
if (lightning)
hold++;
if (!(time % 2))
fireflyblink = (fireflyblink + 1) % 3;
if (!(time % 3)) {
blink1 = (blink1 % 3) + 4;
blink2 = (blink2 % 3) + 4;
blink3 = (blink3 % 3) + 4;
}
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
......@@ -472,21 +478,13 @@ void renderMap(map *m, int time) {
}
break;
case('R'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
if (!((k == 0 || k == 2) && (l == 0 || l == 5))) {
attron(COLOR_PAIR(7));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (time < 10)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond[k][l]);
else if (time < 20)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond2[k][l]);
else
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond3[k][l]);
attroff(COLOR_PAIR(7));
}
}
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'h';
......@@ -495,21 +493,13 @@ void renderMap(map *m, int time) {
}
break;
case('L'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
if (!((k == 0 || k == 2) && (l == 0 || l == 5))) {
attron(COLOR_PAIR(7));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (time < 10)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond[k][l]);
else if (time < 20)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond2[k][l]);
else
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond3[k][l]);
attroff(COLOR_PAIR(7));
}
}
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'h';
......@@ -551,138 +541,23 @@ void renderMap(map *m, int time) {
renderChar(symbol, i, j, offx, offy, 11);
break;
case('M'):
/*if (!(time % 4)) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = '<';
m->grid[i][j] = '0';
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = '>';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'v';
m->grid[i][j] = '0';
}
}*/
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
if (k == 0 || k == 2 || l == 0 || l == 5) {
attron(COLOR_PAIR(4 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(4 + fireflyblink));
} else if (k == 1 && (l == 2 || l == 3)) {
attron(COLOR_PAIR(5 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(5 + fireflyblink));
} else {
attron(COLOR_PAIR(6 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(6 + fireflyblink));
}
}
break;
/*case('<'):
if (!(time % 4)) {
if (m->grid[i][j+1] == '0'){
m->grid[i][j+1] = 'v';
m->grid[i][j] = '0';
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = '<';
m->grid[i][j] = '0';
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = '>';
m->grid[i][j] = '0';
}
}
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
if (k == 0 || k == 2 || l == 0 || l == 5) {
attron(COLOR_PAIR(4 + fireflyblink));
attron(COLOR_PAIR(blink1));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(4 + fireflyblink));
attroff(COLOR_PAIR(blink1));
} else if (k == 1 && (l == 2 || l == 3)) {
attron(COLOR_PAIR(5 + fireflyblink));
attron(COLOR_PAIR(blink2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(5 + fireflyblink));
attroff(COLOR_PAIR(blink2));
} else {
attron(COLOR_PAIR(6 + fireflyblink));
attron(COLOR_PAIR(blink3));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(6 + fireflyblink));
attroff(COLOR_PAIR(blink3));
}
}
break;
case('>'):
if (!(time % 4)) {
if (m->grid[i][j-1] == '0'){
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = '>';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'v';
m->grid[i][j] = '0';
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = '<';
m->grid[i][j] = '0';
}
}
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
if (k == 0 || k == 2 || l == 0 || l == 5) {
attron(COLOR_PAIR(4 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(4 + fireflyblink));
} else if (k == 1 && (l == 2 || l == 3)) {
attron(COLOR_PAIR(5 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(5 + fireflyblink));
} else {
attron(COLOR_PAIR(6 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(6 + fireflyblink));
}
}
break;
case('v'):
if (!(time % 4)) {
if (m->grid[i+1][j] == '0'){
m->grid[i+1][j] = '>';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'v';
m->grid[i][j] = '0';
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = '<';
m->grid[i][j] = '0';
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
}
}
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
if (k == 0 || k == 2 || l == 0 || l == 5) {
attron(COLOR_PAIR(4 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(4 + fireflyblink));
} else if (k == 1 && (l == 2 || l == 3)) {
attron(COLOR_PAIR(5 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(5 + fireflyblink));
} else {
attron(COLOR_PAIR(6 + fireflyblink));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", empty[k][l]);
attroff(COLOR_PAIR(6 + fireflyblink));
}
}
break;*/
}
}
......
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