Commit 9c59b191 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Adicionado mudança de mapa ao completar fase

parent 43ecb49d
#include "gui.h"
// Scoreboard, menu, levels e hub
#ifndef _GUI_H
#define _GUI_H
#include "utils.h"
#endif
......@@ -30,9 +30,14 @@ int offy, offx;
int row, col;
int leveltime, waittime;
int mapnumber;
int done, lightning;
int hold;
int extx, exty;
void readFileMap(map *m, int mapn) {
int i, j;
done = lightning = false;
hold = 0;
mapnumber = mapn;
leveltime = 150;
waittime = 0;
......@@ -54,6 +59,9 @@ void readFileMap(map *m, int mapn) {
player.diamonds = 0;
player.score = 0;
dead = false;
} else if (input[j] == '4') {
extx = i;
exty = j;
}
m->grid[j][i] = input[j];
}
......@@ -109,13 +117,21 @@ void setColors() {
void updateMap(map *m, int action) {
player.dir = action;
if (player.diamonds >= m->diamonds)
if (player.diamonds >= m->diamonds) {
m->score = 15;
done = true;
lightning = hold <= 30;
}
if (!dead) {
updateRockford(&player, m, action);
if (leveltime == 0)
dead = true;
if (done && player.x == extx && player.y == exty) {
if (leveltime == 0)
readFileMap(m, mapnumber+1);
} else {
updateRockford(&player, m, action, done);
if (leveltime == 0)
dead = true;
}
} else {
waittime++;
if (waittime < 21) {
......@@ -166,14 +182,28 @@ void renderMap(map *m, int time) {
m->grid[35][0] = ((player.score / 10) % 10) + 'A';
m->grid[36][0] = (player.score % 10) + 'A';
if (time == 29)
if (leveltime != 0) leveltime--;
if (done && player.x == extx && player.y == exty) {
if (time % 2 == 0 && leveltime != 0) {
leveltime--;
player.score++;
}
} else {
if (time == 29 && leveltime != 0)
leveltime--;
}
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
if (!dead)
waittime = (waittime + 1) % 7;
switch (m->grid[i][j]) {
case('0'):
if (lightning) {
hold++;
renderChar(empty, i, j, offx, offy, 4);
} else
renderChar(empty, i, j, offx, offy, 6);
break;
case('1'):
attron(COLOR_PAIR(5));
for (k = 0; k < 3; k++)
......@@ -193,7 +223,13 @@ void renderMap(map *m, int time) {
renderChar(wall2, i, j, offx, offy, 4);
break;
case('4'):
renderChar(ext, i, j, offx, offy, 5);
if (done) {
if (time < 15)
renderChar(ext, i, j, offx, offy, 5);
else
renderChar(empty, i, j, offx, offy, 4);
} else
renderChar(ext, i, j, offx, offy, 5);
break;
case('5'):
attron(COLOR_PAIR(6));
......
#include "physics.h"
// Controlar o movimento das pedras e tempo de explosão
#ifndef _PHYSICS_H
#define _PHYSICS_H
#include "utils.h"
#endif
#include "rockford.h"
void updateRockford(rockford *player, map *m, int action) {
void updateRockford(rockford *player, map *m, int action, int done) {
if (action == 8) {
char up = m->grid[player->y][player->x-1];
if (up == '0' || up == '2') {
if (up == '0' || up == '2' || (done && up == '4')) {
m->grid[player->y][player->x--] = '0';
m->grid[player->y][player->x] = '5';
} else if (up == '7') {
......@@ -14,7 +14,7 @@ void updateRockford(rockford *player, map *m, int action) {
}
} else if (action == 6) {
char right = m->grid[player->y+1][player->x];
if (right == '0' || right == '2') {
if (right == '0' || right == '2' || (done && right == '4')) {
m->grid[player->y++][player->x] = '0';
m->grid[player->y][player->x] = '5';
} else if (right == '7') {
......@@ -25,7 +25,7 @@ void updateRockford(rockford *player, map *m, int action) {
}
} else if (action == 4) {
char left = m->grid[player->y-1][player->x];
if (left == '0' || left == '2') {
if (left == '0' || left == '2' || (done && left == '4')) {
m->grid[player->y--][player->x] = '0';
m->grid[player->y][player->x] = '5';
} else if (left == '7') {
......@@ -36,7 +36,7 @@ void updateRockford(rockford *player, map *m, int action) {
}
} else if (action == 2) {
char down = m->grid[player->y][player->x+1];
if (down == '0' || down == '2') {
if (down == '0' || down == '2' || (done && down == '4')) {
m->grid[player->y][player->x++] = '0';
m->grid[player->y][player->x] = '5';
} else if (down == '7') {
......
......@@ -3,7 +3,7 @@
#include "utils.h"
#include "entity.h"
void updateRockford(rockford *player, map *m, int action);
void updateRockford(rockford *player, map *m, int action, int done);
void renderRockford(rockford *player);
#endif
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