Commit f947697f authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Fix merge

parents 9ac45b6c 33cd918d
901
\ No newline at end of file
901
324
\ No newline at end of file
260
......@@ -10,7 +10,6 @@ gcc src/*.c -Wall -o temp -l curses
./temp
rm temp
xdotool key Ctrl+plus
xdotool key Ctrl+plus
xdotool key Ctrl+0
export TERM=a
24 15 150
4 50 150
912 728 636
0 0 0
324 244 0
......@@ -9,19 +9,24 @@
1000 1000 1000
0000000000000000000000000000000000000000
1111111111111111111111111111111111111111
1522222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222000222220002222200022222000222221
1222222000222220002222200022222000222221
122222207M2222207M2222207M2222207M222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222000222220002222200022222000222221
1222222000222220002222200022222000222221
1222222070222220702222207022222070222221
1222222222222222222222222222222222222221
122222207M2222207M2222207M2222207M222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222221
1222222222222222222222222222222222222224
1111111111111111111111111111111111111111
75 05 150
1000 724 1000
0 0 0
412 228 136
1000 988 0
620 324 660
420 124 460
620 324 660
1000 1000 1000
0000000000000000000000000000000000000000
1111111111111111111111111111111111111111
1777667767762666676772776776777766767661
1766777666767766666676672767666676776671
1776666666767766266676677767626676667761
1667677666666766777227766767766767726671
1667677666666766727676666767676677667671
1777667672776776677766767666276776676671
1666667667777226667677267677626677777761
17677wzwzwzw2zwzwz7666676zwzwzw2zwzwzw61
17277z00000000000w6776667w00000000000z61
17676w05400000000z6776667z00000000000w61
17667z00000000000w6266776w00000000000w61
17667w00000000000z7777676z00000000000z71
16777z00000000000w7667276w00000000000w71
16666w00000000000z7667766z00000000000z61
17677z00000000000wzwzwzwzw00000000000w61
17677w0000000000000000000000000000000z61
16667z00000000000z2676676w00000000000w61
16667w00000000000w7726767z00000000000z61
17766z00000000000z6667677w00000000000w61
17722wzwzwzwzwzwzw7666777zwzwzwzwzwzwz71
1111111111111111111111111111111111111111
......@@ -24,4 +24,10 @@ typedef struct {
int last;
} menu;
typedef struct firefly {
int x, y;
int dir;
struct firefly *next;
} firefly;
#endif
#include "firefly.h"
void updateFirefly(map *m, firefly *first) {
firefly *aux = first;
int i, j;
while (aux != NULL) {
i = aux->x;
j = aux->y;
switch (aux->dir) {
case(8):
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
}
break;
case(4):
if (m->grid[i][j+1] == '0'){
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
}
break;
case(6):
if (m->grid[i][j-1] == '0'){
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
} else if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
}
break;
case(2):
if (m->grid[i+1][j] == '0'){
m->grid[i+1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 6;
} else if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'M';
m->grid[i][j] = '0';
aux->dir = 2;
} else if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'M';
m->grid[i][j] = '0';
aux->dir = 4;
} else if (m->grid[i][j-1] == '0') {
m->grid[i][j-1] = 'M';
m->grid[i][j] = '0';
aux->dir = 8;
}
break;
}
aux = aux->next;
}
}
#ifndef _FIREFLY_H
#define _FIREFLY_H
#include "utils.h"
#include "entity.h"
void updateFirefly(map *m, firefly *first);
#endif
......@@ -44,7 +44,6 @@ void run(int ismenu, int running) {
}
}
int getInput() {
int input = getch();
if (input != ERR) {
......
......@@ -18,12 +18,13 @@ char butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char explosion[3][6] = {" ", " ## ", " "};
char explosion2[3][6] = {"\\\\||//", "--##--", "//||\\\\"};
char explosion3[3][6] = {"#%$@%@", "#@ ##", "&@*@*#"};
char mapfile[3][100] = {"./sprites/map1.txt", "./sprites/map2.txt", "./sprites/map3.txt"};
char mapfile[5][100] = {"./sprites/map1.txt", "./sprites/map2.txt", "./sprites/map3.txt", "./sprites/map4.txt", "./sprites/map5.txt"};
int colors[8][3];
char input[WIDTH];
rockford player;
firefly *firstff, *auxff;
int alter;
int dead;
int offy, offx;
......@@ -35,6 +36,8 @@ int hold;
int extx, exty;
int pushdelay;
int highscore;
int fireflyblink;
int nff;
FILE *lastscorefile;
FILE *highscorefile;
......@@ -65,6 +68,19 @@ void readFileMap(map *m, int mapn, int pscore) {
} else if (input[j] == '4') {
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;
}
nff++;
}
m->grid[j][i] = input[j];
}
......@@ -217,6 +233,8 @@ void updateMap(map *m, int action, int *ismenu) {
void renderMap(map *m, int time) {
int i, j, k, l;
if (!(time % 4))
updateFirefly(m, firstff);
m->grid[3][0] = ((m->diamonds / 10) % 10) + 'A';
m->grid[4][0] = (m->diamonds % 10) + 'A';
......@@ -251,6 +269,8 @@ void renderMap(map *m, int time) {
if (lightning)
hold++;
if (!(time % 2))
fireflyblink = (fireflyblink + 1) % 3;
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
......@@ -308,13 +328,16 @@ void renderMap(map *m, int time) {
}
break;
case('6'):
if (m->grid[i][j+1] == '0')
m->grid[i][j] = 'f';
if ((m->grid[i][j+1] == '6' || m->grid[i][j+1] == 'w' || m->grid[i][j+1] == 'z') && m->grid[i+1][j] == '0' && m->grid[i+1][j+1] == '0')
if ((m->grid[i][j+1] == '6' || m->grid[i][j+1] == 'w' || m->grid[i][j+1] == 'z' || m->grid[i][j+1] == '7')
&& m->grid[i+1][j] == '0' && m->grid[i+1][j+1] == '0')
m->grid[i][j] = 'r';
if ((m->grid[i][j+1] == '6' || m->grid[i][j+1] == 'w' || m->grid[i][j+1] == 'z') && m->grid[i-1][j] == '0' && m->grid[i-1][j+1] == '0')
else if ((m->grid[i][j+1] == '6' || m->grid[i][j+1] == 'w' || m->grid[i][j+1] == 'z' || m->grid[i][j+1] == '7')
&& m->grid[i-1][j] == '0' && m->grid[i-1][j+1] == '0')
m->grid[i][j] = 'l';
if (m->grid[i][j+1] == '0')
m->grid[i][j] = 'f';
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (!((k == 0 || k == 2) && (l == 0 || l == 5))) {
......@@ -330,6 +353,13 @@ void renderMap(map *m, int time) {
}
break;
case('7'):
if ((m->grid[i][j+1] == '6' || m->grid[i][j+1] == 'w' || m->grid[i][j+1] == 'z' || m->grid[i][j+1] == '7')
&& m->grid[i-1][j] == '0' && m->grid[i-1][j+1] == '0')
m->grid[i][j] = 'L';
else if ((m->grid[i][j+1] == '6' || m->grid[i][j+1] == 'w' || m->grid[i][j+1] == 'z' || m->grid[i][j+1] == '7')
&& m->grid[i+1][j] == '0' && m->grid[i+1][j+1] == '0')
m->grid[i][j] = 'R';
if (m->grid[i][j+1] == '0')
m->grid[i][j] = 'h';
......@@ -362,7 +392,7 @@ void renderMap(map *m, int time) {
m->grid[i][j+1] = 'f';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '5') {
m->grid[i][j+1] = 'f';
m->grid[i][j+1] = '0';
m->grid[i][j] = '0';
dead = true;
} else
......@@ -440,6 +470,52 @@ void renderMap(map *m, int time) {
m->grid[i][j] = '0';
}
}
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 (waittime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'h';
m->grid[i][j] = '0';
}
}
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 (waittime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'h';
m->grid[i][j] = '0';
}
}
break;
case('A'):
renderChar(zero, i, j, offx, offy, (i == 3 || i == 4 || i == 12 || i == 13) ? 2 : 11);
......@@ -474,6 +550,139 @@ void renderMap(map *m, int time) {
case('K'):
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));
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] = '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;*/
}
}
......
......@@ -4,6 +4,7 @@
#include "utils.h"
#include "entity.h"
#include "rockford.h"
#include "firefly.h"
void readFileMap(map *m, int mapn, int pscore);
void setColors();
......
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