Commit c2f1d8ce authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Adicionado gravidade

parent 7131a7aa
#include "maps.h"
char steel[3][6] = {" @ @ ", " ", " @ @ "};
char steel2[3][6] = {" ", " @ @ ", " "};
char steel2[3][6] = {" ", " @ @ ", " "};
char dirt[3][6] = {"-_-_-_", "_-_-_-", "-_-_-_"};
//char wall[3][6] = {"=-=-=-", "-=-=-=", "=-=-=-"};
char wall[3][6] = {"|_|_|_", "_|_|_|", "|_|_|_"};
char wall2[3][6] = {"_|_|_|", "|_|_|_", "_|_|_|"};
char wall2[3][6] = {"_|_|_|", "|_|_|_", "_|_|_|"};
char ext[3][6] = {" @ @ ", " ", " @ @ "};
char rockf[3][6] = {" (**) ", " /EE\\ ", " II "};
......@@ -13,14 +12,17 @@ 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 diamond2[3][6] = {" / \\ ", "|====|", " \\ / "};
char diamond3[3][6] = {" /==\\ ", "| |", " \\ / "};
char butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char explosion[3][6] = {"#%@$%@", "#@$$##", "&@#!*#"};
char input[WIDTH];
rockford player;
int alter;
int dead;
int s = 0;
void readFileMap(map *m, char *path) {
void readFileMap(map *m) {
int i, j;
m->sprite = fopen("./sprites/map1.txt", "r");
for (i = 0; i < HEIGHT; i++) {
......@@ -30,6 +32,8 @@ void readFileMap(map *m, char *path) {
player.x = i;
player.y = j;
player.dir = 5;
dead = 0;
s = 0;
}
m->grid[j][i] = input[j];
}
......@@ -62,13 +66,41 @@ void readFileMap(map *m, char *path) {
// diamond color
init_pair(7, COLOR_CYAN, COLOR_BLACK);
//explosion color
init_pair(9, COLOR_WHITE, COLOR_BLACK);
fclose(m->sprite);
}
void updateMap(map *m, int action) {
player.dir = action;
updateRockford(&player, m, action);
mvprintw(0, 0, "%d", action);
if (!dead)
updateRockford(&player, m, action);
else {
s++;
if (s < 20) {
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';
m->grid[player.y-1][player.x] = 'x';
m->grid[player.y][player.x] = 'x';
m->grid[player.y+1][player.x] = 'x';
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) {
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';
m->grid[player.y-1][player.x] = '0';
m->grid[player.y][player.x] = '0';
m->grid[player.y+1][player.x] = '0';
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)
readFileMap(m);
}
}
void renderMap(map *m, int time) {
......@@ -76,6 +108,7 @@ void renderMap(map *m, int time) {
alter = 0;
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
if (!dead) s = (s + 1) % 7;
switch (m->grid[i][j]) {
case('1'):
attron(COLOR_PAIR(5));
......@@ -128,8 +161,10 @@ void renderMap(map *m, int time) {
attroff(COLOR_PAIR(6));
break;
case('6'):
if (m->grid[i][j+1] == '0')
m->grid[i][j] = 'f';
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
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));
......@@ -141,6 +176,7 @@ void renderMap(map *m, int time) {
attroff(COLOR_PAIR(3));
}
}
}
break;
case('7'):
attron(COLOR_PAIR(7));
......@@ -159,6 +195,42 @@ void renderMap(map *m, int time) {
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", butterfly[k][l]);
break;
case('f'):
for (k = 0; k < 3; k++)
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));
}
}
}
if (s == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'f';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '5') {
m->grid[i][j+1] = 'f';
m->grid[i][j] = '0';
dead = true;
} else
m->grid[i][j] = '6';
}
break;
case('x'):
attron(COLOR_PAIR(9));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", explosion[k][l]);
mvprintw(3*j+k+1, 6*i+l+1, "%c", explosion[k][l]);
attroff(COLOR_PAIR(9));
break;
}
}
......
#ifndef _MAPS_H
#define _MAPS_H
#include <math.h>
#include "utils.h"
#include "entity.h"
#include "rockford.h"
void readFileMap();
void readFileMap(map *m);
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