Commit 68f58055 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Organização 1

parent e3844c55
......@@ -9,6 +9,7 @@ int main() {
void startCurses() {
initscr();
start_color();
cbreak();
nodelay(stdscr, true);
noecho();
......
......@@ -59,14 +59,16 @@ int alter;
int dead;
int offy, offx;
int row, col;
int t;
int s = 0;
int t, s;
void readFileMap(map *m) {
int i, j;
t = 150;
s = 0;
m->score = 10;
m->diamonds = 12;
m->sprite = fopen("./sprites/map1.txt", "r");
for (i = 0; i < HEIGHT; i++) {
fscanf(m->sprite, "%s", input);
for (j = 0; j < WIDTH; j++) {
......@@ -76,17 +78,19 @@ void readFileMap(map *m) {
player.dir = 5;
player.diamonds = 0;
player.score = 0;
dead = 0;
t = 150;
s = 0;
dead = false;
}
m->grid[j][i] = input[j];
}
}
fclose(m->sprite);
getmaxyx(stdscr, row, col);
offy = row / 2 - 12*3;
offx = col / 2 - 20*6;
start_color();
offy = (row / 2) - (12 * 3);
offx = (col / 2) - (20 * 6);
}
void setColors() {
init_color(COLOR_WHITE, 650, 650, 650);
init_color(COLOR_BLACK, 0, 0, 0);
init_color(COLOR_RED, 412, 228, 136);
......@@ -100,17 +104,22 @@ 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_WHITE);
// rock gray color 2
init_pair(3, COLOR_BLACK, COLOR_GREEN);
// wall color
init_pair(4, COLOR_BLACK, COLOR_WHITE);
// steel color
init_pair(5, COLOR_WHITE, COLOR_BLUE);
// rockford color
init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
// diamond color
init_pair(7, COLOR_CYAN, COLOR_BLACK);
......@@ -120,11 +129,13 @@ void readFileMap(map *m) {
//number color
init_pair(2, COLOR_YELLOW, COLOR_BLACK);
fclose(m->sprite);
}
void updateMap(map *m, int action) {
player.dir = action;
if (player.diamonds >= m->diamonds)
m->score = 15;
if (!dead) {
updateRockford(&player, m, action);
if (t == 0)
......@@ -154,8 +165,6 @@ 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) {
......
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