Thread: gotoxy

  1. #1
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    gotoxy

    when i use it to move a @ around the screen just right and down first i have to hold 1 or 2 down before it even moves then it starts to be like if you hit 2 some times it goes over instead of down heres my code:
    Code:
    int main()
    {
    char in;
    int x = 0;
    int y = 0;
    
    gotoxy(0, 0);
    cout<<"@"<<endl;
    
    while(1 == 1)
    {
    in = getch();
    
    switch(in)
    {
    case '1':
    clrscr();
    gotoxy(x++, y);
    cout<<"@"<<endl;
    break;
    case '2':
    clrscr();
    gotoxy(x, y++);
    cout<<"@"<<endl;
    break;
    }
    }
    }
    +++
    ++
    + Sekti
    ++
    +++

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    gotoxy(x++, y);

    x is incremented after the gotoxy is performed. You would like to increment it before that happens. gotoxy(++x, y);
    Likewise in the y-line.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    thanks

    thanks man
    +++
    ++
    + Sekti
    ++
    +++

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is gotoxy??
    By Beachblue in forum C Programming
    Replies: 6
    Last Post: 11-23-2008, 01:24 AM
  2. Tic Tac Toe movement
    By $l4xklynx in forum Game Programming
    Replies: 4
    Last Post: 11-06-2008, 07:22 PM
  3. gotoxy(); help!!
    By clique in forum C Programming
    Replies: 2
    Last Post: 10-07-2008, 04:08 AM
  4. Want to see if I am using gotoxy the right way ...
    By o0obruceleeo0o in forum C++ Programming
    Replies: 5
    Last Post: 04-22-2003, 04:17 PM
  5. Is gotoxy ansi?
    By MeneLaus in forum C Programming
    Replies: 2
    Last Post: 05-18-2002, 02:48 PM