-
help me
i wanna write a program that has a jet( : -> ) and it has ability to fire but the problem occurs here i can move that object whereever i want but i cant fire it.
for example:
:-> *
:-> ..*
:-> ... *
:->....... *
like that but i couldnt achieve this.
my code is :
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
void player();
void fire();
int x=3,y=3;
int oldx,oldy;
int firex,firey;
int shipx,shipy;
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==60) {
x=59;
}
break;
case 'p' :
fire();
break;
case 'q' :
exit();
break;
default :
getch();
}
} //end of while
} //end of player
void fire() {
while(1) {
delay(30);
gotoxy(firex,firey);printf(".");
firex=x;
firey=y;
gotoxy(oldx,oldy);printf(" ");
}
}
void main() {
clrscr();
player();
fire();
}
can you fix this problem?(becouse i couldnt)
Last edited by condorx; 02-23-2002 at 10:47 AM.
-
"The Oldest Member Here"
in fire(), at the end before while(1) stops, say x++;
Popular pages
Recent additions