Hi everyone,
im writing a c code project called space invaders, but
ive got a problem with it.
I want to delete an enemy if it was hit.
I have no idea, how can i realize it, to overwrite the array position.
Here is my source code...
Code:
while (1) { //Bildschirm reset und Startposition
system("cls");
for (y = 1; y <= 20; y++) {
for (x = 1; x <= 30; x++) {
if (x == 1 || x == 30 || y == 1 || y == 20) {
feld[y][x] = h_muster;
}
else if (feld[y][x] == 'O' && feld[y+2][x] == 'e') {
//Feldwerte in Array schreiben
feld[y][x] = '.';
score++;
}
else if (feld[y][x] == '^') {
feld[y][x] = 'e';
feld[y-1][x] = '^';
}
else if (x == p_cursor_x && y == 18 && shot == 1) {
//Drucke Schuss
feld[y][x] = '^';
shot = 0;
}
else if (x > 4 && x < 27 && y > scroll_down && y < (scroll_down + 6)) {
//Drucke Gegner
feld[y][x] = 'O';
cycles++;
if (cycles == 10000) {
scroll_down++;
cycles = 0;
}
}
else if (x == p_cursor_x && y == 19) {
//Drucke Spieler
feld[y][x] = 'T';
}
else {
feld[y][x] = '.';
}
printf("%c", feld[y][x]);
}printf("\n");
}
printf("\n\nSCORE: %d", score);
//Einlesen von Taste, falls Tasteneingabe nicht erfolgt -> Leerzeichen übergeben
if (_kbhit()) {
read_keyboard(_getch());
fflush(stdin);
}
else {
read_keyboard(' ');
}
//Warte 50ms, damit Bild nicht so oft neu geladen wird.
Sleep(50);
}