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

add zoom

parent aebdef22
......@@ -3,8 +3,14 @@
a=`echo $TERM`
export TERM=xterm-256color
xdotool key Ctrl+minus
xdotool key Ctrl+minus
gcc src/*.c -Wall -o temp -l curses
./temp
rm temp
xdotool key Ctrl+plus
xdotool key Ctrl+plus
export TERM=a
......@@ -20,6 +20,8 @@ char input[WIDTH];
rockford player;
int alter;
int dead;
int offy, offx;
int row, col;
int s = 0;
void readFileMap(map *m) {
......@@ -38,6 +40,9 @@ void readFileMap(map *m) {
m->grid[j][i] = input[j];
}
}
getmaxyx(stdscr, row, col);
offy = row / 2 - 11*3;
offx = col / 2 - 20*6;
start_color();
init_color(COLOR_WHITE, 650, 650, 650);
init_color(COLOR_BLACK, 0, 0, 0);
......@@ -115,16 +120,16 @@ void renderMap(map *m, int time) {
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (j == 0 || j == 21)
mvprintw(3*j+k+1, 6*i+l+1, "%c", steel[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", steel[k][l]);
else
mvprintw(3*j+k+1, 6*i+l+1, "%c", steel2[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", steel2[k][l]);
attroff(COLOR_PAIR(5));
break;
case('2'):
attron(COLOR_PAIR(1));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", dirt[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", dirt[k][l]);
attroff(COLOR_PAIR(1));
break;
case('3'):
......@@ -132,9 +137,9 @@ void renderMap(map *m, int time) {
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (alter)
mvprintw(3*j+k+1, 6*i+l+1, "%c", wall[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", wall[k][l]);
else
mvprintw(3*j+k+1, 6*i+l+1, "%c", wall2[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", wall2[k][l]);
if (i < 9 || i > 30)
alter = (alter + 1) % 2;
alter = alter ? 0 : 1;
......@@ -144,7 +149,7 @@ void renderMap(map *m, int time) {
attron(COLOR_PAIR(5));
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", ext[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", ext[k][l]);
attroff(COLOR_PAIR(5));
break;
case('5'):
......@@ -152,11 +157,11 @@ void renderMap(map *m, int time) {
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++) {
if (player.dir == 0 || player.dir == 5)
mvprintw(3*j+k+1, 6*i+l+1, "%c", rockf[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", rockf[k][l]);
else if (player.dir == 6 || player.dir == 8)
mvprintw(3*j+k+1, 6*i+l+1, "%c", rockfr[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", rockfr[k][l]);
else if (player.dir == 4 || player.dir == 2)
mvprintw(3*j+k+1, 6*i+l+1, "%c", rockfl[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", rockfl[k][l]);
}
attroff(COLOR_PAIR(6));
break;
......@@ -168,11 +173,11 @@ void renderMap(map *m, int time) {
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]);
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+1, 6*i+l+1, "%c", bould[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
......@@ -185,17 +190,17 @@ void renderMap(map *m, int time) {
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (time < 10)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond[k][l]);
else if (time < 20)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond2[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond2[k][l]);
else
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond3[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond3[k][l]);
attroff(COLOR_PAIR(7));
break;
case('8'):
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
mvprintw(3*j+k+1, 6*i+l+1, "%c", butterfly[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", butterfly[k][l]);
break;
case('f'):
for (k = 0; k < 3; k++)
......@@ -203,11 +208,11 @@ void renderMap(map *m, int time) {
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]);
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+1, 6*i+l+1, "%c", bould[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", bould[k][l]);
attroff(COLOR_PAIR(3));
}
}
......@@ -229,11 +234,11 @@ void renderMap(map *m, int time) {
for (k = 0; k < 3; k++)
for (l = 0; l < 6; l++)
if (time < 10)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond[k][l]);
else if (time < 20)
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond2[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond2[k][l]);
else
mvprintw(3*j+k+1, 6*i+l+1, "%c", diamond3[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", diamond3[k][l]);
attroff(COLOR_PAIR(7));
if (s == 6) {
......@@ -252,8 +257,8 @@ void renderMap(map *m, int time) {
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]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", explosion[k][l]);
mvprintw(3*j+k+offy, 6*i+l+offx, "%c", explosion[k][l]);
attroff(COLOR_PAIR(9));
break;
......
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