help me

This is a discussion on help me within the Game Programming forums, part of the General Programming Boards category; i wanna write a program that has a jet( : -> ) and it has ability to fire but the ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    80

    Question 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.

  2. #2
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    in fire(), at the end before while(1) stops, say x++;

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21