Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Displaying x and y values....how?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
programingcat




PostPosted: 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 Arrow 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 Very Happy

multi
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: 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




PostPosted: Sat Sep 04, 2004 4:21 pm   Post subject: (No subject)

Before outputting the text, do a
code:

locate(1, 1)
Cervantes




PostPosted: 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)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: