Displaying x and y values....how?
Author |
Message |
programingcat
|
Posted: Sat Sep 04, 2004 3:57 pm Post subject: Displaying x and y values....how? |
|
|
I have a progarm where i need to have a shape move across the screen and then up the screen...that is done. I now need to create a sort of counter. It should look like this:
PixelX: xxx PixelY: yyy needs to be centered at the top
The bolded numbers need to constanly display the co-ordinates of my moving shape.
So far i can have the numbers displayed, but they list down the side and won't stay in the same place!
I know this sounds weird...but i hope one of you can help me!!!
-Programingcat
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: Sat Sep 04, 2004 4:20 pm Post subject: (No subject) |
|
|
You can postion text by using the locate and locatexy fuctions. locate gose by rows and cols while locatexy gose by pixels.
Ex.
code: |
locatexy(maxx-50,maxy)
put "hello"
|
Will put hello in the top right. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Mazer
|
Posted: Sat Sep 04, 2004 4:21 pm Post subject: (No subject) |
|
|
Before outputting the text, do a
|
|
|
|
|
|
Cervantes
|
Posted: Sun Sep 05, 2004 10:30 am Post subject: (No subject) |
|
|
And finally, you can use Font.Draw or Draw.Text
Turing Reference wrote:
Syntax Font.Draw (txtStr : string, x, y, fontID, Color : int)
Font.Draw is used to actually draw text in a specified font. The textStr parameter contains the string to be drawn. The x and y parameters are the location of the lower left hand corner of the text to be displayed. The fontID parameter is the number of the font in which the text is to be drawn. The Color parameter is used to specify the color in which the text is to appear.
Note that the text that appears is completely unrelated to the text that appears using put. Font.Draw is a graphics command and thus does not use or affect the cursor location.
The text drawn by the Font.Draw procedure does not erase the background.
Since txtStr must be a string, and since you want to output an integer (or real) variable, you must use intstr(i : int) (or realstr(r : real) )
code: |
var font := Font.New ("sans serif:18:bold")
Font.Draw (intstr(BALL_X), maxx div 2 - 50, maxy - 20, font, black)
|
|
|
|
|
|
|
|
|