I am working on 2d terminal game like space invaders but with moving map. I have a issue where the map moves to the top and after reaching the top edge it changes characters of another wall coming towards the player any tips?
void moving_map(){
initscr();
int i = 0;
char map1[50][150];
char map2[50][150];
char zone[50][150];
//prva mapa inicializacia pre prvych 50 riadkov
entities(zone);
generator(map1,zone);
for(int k = 0; k < 50;k++){
for(int j = 0; j < 150;j++){
mvprintw(k,j,".");
map2[k][j] = map1[k][j];
}
}
ship();
refresh();
delay(2000);
int test = 0;
int x = 0;
while(true){
if(i == 49){
//nasledna inicializacia pre dalsich 50x riadkov
srand(time(NULL));
entities(zone);
generator(map1,zone);
i = 0;
for(int q = 0;q<50;q++){
for(int j = 0;j<150;j++){
map2[q][j] = map1[q][j];
}
}
}
for(int q = 0; q <= i;q++){
for(int j = 0; j < 150;j++){
mvprintw(49-q,j,"%c",map1[i-q][j]);
if(q == 48){
test = 1;
}
if(test == 1){
x = 0;
for(int p = 48-q; p > 0; p--){
mvprintw(p,j,"%c",map2[x][j]);
x++;
}
}
}
}
ship();
delay(100);
refresh();
i++;
}
getch();
refresh();
endwin();
}
triple wall segment After the triple wall segment reach the edge it its changing another wall segment coming after it.
Thanks for help.