Commit 1c86ec09 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Adicionado physics

parent 14474f66
#include "maps.h"
#include "physics.h"
char steel[3][6] = {" @ @ ", " ", " @ @ "};
/*char steel[3][6] = {" @ @ ", " ", " @ @ "};
char steel2[3][6] = {" ", " @ @ ", " "};
char dirt[3][6] = {"-_-_-_", "_-_-_-", "-_-_-_"};
char wall[3][6] = {"|_|_|_", "_|_|_|", "|_|_|_"};
......@@ -17,7 +18,7 @@ char diamond3[3][6] = {" /==\\ ", "| |", " \\ / "};
char butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char explosion[3][6] = {" ", " ## ", " "};
char explosion2[3][6] = {"\\\\||//", "--##--", "//||\\\\"};
char explosion3[3][6] = {"#%$@%@", "#@ ##", "&@*@*#"};
char explosion3[3][6] = {"#%$@%@", "#@ ##", "&@*@*#"}; */
char mapfile[5][100] = {"./sprites/map1.txt", "./sprites/map2.txt", "./sprites/map3.txt", "./sprites/map4.txt", "./sprites/map5.txt"};
int colors[8][3];
......@@ -280,6 +281,7 @@ void renderMap(map *m, int time) {
for (i = 0; i < WIDTH; i++) {
for (j = 0; j < HEIGHT; j++) {
updatePhysics(m, m->grid[i][j], i, j, offx, offy, time, waittime, dead);
if (!dead)
waittime = (waittime + 1) % 7;
switch (m->grid[i][j]) {
......@@ -379,134 +381,6 @@ void renderMap(map *m, int time) {
case('8'):
renderChar(butterfly, i, j, offx, offy, 5);
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+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
if (waittime == 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] = '0';
m->grid[i][j] = '0';
dead = true;
} else
m->grid[i][j] = '6';
}
break;
case('h'):
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'h';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '5') {
m->grid[i][j+1] = 'h';
m->grid[i][j] = '0';
dead = true;
} else
m->grid[i][j] = '7';
}
break;
case('x'):
if(waittime < 7)
renderChar(explosion, i, j, offx, offy, 9);
else if(waittime < 14)
renderChar(explosion2, i, j, offx, offy, 9);
else
renderChar(explosion3, i, j, offx, offy, 9);
break;
case('r'):
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+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
}
if (waittime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'f';
m->grid[i][j] = '0';
}
}
break;
case('l'):
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+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
}
if (waittime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'f';
m->grid[i][j] = '0';
}
}
break;
case('R'):
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'h';
m->grid[i][j] = '0';
}
}
break;
case('L'):
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'h';
m->grid[i][j] = '0';
}
}
break;
case('A'):
renderChar(zero, i, j, offx, offy, (i == 3 || i == 4 || i == 12 || i == 13) ? 2 : 11);
break;
......
#include "physics.h"
void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time, int waittime, int dead) {
int k, l;
switch (in) {
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+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
if (waittime == 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] = '0';
m->grid[i][j] = '0';
dead = true;
} else
m->grid[i][j] = '6';
}
break;
case('h'):
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'h';
m->grid[i][j] = '0';
} else if (m->grid[i][j+1] == '5') {
m->grid[i][j+1] = 'h';
m->grid[i][j] = '0';
dead = true;
} else
m->grid[i][j] = '7';
}
break;
case('x'):
if(waittime < 7)
renderChar(explosion, i, j, offx, offy, 9);
else if(waittime < 14)
renderChar(explosion2, i, j, offx, offy, 9);
else
renderChar(explosion3, i, j, offx, offy, 9);
break;
case('r'):
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+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
}
if (waittime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'f';
m->grid[i][j] = '0';
}
}
break;
case('l'):
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+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(8));
} else {
attron(COLOR_PAIR(3));
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
}
if (waittime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'f';
m->grid[i][j] = '0';
}
}
break;
case('R'):
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'h';
m->grid[i][j] = '0';
}
}
break;
case('L'):
if (time < 10)
renderChar(diamond, i, j, offx, offy, 7);
else if (time < 20)
renderChar(diamond2, i, j, offx, offy, 7);
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'h';
m->grid[i][j] = '0';
}
}
break;
}
}
#ifndef _PHYSICS_H
#define _PHYSICS_H
#include "utils.h"
#include "entity.h"
void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time, int waittime, int dead);
#endif
#include "utils.h"
char steel[3][6] = {" @ @ ", " ", " @ @ "};
char steel2[3][6] = {" ", " @ @ ", " "};
char dirt[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 diamond2[3][6] = {" / \\ ", "|====|", " \\ / "};
char diamond3[3][6] = {" /==\\ ", "| |", " \\ / "};
char butterfly[3][6] = {"\\\\ //", " (__) ", "// \\\\"};
char explosion[3][6] = {" ", " ## ", " "};
char explosion2[3][6] = {"\\\\||//", "--##--", "//||\\\\"};
char explosion3[3][6] = {"#%$@%@", "#@ ##", "&@*@*#"};
char empty[3][6] = {" ", " ", " "};
char one[3][6] = {" ", " -| ", " _|_ "};
char two[3][6] = {" __ ", " __] ", " |__ "};
......
......@@ -13,6 +13,25 @@
#define MAPVALUE 1
char steel[3][6];
char steel2[3][6];
char dirt[3][6];
char wall[3][6];
char wall2[3][6];
char ext[3][6];
char rockf[3][6];
char rockfr[3][6];
char rockfl[3][6];
char bould[3][6];
char diamond[3][6];
char diamond2[3][6];
char diamond3[3][6];
char butterfly[3][6];
char explosion[3][6];
char explosion2[3][6];
char explosion3[3][6];
char empty[3][6];
char one[3][6];
char two[3][6];
......
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