Commit 330bfad5 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Mudado a textura

parent 10ed6dd2
#!/bin/bash
a=`echo $TERM`
export TERM=xterm-256color
gcc src/*.c -Wall -o temp -l curses
./temp
rm temp
export TERM=a
......@@ -23,29 +23,24 @@ void run(int running) {
}
}
int getInput() {
int n;
int input = getch();
if (input != ERR) {
switch (input) {
case KEY_UP:
n = 8;
break;
return 8;
case KEY_DOWN:
n = 2;
break;
return 2;
case KEY_RIGHT:
n = 6;
break;
return 6;
case KEY_LEFT:
n = 4;
break;
return 4;
default:
n = 0;
break;
return 0;
}
}
return n;
return 0;
}
void update(int action) {
......@@ -53,7 +48,7 @@ void update(int action) {
}
void render() {
clear();
erase();
renderMap(&level);
refresh();
}
#include "maps.h"
char steel[3][4] = {"ETET", "TETE", "ETET"};
char dirt[3][4] = {"----", "----", "----"};
char wall[3][4] = {"=-=-", "-=-=", "=-=-"};
char ext[3][4] = {"ETET", "TETE", "ETET"};
char rockf[3][4] = {" () ", "/MM\\", " /\\ "};
char bould[3][4] = {" @0 ", "O0@O", " o0 "};
char diamond[3][4] = {"/--\\", "|--|", "\\--/"};
char butterfly[3][4] = {"\\ /", "-oo-", "/ \\"};
char steel[3][6] = {" @ @ ", " ", " @ @ "};
char dirt[3][6] = {"-_-_-_", "_-_-_-", "-_-_-_"};
char wall[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 butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char input[WIDTH];
rockford player;
......@@ -51,14 +53,15 @@ void readFileMap(map *m, char *path) {
// rockford color
init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
// diamond color
init_pair(7, COLOR_YELLOW, COLOR_BLACK);
init_pair(7, COLOR_CYAN, COLOR_BLACK);
fclose(m->sprite);
}
void updateMap(map *m, int action) {
player.dir = action;
updateRockford(&player, m, action);
//mvprintw(0, 0, "%d", action);
mvprintw(0, 0, "%d", action);
}
void renderMap(map *m) {
......@@ -70,67 +73,70 @@ void renderMap(map *m) {
case('1'):
attron(COLOR_PAIR(5));
for (k = 0; k < 3; k++)
for (l = 0; l < 4; l++)
mvprintw(3*j+k+1, 4*i+l+1, "%c", steel[k][l]);
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", steel[k][l]);
attroff(COLOR_PAIR(5));
break;
case('2'):
attron(COLOR_PAIR(1));
for (k = 0; k < 3; k++)
for (l = 0; l < 4; l++)
mvprintw(3*j+k+1, 4*i+l+1, "%c", dirt[k][l]);
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", dirt[k][l]);
attroff(COLOR_PAIR(1));
break;
case('3'):
attron(COLOR_PAIR(4));
for (k = 0; k < 3; k++)
for (l = 0; l < 4; l++)
mvprintw(3*j+k+1, 4*i+l+1, "%c", wall[k][l]);
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", wall[k][l]);
attroff(COLOR_PAIR(4));
break;
case('4'):
attron(COLOR_PAIR(5));
for (k = 0; k < 3; k++)
for (l = 0; l < 4; l++)
mvprintw(3*j+k+1, 4*i+l+1, "%c", ext[k][l]);
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", ext[k][l]);
attroff(COLOR_PAIR(5));
break;
case('5'):
attron(COLOR_PAIR(6));
for (k = 0; k < 3; k++)
for (l = 0; l < 4; l++)
mvprintw(3*j+k+1, 4*i+l+1, "%c", rockf[k][l]);
for (l = 0; l < 6; l++) {
if (player.dir == 0 || player.dir == 5)
mvprintw(3*j+k+1, 6*i+l+1, "%c", rockf[k][l]);
else if (player.dir == 6 || player.dir == 8)
mvprintw(3*j+k+1, 6*i+l+1, "%c", rockfr[k][l]);
else if (player.dir == 4 || player.dir == 2)
mvprintw(3*j+k+1, 6*i+l+1, "%c", rockfl[k][l]);
}
attroff(COLOR_PAIR(6));
break;
case('6'):
for (k = 0; k < 3; k++)
for (l = 0; l < 4; l++) {
if ((l == 1 ||l == 2) && (k == 2)) {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+1, 4*i+l+1, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
} else if ((l == 1 || l == 2) && (k == 0)) {
attron(COLOR_PAIR(8));
mvprintw(3*j+k+1, 4*i+l+1, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else if (k != 0 && k != 2) {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+1, 4*i+l+1, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
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));
mvprintw(3*j+k+1, 6*i+l+1, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else {
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 < 4; l++)
mvprintw(3*j+k+1, 4*i+l+1, "%c", diamond[k][l]);
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond[k][l]);
attroff(COLOR_PAIR(7));
break;
case('8'):
for (k = 0; k < 3; k++)
for (l = 0; l < 4; l++)
mvprintw(3*j+k+1, 4*i+l+1, "%c", butterfly[k][l]);
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", butterfly[k][l]);
break;
}
......
......@@ -3,7 +3,7 @@
#include "utils.h"
#include <sys/time.h>
#define NANO 1000000000.0
#define FPS 1.0/10.0
#define FPS 1.0/24.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