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

Username:   Password: 
 RegisterRegister   
 Floating text
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CChanni




PostPosted: Tue Jan 15, 2008 2:58 pm   Post subject: Floating text

Is there some way to make text float around the screen?
Sponsor
Sponsor
Sponsor
sponsor
Sean




PostPosted: Tue Jan 15, 2008 3:30 pm   Post subject: Re: Floating text

Like in which way?
StealthArcher




PostPosted: Tue Jan 15, 2008 5:06 pm   Post subject: RE:Floating text

Have you made a bouncing ball program before?

If so just alter the variables the same way for a Font.Draw procedure, and clear and redaw for effect.
CChanni




PostPosted: Tue Jan 15, 2008 6:39 pm   Post subject: Re: Floating text

Okay, I'll try that. Thanks for your help!
CChanni




PostPosted: Tue Jan 15, 2008 7:15 pm   Post subject: Re: Floating text

How do you make the program so that you can add different text but allow them to move at different paces?
TokenHerbz




PostPosted: Tue Jan 15, 2008 7:25 pm   Post subject: RE:Floating text

Try assigning the word to an array, meaning...

Word is : Help!

array1 = H
array2 = e
array3 = l
array4 = p
array5 = !

Now that you have the 5 single letters, your free to minipulate each one accordingly and seperatly from the rest. Or you can go with easier methods, but i dont know those.... Muhahaha math is fun!
CChanni




PostPosted: Tue Jan 15, 2008 8:16 pm   Post subject: Re: Floating text

No! I'm only in Grade 10 Computer Science, I haven't learned arrays yet...
syntax_error




PostPosted: Tue Jan 15, 2008 8:28 pm   Post subject: Re: Floating text

a) just because you haven't learned something does not mean you can NOT learn it
everything is within ur reach here at compsci.ca here a thought try the turing tuts there they are soo detailed and full of example and then again after you give it a try at it we can help you at it see the glory in this??

b) since im soo nice i will give you the link to the array section here
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Tue Jan 15, 2008 9:09 pm   Post subject: RE:Floating text

CChanni do you want to have each character move independently, or together? If they move together, all you need is basic a understanding of collision detection and the Font module.
petree08




PostPosted: Wed Jan 16, 2008 11:11 am   Post subject: RE:Floating text

You don't need to have an array to select individual characters in a string, because a string is just an array of chars

example

variable Name has the value "Peter"

lets say we want to output the 2nd letter in the Name var

var Name : string

Name := "Peter"

put Name (2)

---------

the screen should output the letter "e"

-----------

This manipulation of strings can also have more than one character selected

put Name (1..5)

-----
This will display the first to 5th characters in the var

-----
Also

put Name (1 ..*) % this outputs the first to last char in the string

-----

hope that helps happy coding
CChanni




PostPosted: Wed Jan 16, 2008 12:43 pm   Post subject: Re: Floating text

@ericfourfour: I want them to move independently.
Zampano




PostPosted: Wed Jan 16, 2008 1:57 pm   Post subject: Re: Floating text

No one's actually explained what you are supposed to do assuming little previous knowledge so I will.
Have variables holding the x and y coordinates of each letter. have a loop which changes both the x and y by a random amount each time through (look in to Rand.Int). Finally, factor the x and y of each letter into the Draw.Text function for each respective letter. Add in some View.Update and a delay and all have left is to make sure that the letter don't go offscreen.
To do this compare the letters' x and ys with both maxx and maxy (of the screen) and 0. If they are below 0 or above the maxes of the screen, revert them to a position just on the edge of the screen (by adjusting x and y directly). This creates the illusion of a wall.
Always remember to search for information on aspects of programming in Turing help (F10).
CChanni




PostPosted: Wed Jan 16, 2008 7:25 pm   Post subject: Re: Floating text

Below is a post of my program. I think I did everything you said but I'm not sure, so can you check it for me?



View.Set("graphics:max;max;noecho")
var font:int
font:=Font.New ("MS Reference Sans Serif:11")
var x:= 7
var y:=7
var xChange, yChange : int := 4
var i: int

loop
x:=y
put Rand.Int (x,y)
cls
Draw.Text ("1", x, y, font, red)
delay (10)
View.Update
delay (10)
x += xChange
y += yChange
if x < 8 or x > maxx - 9 then
xChange := -xChange
end if
if y < 8 or y > maxy - 9 then
yChange := -yChange
cls
end if
end loop

loop
cls
x:=y
put Rand.Int (x,y)

cls
Draw.Text ("5", x, y, font, red)
delay (10)
View.Update
delay (10)
x += xChange
y += yChange
if x < 8 or x > maxx - 9 then
xChange := -xChange
end if
if y < 8 or y > maxy - 9 then
yChange := -yChange
cls
end if
end loop
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  [ 13 Posts ]
Jump to:   


Style:  
Search: