Sup people. Ok, the galaga-type of game is due on monday. However, I'm having some serious trouble :ph34r:
Here's the code
As the last time, press E to play, A-D for left-right, S for shooting, M for menu, and Z for quitting. I compiled with borlandC 3.1Code:#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
int x = 37;
int y = 25;
char b;
void ship (int x, int y);
void shoot (int x, int y);
void menu ();
void enemy();
void salida ();
void salida(){
clrscr();
delay(500);
printf("Gracias por jugar\n");
exit(0);
}
void enemy(int x, int y){
gotoxy(x,y);
printf("w0otage");
}
void shoot(int x, int y){
int i=21;
while (i>0){
int ejex = x;
gotoxy(ejex+3, i);
printf("|");
delay (14);
i--;
}
ship(x,y);
}
void ship(int x, int y){
clrscr();
gotoxy(x,y);
printf("*-----*");
gotoxy(x,y-1);
printf(" *---* ");
gotoxy(x,y-2);
printf(" *-* ");
gotoxy(x,y-3);
printf(" * ");
delay(3000);
enemy(x,y);
b = getch();
switch (b){
case 'a':
if(x<=5){
ship(x,y);
}else {
ship(x-7,y);
}
break;
case 'd':
if(x>=72){
ship(x,y);
}else {
ship(x+7,y);
}
break;
case 's':
shoot(x,y);
break;
case 'm':
menu();
break;
case 'z':
salida();
break;
default:
ship(x,y);
}
}
void menu(){
clrscr();
gotoxy(22,10);
printf("Izquierda A\n");
gotoxy(22,11);
printf("Disparar S\n");
gotoxy(22,12);
printf("Derecha D\n");
gotoxy(22,13);
printf("Menu M\n");
gotoxy(22,14);
printf("Salir Z\n");
gotoxy(22,16);
printf("Para empezar a jugar, presione E\n");
gotoxy(22,17);
printf("Para salir, presione Z\n");
b = getch();
switch (b){
case 'e':
ship(x,y);
break;
case 'z':
salida();
break;
default:
menu();
}
}
void main(){
menu();
}
So here's the problem:
I'm trying to great the enemy ships. However, the problem is that the good ship (whenever it moves), it clears screen
So if I get the enemy ship to display, it would be erased whenever the ship does something.Quote:
void ship(int x, int y){
clrscr();
gotoxy(x,y);
Any ideas on this? Please, I'm on a hurry :ph34r: :ghostface: