Commit 7131a7aa authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Alterado texturas e comportamento

parent 330bfad5
......@@ -4,7 +4,7 @@ map level;
void run(int running) {
double last_time, current_time, delta = FPS;
int sleep_time, action = 0;
int sleep_time, action = 0, s = 0;
last_time = getTime() / NANO;
readFileMap(&level);
......@@ -12,9 +12,10 @@ void run(int running) {
current_time = getTime() / NANO;
if (current_time >= last_time) {
last_time += delta;
render();
render(s);
update(action);
action = getInput();
s = (s + 1) % 30;
} else {
sleep_time = (int) ((last_time - current_time));
if (sleep_time > 0)
......@@ -47,8 +48,8 @@ void update(int action) {
updateMap(&level, action);
}
void render() {
void render(int time) {
erase();
renderMap(&level);
renderMap(&level, time);
refresh();
}
......@@ -7,6 +7,6 @@
void run(int running);
int getInput();
void update(int action);
void render();
void render(int time);
#endif
#include "maps.h"
char steel[3][6] = {" @ @ ", " ", " @ @ "};
char steel2[3][6] = {" ", " @ @ ", " "};
char dirt[3][6] = {"-_-_-_", "_-_-_-", "-_-_-_"};
char wall[3][6] = {"=-=-=-", "-=-=-=", "=-=-=-"};
//char wall[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 bould[3][6] = {" (@*) ", "( #@#)", " (_*) "};
char diamond[3][6] = {" / \\ ", "| |", " \\==/ "};
char diamond2[3][6] = {" / \\ ", "|====|", " \\ / "};
char diamond3[3][6] = {" /==\\ ", "| |", " \\ / "};
char butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char input[WIDTH];
rockford player;
int alter;
void readFileMap(map *m, char *path) {
int i, j;
......@@ -28,24 +35,24 @@ void readFileMap(map *m, char *path) {
}
}
start_color();
init_color(COLOR_WHITE, 700, 700, 700);
init_color(COLOR_WHITE, 650, 650, 650);
init_color(COLOR_BLACK, 0, 0, 0);
init_color(COLOR_RED, 556, 276, 76);
init_color(COLOR_RED, 412, 228, 136);
init_color(COLOR_YELLOW, 980, 888, 716);
init_color(COLOR_GREEN, 400, 400, 400);
init_color(COLOR_BLUE, 300, 300, 300);
init_color(COLOR_BLUE, 200, 200, 200);
init_color(COLOR_MAGENTA, 600, 0, 600);
// dirt color
init_pair(1, COLOR_BLACK, COLOR_RED);
// rock yellow color 1
init_pair(2, COLOR_YELLOW, COLOR_BLACK);
// rock gray color 1
init_pair(3, COLOR_BLACK, COLOR_GREEN);
// rock gray color 3
init_pair(10, COLOR_BLACK, COLOR_BLUE);
// rock yellow color 2
init_pair(8, COLOR_BLACK, COLOR_YELLOW);
// rock gray color 2
init_pair(9, COLOR_BLACK, COLOR_GREEN);
init_pair(3, COLOR_BLACK, COLOR_GREEN);
// wall color
init_pair(4, COLOR_BLACK, COLOR_WHITE);
// steel color
......@@ -64,9 +71,9 @@ void updateMap(map *m, int action) {
mvprintw(0, 0, "%d", action);
}
void renderMap(map *m) {
void renderMap(map *m, int time) {
int i, j, k, l;
//updateRockford(&player, m, 6);
alter = 0;
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
switch (m->grid[i][j]) {
......@@ -74,7 +81,10 @@ void renderMap(map *m) {
attron(COLOR_PAIR(5));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", steel[k][l]);
if (j == 0 || j == 21)
mvprintw(3*j+k+1, 6*i+l+1, "%c", steel[k][l]);
else
mvprintw(3*j+k+1, 6*i+l+1, "%c", steel2[k][l]);
attroff(COLOR_PAIR(5));
break;
case('2'):
......@@ -88,7 +98,13 @@ void renderMap(map *m) {
attron(COLOR_PAIR(4));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", wall[k][l]);
if (alter)
mvprintw(3*j+k+1, 6*i+l+1, "%c", wall[k][l]);
else
mvprintw(3*j+k+1, 6*i+l+1, "%c", wall2[k][l]);
if (i < 9 || i > 30)
alter = (alter + 1) % 2;
alter = alter ? 0 : 1;
attroff(COLOR_PAIR(4));
break;
case('4'):
......@@ -123,14 +139,19 @@ void renderMap(map *m) {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+1, 6*i+l+1, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
}
break;
case('7'):
attron(COLOR_PAIR(7));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond[k][l]);
if (time < 10)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond[k][l]);
else if (time < 20)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond2[k][l]);
else
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond3[k][l]);
attroff(COLOR_PAIR(7));
break;
case('8'):
......@@ -142,4 +163,5 @@ void renderMap(map *m) {
}
}
alter = 0;
}
......@@ -6,6 +6,6 @@
void readFileMap();
void updateMap(map *m, int action);
void renderMap(map *m);
void renderMap(map *m, int time);
#endif
......@@ -3,7 +3,7 @@
#include "utils.h"
#include <sys/time.h>
#define NANO 1000000000.0
#define FPS 1.0/24.0
#define FPS 1.0/30.0
double getTime();
......
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