Commit 71bb727d authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Correções explosão e tempo

parent 89ded8ed
564
0
\ No newline at end of file
1000 1000 1000
0 0 0
0 0 1000
@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@
@!###################################!@
@!#!!!!##!!!!#!####!!!###!!!!#!!!####!@
@!#!###!#!##!#!####!##!##!####!##!###!@
@!#!###!#!##!#!####!###!#!!!##!#!####!@
@!#!##!##!##!#!####!###!#!!!##!!#####!@
@!#!###!#!##!#!####!##!##!####!#!####!@
@!#!!!!##!!!!#!!!!#!!!###!!!!#!##!###!@
@!###################################!@
@!###########!!!#####!###!!!!!#!###!#!@
@!###########!##!###!#!##!#####!###!#!@
@!###########!###!#!###!#!!!!!#!!!!!#!@
@!###########!###!#!!!!!#####!#!!!!!#!@
@!###########!##!##!###!#####!#!###!#!@
@!###########!!!###!###!#!!!!!#!###!#!@
@!###################################!@
@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@
@creators:@ivo@@@@@@@@e@@bruno@@@@@@@@@
@@@@@@@@@@@@@@junior@@@@@@@@@tissei@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@high@score:@@@@@@@@@@@@@@@@@@@@
@@@@@@@@last@@@@@@:@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@cave:@@@@@@@<@>@@@@enter@
@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@@
@!###################################!@@
@!#!!!!##!!!!#!####!!!###!!!!#!!!####!@@
@!#!###!#!##!#!####!##!##!####!##!###!@@
@!#!###!#!##!#!####!###!#!!!##!#!####!@@
@!#!##!##!##!#!####!###!#!!!##!!#####!@@
@!#!###!#!##!#!####!##!##!####!#!####!@@
@!#!!!!##!!!!#!!!!#!!!###!!!!#!##!###!@@
@!###################################!@@
@!###########!!!#####!###!!!!!#!###!#!@@
@!###########!##!###!#!##!#####!###!#!@@
@!###########!###!#!###!#!!!!!#!!!!!#!@@
@!###########!###!#!!!!!#####!#!!!!!#!@@
@!###########!##!##!###!#####!#!###!#!@@
@!###########!!!###!###!#!!!!!#!###!#!@@
@!###################################!@@
@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@@
@creators:@ivo@@@@@@and@@bruno@@@@@@@@@@
@@@@@@@@@@@@@@junior@@@@@@@@@tissei@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@high@score:@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@last@@@@@@:@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@cave:@@@@@@@<@>@@@@enter@@
......@@ -9,7 +9,7 @@ void updateFirefly(map *m, firefly *first, int *dead) {
if (!aux->dead) {
for (k = -1; k <= 1; k++) {
for (l = -1; l <= 1; l++) {
if (m->grid[i+k][j+l] == '5') {
if (!(k && l) && m->grid[i+k][j+l] == '5') {
*dead = true;
aux->dead = true;
m->grid[i][j] = '0';
......
......@@ -4,6 +4,7 @@ map level;
menu me;
int menuaction = 0;
int load = true;
int loadMenu = false;
void run(int ismenu, int running) {
double last_time, current_time, delta = FPS;
......@@ -46,37 +47,37 @@ void run(int ismenu, int running) {
int getInput() {
int input = getch();
if (input != ERR) {
switch (input) {
case KEY_UP:
return 8;
case KEY_DOWN:
return 2;
case KEY_RIGHT:
return 6;
case KEY_LEFT:
return 4;
case 10:
return 1;
case 27:
return 9;
default:
return 0;
}
}
return 0;
}
if (input != ERR) {
switch (input) {
case KEY_UP:
return 8;
case KEY_DOWN:
return 2;
case KEY_RIGHT:
return 6;
case KEY_LEFT:
return 4;
case 10:
return 1;
case 27:
return 9;
default:
return 0;
}
}
return 0;
}
void update(int action, int *ismenu) {
if (*ismenu) {
menuaction = updateMenu(&me, action);
void update(int action, int *ismenu) {
if (*ismenu) {
menuaction = updateMenu(&me, action, &loadMenu);
if (menuaction != -1) {
load = true;
*ismenu = false;
me.last = 0;
}
} else
updateMap(&level, action, ismenu);
updateMap(&level, action, ismenu, &loadMenu);
}
void render(int time) {
......
#include "maps.h"
#include "physics.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 mapfile[5][100] = {"./sprites/map1.txt", "./sprites/map2.txt", "./sprites/map3.txt", "./sprites/map4.txt", "./sprites/map5.txt"};
int colors[8][3];
......@@ -30,7 +12,7 @@ int alter;
int dead;
int offy, offx;
int row, col;
int leveltime, waittime;
int leveltime, waittime, falltime;
int mapnumber;
int done, lightning;
int hold;
......@@ -53,6 +35,7 @@ void readFileMap(map *m, int mapn, int pscore) {
pushdelay = 0;
mapnumber = mapn;
waittime = 0;
falltime = 0;
m->sprite = fopen(mapfile[mapnumber], "r");
fscanf(m->sprite, "%d %d %d", &m->diamonds, &m->score, &leveltime);
......@@ -163,14 +146,15 @@ void saveScore() {
fclose(lastscorefile);
}
void updateMap(map *m, int action, int *ismenu) {
void updateMap(map *m, int action, int *ismenu, int *loadMenu) {
int k, l;
getmaxyx(stdscr, row, col);
offy = (row / 2) - (12 * 3);
offx = (col / 2) - (20 * 6);
if (action == 9) {
saveScore();
*ismenu = true;
*loadMenu = true;
} else {
player.dir = action;
pushdelay = (pushdelay + 1) % 30;
......@@ -192,18 +176,17 @@ void updateMap(map *m, int action, int *ismenu) {
}
} else {
waittime++;
int k, l;
if (waittime < 21)
for(k = -1; k <= 1; k++)
for(l = -1; l <=1; l++)
if(m->grid[player.y+k][player.x+l] != '1')
if (waittime < 21) {
for(k = -1; k <= 1; k++)
for(l = -1; l <= 1; l++)
if(m->grid[player.y+k][player.x+l] != '1')
m->grid[player.y+k][player.x+l] = 'x';
else if (waittime <= 100)
for(k = -1; k <= 1; k++)
for(l = -1; l <=1; l++)
if(m->grid[player.y+k][player.x+l] != '1')
} else if (waittime <= 21) {
for(k = -1; k <= 1; k++)
for(l = -1; l <= 1; l++)
if(m->grid[player.y+k][player.x+l] != '1')
m->grid[player.y+k][player.x+l] = '0';
else if (waittime > 100)
} else if (waittime > 100)
readFileMap(m, mapnumber, player.score);
}
}
......@@ -245,20 +228,20 @@ void renderMap(map *m, int time) {
if (lightning)
hold++;
if (!(time % 3)) {
if (!(time % 2)) {
blink1 = (blink1 % 3) + 4;
blink2 = (blink2 % 3) + 4;
blink3 = (blink3 % 3) + 4;
}
if (nff && !(time % 6))
if (nff && !(time % 4))
updateFirefly(m, firstff, &dead);
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;
updatePhysics(m, m->grid[i][j], i, j, offx, offy, time, falltime, waittime, &dead);
falltime = (falltime + 1) % 7;
switch (m->grid[i][j]) {
case('0'):
renderChar(empty, i, j, offx, offy, lightning ? 4 : 6);
......
......@@ -9,7 +9,7 @@
void readFileMap(map *m, int mapn, int pscore);
void setColors();
void saveScore();
void updateMap(map *m, int action, int *ismenu);
void updateMap(map *m, int action, int *ismenu, int *loadMenu);
void renderMap(map *m, int time);
#endif
......@@ -44,9 +44,12 @@ void setMenuColors() {
init_pair(4, COLOR_WHITE, COLOR_WHITE);
}
int updateMenu(menu *menu, int action) {
int updateMenu(menu *menu, int action, int *loadMenu) {
buffer = -1;
if (*loadMenu) {
setMenuColors();
*loadMenu = false;
}
switch(action){
case 6:
currmap = (currmap + 1) % 5;
......
......@@ -5,7 +5,7 @@
void readFileMenu(menu *menu);
void setMenuColors();
int updateMenu(menu *menu, int action);
int updateMenu(menu *menu, int action, int *loadMenu);
void renderMenu(menu *menu);
#endif
#include "physics.h"
void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time, int waittime, int *dead) {
void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time, int falltime, int waittime, int *dead) {
int k, l;
switch (in) {
case('f'):
......@@ -17,7 +17,7 @@ void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time,
attroff(COLOR_PAIR(3));
}
}
if (waittime == 6) {
if (falltime == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'f';
m->grid[i][j] = '0';
......@@ -37,7 +37,7 @@ void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time,
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (falltime == 6) {
if (m->grid[i][j+1] == '0') {
m->grid[i][j+1] = 'h';
m->grid[i][j] = '0';
......@@ -72,7 +72,7 @@ void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time,
}
}
}
if (waittime == 6) {
if (falltime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'f';
m->grid[i][j] = '0';
......@@ -94,7 +94,7 @@ void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time,
}
}
}
if (waittime == 6) {
if (falltime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'f';
m->grid[i][j] = '0';
......@@ -109,7 +109,7 @@ void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time,
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (falltime == 6) {
if (m->grid[i+1][j] == '0') {
m->grid[i+1][j] = 'h';
m->grid[i][j] = '0';
......@@ -124,7 +124,7 @@ void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time,
else
renderChar(diamond3, i, j, offx, offy, 7);
if (waittime == 6) {
if (falltime == 6) {
if (m->grid[i-1][j] == '0') {
m->grid[i-1][j] = 'h';
m->grid[i][j] = '0';
......
......@@ -4,6 +4,6 @@
#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);
void updatePhysics(map *m, char in, int i, int j, int offx, int offy, int time, int falltime, int waittime, int *dead);
#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