Movement

This is a discussion on Movement within the C++ Programming forums, part of the General Programming Boards category; Hi, first question. How would you input movement into a program? I'm using Borland C++. To define my question a ...

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Movement

    Hi, first question. How would you input movement into a program?
    I'm using Borland C++. To define my question a little better: I want to make a game where you move an asterisk around the screen. Well, I have the key movement, but I don't know how to show the space between where the asterisk was and where it is now. Here's the code:

    #include <conio.h>
    #include <iostream.h>
    #define left arrow = 'A'
    #define up arrow = 'Q'
    #define down arrow = 'Z'
    #define right arrow = 'S'
    void main()
    {
    cout << "YOU NEED CAPS-LOCKS ON TO RUN THE PROGRAM" << endl;
    cout << endl << "Controls: " << endl;
    cout << "S Right" << endl;
    cout << "A Left" << endl;
    cout << "Q Up" << endl;
    cout << "Z Down" << endl << endl;
    cout << "*";
    char spc[2]=" ";//Space for movement
    int lp=1;
    while(lp!=0)
    {
    char ch;
    ch = getch();
    if(ch == 'S')//Right
    {
    clrscr();
    cout << "--*";
    }
    if(ch == 'A')//Left
    {
    clrscr();
    cout << "*--";
    }
    if(ch == 'Q')//Up
    {
    clrscr();
    cout << "I" << endl << "*";
    }
    if(ch == 'Z')//Down
    {
    clrscr();
    cout << "*" << endl << "I";
    }
    }
    }

  2. #2
    Unregistered
    Guest
    use a 2D char array with spaces everywhere but where you want to show the asterix, OR look up gotoxy().

  3. #3
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    are you planning on making walls with = and ||? That would be cool!

  4. #4
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    using == as a character to build a wall is a good idea

  5. #5
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    using == as a character to build a wall is a good idea

  6. #6
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Talking Reply

    Thanx... I created the program using gotoxy(). Sure, I think I will make walls using =.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program to control Cursor movement in C
    By beginner in forum C Programming
    Replies: 2
    Last Post: 06-25-2011, 12:20 PM
  2. Ship Movement
    By gustavosserra in forum Game Programming
    Replies: 8
    Last Post: 11-27-2004, 07:00 PM
  3. I need movement...
    By Finchie_88 in forum C++ Programming
    Replies: 1
    Last Post: 10-04-2004, 04:10 PM
  4. natural leg movement
    By DavidP in forum Game Programming
    Replies: 32
    Last Post: 01-11-2004, 09:01 AM
  5. Movement problem...
    By Umoniel in forum C Programming
    Replies: 2
    Last Post: 11-10-2002, 12:46 PM

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