hi
in my programme there has to be at least 2 actions
i used do while loop in one of the fuctions and this function is called when pressed "p" and problem occurs here:this function uses do while loop .while this function works changes between(1-5 seconds) other fuctions dont work.
so i tried changing it to for loop.but at this time the function doesnt work.i mean there is nothing printed to screen.
how can i solve this problem?
my code is:#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
void player();
void fire();
void animation();
void stupid_ship();
int x=3,y=3;
int oldx,oldy;
int firex,firey;
int shipx,shipy,tempy
int existship=0;
void player() {
char key;
while(1) {
gotoxy(x,y);printf(":->");
oldx=x;
oldy=y;
key = getch();
switch(key) {
case 'w' :
y--;
gotoxy(oldx,oldy);
printf(" ");
if(y==1) {
y=2;
}
break;
case 's' :
y++;
gotoxy(oldx,oldy);
printf(" ");
if(y==23) {
y=22;
}
break;
case 'a' :
x--;
gotoxy(oldx+2,oldy);
printf(" ");
if(x==1) {
x=2;
}
break;
case 'd' :
x++;
gotoxy(oldx,oldy);
printf(" ");
if(x==81) {
x=8*;
}
break;
case 'p' :
fire();
break;
case 'q' :
exit(0);
break;
default :
getch();
}
} //end of while
} //end of player
//---------------------------------------------------------
void fire() {
firex=x+4;
firey=y;
// for(firex=x+4;firex>85;firex++)
do {
delay(50);
gotoxy(firex,firey);printf(".");
gotoxy(firex-1,firey);printf(" ");
firex++;
if(firex==shipx && firey==shipy) {
animation();
firex=60;
}
}while(firex!=82) ;
}
//-------------------------------------------------------------
void animation() {
gotoxy(firex,firey);printf("isi bitti");
delay(100);
gotoxy(firex,firey);printf(" ");
existship=0;
}
void stupid_ship() {
randomize();
shipx=60;
shipy=random(25);
textcolor(random(12));
while(shipx!=1) {
delay(400);
old_shipx=shipx;
old_shipy=shipy;
gotoxy(shipx,shipy);printf("-<<=");
gotoxy(old_shipx,old_shipy);printf(" ");
shipx--;
} //end of while
} //end of function
void main() {
clrscr();
player();
}