Commit 576a7d15 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Adicionado cores ao arquivo mapa

parent 68f58055
650 650 650
0 0 0
412 228 136
1000 988 0
400 400 400
200 200 200
600 0 600
000BCKBA0000AA00000000000BFA000AAAAAA000
1111111111111111111111111111111111111111
1222222022726022222626222222202222622221
......
......@@ -6,69 +6,53 @@ char dirt[3][6] = {"-_-_-_", "_-_-_-", "-_-_-_"};
char wall[3][6] = {"|_|_|_", "_|_|_|", "|_|_|_"};
char wall2[3][6] = {"_|_|_|", "|_|_|_", "_|_|_|"};
char ext[3][6] = {" @ @ ", " ", " @ @ "};
char rockf[3][6] = {" (**) ", " /EE\\ ", " II "};
char rockfr[3][6] = {" ( *} ", " EE\\ ", " /; "};
char rockfl[3][6] = {" {* ) ", " /EE ", " ;\\ "};
char bould[3][6] = {" (@*) ", "( #@#)", " (_*) "};
char diamond[3][6] = {" / \\ ", "| |", " \\==/ "};
char diamond2[3][6] = {" / \\ ", "|====|", " \\ / "};
char diamond3[3][6] = {" /==\\ ", "| |", " \\ / "};
char butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char explosion[3][6] = {" ", " ## ", " "};
char ext[3][6] = {" @ @ ", " ", " @ @ "};
char rockf[3][6] = {" (**) ", " /EE\\ ", " II "};
char rockfr[3][6] = {" ( *} ", " EE\\ ", " /; "};
char rockfl[3][6] = {" {* ) ", " /EE ", " ;\\ "};
char bould[3][6] = {" (@*) ", "( #@#)", " (_*) "};
char diamond[3][6] = {" / \\ ", "| |", " \\==/ "};
char diamond2[3][6] = {" / \\ ", "|====|", " \\ / "};
char diamond3[3][6] = {" /==\\ ", "| |", " \\ / "};
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 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] = {" ", " /##\\ ", " \\##/ "};
int colors[7][3];
char input[WIDTH];
rockford player;
int alter;
int dead;
int offy, offx;
int row, col;
int t, s;
int leveltime, waittime;
void readFileMap(map *m) {
int i, j;
t = 150;
s = 0;
leveltime = 150;
waittime = 0;
m->score = 10;
m->diamonds = 12;
m->sprite = fopen("./sprites/map1.txt", "r");
for (i = 0; i < 7; i++)
for (j = 0; j < 3; j++)
fscanf(m->sprite, "%d", &colors[i][j]);
for (i = 0; i < HEIGHT; i++) {
fscanf(m->sprite, "%s", input);
for (j = 0; j < WIDTH; j++) {
......@@ -84,6 +68,7 @@ void readFileMap(map *m) {
}
}
fclose(m->sprite);
setColors();
getmaxyx(stdscr, row, col);
offy = (row / 2) - (12 * 3);
......@@ -91,13 +76,13 @@ void readFileMap(map *m) {
}
void setColors() {
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, 1000, 988, 0);
init_color(COLOR_GREEN, 400, 400, 400);
init_color(COLOR_BLUE, 200, 200, 200);
init_color(COLOR_MAGENTA, 600, 0, 600);
init_color(COLOR_WHITE, colors[0][0], colors[0][1], colors[0][2]);
init_color(COLOR_BLACK, colors[1][0], colors[1][1], colors[1][2]);
init_color(COLOR_RED, colors[2][0], colors[2][1], colors[2][2]);
init_color(COLOR_YELLOW, colors[3][0], colors[3][1], colors[3][2]);
init_color(COLOR_GREEN, colors[4][0], colors[4][1], colors[4][2]);
init_color(COLOR_BLUE, colors[5][0], colors[5][1], colors[5][2]);
init_color(COLOR_MAGENTA, colors[6][0], colors[6][1], colors[6][2]);
// dirt color
init_pair(1, COLOR_BLACK, COLOR_RED);
......@@ -138,11 +123,11 @@ void updateMap(map *m, int action) {
if (!dead) {
updateRockford(&player, m, action);
if (t == 0)
if (leveltime == 0)
dead = true;
} else {
s++;
if (s < 21) {
waittime++;
if (waittime < 21) {
m->grid[player.y-1][player.x-1] = 'x';
m->grid[player.y][player.x-1] = 'x';
m->grid[player.y+1][player.x-1] = 'x';
......@@ -152,7 +137,7 @@ void updateMap(map *m, int action) {
m->grid[player.y-1][player.x+1] = 'x';
m->grid[player.y][player.x+1] = 'x';
m->grid[player.y+1][player.x+1] = 'x';
} else if (s <= 100) {
} else if (waittime <= 100) {
m->grid[player.y-1][player.x-1] = '0';
m->grid[player.y][player.x-1] = '0';
m->grid[player.y+1][player.x-1] = '0';
......@@ -162,7 +147,7 @@ void updateMap(map *m, int action) {
m->grid[player.y-1][player.x+1] = '0';
m->grid[player.y][player.x+1] = '0';
m->grid[player.y+1][player.x+1] = '0';
} else if (s > 100)
} else if (waittime > 100)
readFileMap(m);
}
}
......@@ -180,9 +165,9 @@ void renderMap(map *m, int time) {
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[25][0] = (leveltime / 100) + 'A';
m->grid[26][0] = ((leveltime / 10) % 10) + 'A';
m->grid[27][0] = (leveltime % 10) + 'A';
m->grid[31][0] = ((player.score / 100000) % 10) + 'A';
m->grid[32][0] = ((player.score / 10000) % 10) + 'A';
......@@ -192,11 +177,12 @@ void renderMap(map *m, int time) {
m->grid[36][0] = (player.score % 10) + 'A';
if (time == 29)
if (t != 0) t--;
if (leveltime != 0) leveltime--;
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
if (!dead) s = (s + 1) % 7;
if (!dead)
waittime = (waittime + 1) % 7;
switch (m->grid[i][j]) {
case('1'):
attron(COLOR_PAIR(5));
......@@ -302,7 +288,7 @@ void renderMap(map *m, int time) {
attroff(COLOR_PAIR(3));
}
}
if (s == 6) {
if (waittime == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'f';
m->grid[i][j] = '0';
......@@ -326,7 +312,7 @@ void renderMap(map *m, int time) {
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond3[k][l]);
attroff(COLOR_PAIR(7));
if (s == 6) {
if (waittime == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'h';
m->grid[i][j] = '0';
......@@ -342,9 +328,9 @@ void renderMap(map *m, int time) {
attron(COLOR_PAIR(9));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if(s < 7)
if(waittime < 7)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", explosion[k][l]);
else if(s < 14)
else if(waittime < 14)
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", explosion2[k][l]);
else
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", explosion3[k][l]);
......@@ -365,7 +351,7 @@ void renderMap(map *m, int time) {
}
}
}
if (s == 6) {
if (waittime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'f';
m->grid[i][j] = '0';
......@@ -387,7 +373,7 @@ void renderMap(map *m, int time) {
}
}
}
if (s == 6) {
if (waittime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'f';
m->grid[i][j] = '0';
......
......@@ -6,6 +6,7 @@
#include "rockford.h"
void readFileMap(map *m);
void setColors();
void updateMap(map *m, int action);
void renderMap(map *m, int time);
......
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