Thread: Coordinates

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    28

    Coordinates

    Does anyone have an idea how can i get the coordinates so i will know where am i typing when i use coordinates.

    Like

    x=5, y=20; i know approximately where that is, but i need the exact thing.

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    To do this you have to use goto coordinates.

    The line of code would look like this:

    Code:
    gotoxy(12,15);cout << "text goes here";
    but to make this work in your code, you need to create a function to understand the above coide.. here is one i created for my games:

    Code:
    void gotoxy( int x, int y ) 
    { 
        COORD c; 
    
    	c.X = x - 1 ; 
     	c.Y = y - 1 ; 
     	
     	// TO REMEMBER: 1ST NUMBER SPACES IN :: 2ND NUMBER SPACES DOWN
    
    	SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), c ) ; 
    }

  3. #3
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    You also need to understand that the above code requires <windows.h> and will only run on the Windows operating system. There is no standard way.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    This is a platform dependant operation. These details would be appropriate now. You might look into:

    Low-level I/O <= Windows
    NCURSES (?) <= *nix

    Edit: do you just wanna move the cursor around with that "gotoxy" or do you want to recieve notifications of user input in character cell coordinates?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get relative mouse coordinates when GLUT return absolute
    By joeprogrammer in forum Game Programming
    Replies: 14
    Last Post: 02-10-2009, 06:35 PM
  2. values into array based on coordinates
    By BabyWasabi in forum C++ Programming
    Replies: 1
    Last Post: 12-13-2006, 07:48 PM
  3. Global coordinates in OpenGL?
    By IcyDeath in forum C++ Programming
    Replies: 1
    Last Post: 11-25-2004, 06:29 PM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. Size of 1 pixel
    By ooosawaddee3 in forum C++ Programming
    Replies: 4
    Last Post: 07-26-2002, 08:06 PM