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

Adicionado a barra superior

parent b3b87589
000BCKBA0000AA00000000000BFA000AAAAAA000
1111111111111111111111111111111111111111
1222222022726022222626222222202222622221
1265622222202222222226722622220222220221
......
......@@ -5,11 +5,14 @@ typedef struct {
int x, y;
int dir;
int diamonds;
int score;
} rockford;
typedef struct {
FILE *sprite;
char grid[WIDTH][HEIGHT];
int score;
int diamonds;
} map;
#endif
......@@ -18,16 +18,54 @@ char butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char explosion[3][6] = {" ", " ## ", " "};
char explosion2[3][6] = {"\\\\||//", "--##--", "//||\\\\"};
char explosion3[3][6] = {"#%$@%@", "#@ ##", "&@*@*#"};
char one[3][6] = {" ",
" -| ",
" _|_ "};
char two[3][6] = {" __ ",
" __] ",
" |__ "};
char three[3][6] = {" __ ",
" __] ",
" __] "};
char four[3][6] = {" ",
" /_| ",
" | "};
char five[3][6] = {" __ ",
" |__ ",
" __] "};
char six[3][6] = {" __ ",
" |__ ",
" [__] "};
char seven[3][6] = {" ___ ",
" / ",
" / "};
char eight[3][6] = {" __ ",
" [__] ",
" [__] "};
char nine[3][6] = {" __ ",
" [__] ",
" _/ "};
char zero[3][6] = {" __ ",
" | | ",
" |__| "};
char symbol[3][6] = {" ",
" /##\\ ",
" \\##/ "};
char input[WIDTH];
rockford player;
int alter;
int dead;
int offy, offx;
int row, col;
int t;
int s = 0;
void readFileMap(map *m) {
int i, j;
m->score = 10;
m->diamonds = 12;
m->sprite = fopen("./sprites/map1.txt", "r");
for (i = 0; i < HEIGHT; i++) {
fscanf(m->sprite, "%s", input);
......@@ -36,20 +74,23 @@ void readFileMap(map *m) {
player.x = i;
player.y = j;
player.dir = 5;
player.diamonds = 0;
player.score = 0;
dead = 0;
t = 150;
s = 0;
}
m->grid[j][i] = input[j];
}
}
getmaxyx(stdscr, row, col);
offy = row / 2 - 11*3;
offy = row / 2 - 12*3;
offx = col / 2 - 20*6;
start_color();
init_color(COLOR_WHITE, 650, 650, 650);
init_color(COLOR_BLACK, 0, 0, 0);
init_color(COLOR_RED, 412, 228, 136);
init_color(COLOR_YELLOW, 980, 888, 716);
init_color(COLOR_YELLOW, 1000, 988, 0);
init_color(COLOR_GREEN, 400, 400, 400);
init_color(COLOR_BLUE, 200, 200, 200);
init_color(COLOR_MAGENTA, 600, 0, 600);
......@@ -60,7 +101,7 @@ void readFileMap(map *m) {
// rock gray color 3
init_pair(10, COLOR_BLACK, COLOR_BLUE);
// rock yellow color 2
init_pair(8, COLOR_BLACK, COLOR_YELLOW);
init_pair(8, COLOR_BLACK, COLOR_WHITE);
// rock gray color 2
init_pair(3, COLOR_BLACK, COLOR_GREEN);
......@@ -76,14 +117,19 @@ void readFileMap(map *m) {
//explosion color
init_pair(9, COLOR_WHITE, COLOR_BLACK);
//number color
init_pair(2, COLOR_YELLOW, COLOR_BLACK);
fclose(m->sprite);
}
void updateMap(map *m, int action) {
player.dir = action;
if (!dead)
if (!dead) {
updateRockford(&player, m, action);
else {
if (t == 0)
dead = true;
} else {
s++;
if (s < 21) {
m->grid[player.y-1][player.x-1] = 'x';
......@@ -108,11 +154,37 @@ void updateMap(map *m, int action) {
} else if (s > 100)
readFileMap(m);
}
if (player.diamonds >= m->diamonds)
m->score = 15;
}
void renderMap(map *m, int time) {
int i, j, k, l;
alter = 0;
m->grid[3][0] = ((m->diamonds / 10) % 10) + 'A';
m->grid[4][0] = (m->diamonds % 10) + 'A';
m->grid[6][0] = ((m->score / 10) % 10) + 'A';
m->grid[7][0] = (m->score % 10) + 'A';
m->grid[12][0] = ((player.diamonds / 10) % 10) + 'A';
m->grid[13][0] = (player.diamonds % 10) + 'A';
m->grid[25][0] = (t / 100) + 'A';
m->grid[26][0] = ((t / 10) % 10) + 'A';
m->grid[27][0] = (t % 10) + 'A';
m->grid[31][0] = ((player.score / 100000) % 10) + 'A';
m->grid[32][0] = ((player.score / 10000) % 10) + 'A';
m->grid[33][0] = ((player.score / 1000) % 10) + 'A';
m->grid[34][0] = ((player.score / 100) % 10) + 'A';
m->grid[35][0] = ((player.score / 10) % 10) + 'A';
m->grid[36][0] = (player.score % 10) + 'A';
if (time == 29)
if (t != 0) t--;
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
if (!dead) s = (s + 1) % 7;
......@@ -121,7 +193,7 @@ void renderMap(map *m, int time) {
attron(COLOR_PAIR(5));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (j == 0 || j == 21)
if (j == 1 || j == 22)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", steel[k][l]);
else
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", steel2[k][l]);
......@@ -157,14 +229,13 @@ void renderMap(map *m, int time) {
case('5'):
attron(COLOR_PAIR(6));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
for (l = 0; l < 6; l++)
if (player.dir == 0 || player.dir == 5)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", rockf[k][l]);
else if (player.dir == 6 || player.dir == 8)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", rockfr[k][l]);
else if (player.dir == 4 || player.dir == 2)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", rockfl[k][l]);
}
attroff(COLOR_PAIR(6));
break;
case('6'):
......@@ -176,7 +247,7 @@ void renderMap(map *m, int time) {
m->grid[i][j] = 'l';
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
for (l = 0; l < 6; l++)
if (!((k == 0 || k == 2) && (l == 0 || l == 5))) {
if (k == 0 && (l == 3 || l == 4)) {
attron(COLOR_PAIR(8));
......@@ -188,7 +259,6 @@ void renderMap(map *m, int time) {
attroff(COLOR_PAIR(3));
}
}
}
break;
case('7'):
if (m->grid[i][j+1] == '0')
......@@ -211,7 +281,7 @@ void renderMap(map *m, int time) {
break;
case('f'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
for (l = 0; l < 6; l++)
if (!((k == 0 || k == 2) && (l == 0 || l == 5))) {
if (k == 0 && (l == 3 || l == 4)) {
attron(COLOR_PAIR(8));
......@@ -223,7 +293,6 @@ void renderMap(map *m, int time) {
attroff(COLOR_PAIR(3));
}
}
}
if (s == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'f';
......@@ -316,6 +385,143 @@ void renderMap(map *m, int time) {
}
}
break;
case('A'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", zero[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", zero[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('B'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", one[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", one[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('C'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", two[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", two[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('D'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", three[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", three[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('E'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", four[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", four[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('F'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", five[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", five[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('G'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", six[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", six[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('H'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", seven[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", seven[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('I'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", eight[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", eight[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('J'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (i == 3 || i == 4 || i == 12 || i == 13) {
attron(COLOR_PAIR(2));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", nine[k][l]);
attroff(COLOR_PAIR(2));
} else {
attron(COLOR_PAIR(9));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", nine[k][l]);
attroff(COLOR_PAIR(9));
}
break;
case('K'):
attron(COLOR_PAIR(9));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", symbol[k][l]);
attroff(COLOR_PAIR(9));
break;
}
......
......@@ -10,6 +10,7 @@ void updateRockford(rockford *player, map *m, int action) {
m->grid[player->y][player->x--] = '0';
m->grid[player->y][player->x] = '5';
player->diamonds++;
player->score += m->score;
}
} else if (action == 6) {
char right = m->grid[player->y+1][player->x];
......@@ -20,6 +21,7 @@ void updateRockford(rockford *player, map *m, int action) {
m->grid[player->y++][player->x] = '0';
m->grid[player->y][player->x] = '5';
player->diamonds++;
player->score += m->score;
}
} else if (action == 4) {
char left = m->grid[player->y-1][player->x];
......@@ -30,6 +32,7 @@ void updateRockford(rockford *player, map *m, int action) {
m->grid[player->y--][player->x] = '0';
m->grid[player->y][player->x] = '5';
player->diamonds++;
player->score += m->score;
}
} else if (action == 2) {
char down = m->grid[player->y][player->x+1];
......@@ -40,6 +43,7 @@ void updateRockford(rockford *player, map *m, int action) {
m->grid[player->y][player->x++] = '0';
m->grid[player->y][player->x] = '5';
player->diamonds++;
player->score += m->score;
}
}
}
......
......@@ -6,7 +6,7 @@
#include <unistd.h>
#define WIDTH 40
#define HEIGHT 22
#define HEIGHT 23
#define true 1
#define false 0
......
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