Text in a sinus-curve

Started by
2 comments, last by Johannes_A 22 years ago
Hello everybody... I need some help to create a demo in OpenGL... I want to make a text scroll in a sinus-curve, like in those old Amiga demos... but i have no idea how to do it :/ Does anyone know where to get an example or something? Thanks /Johannes
Advertisement
I suppose you use the sinus function then! :D
Seriously, How I would have done it was something like this. You first load up all the text in seperate variables, i mean each letter in one variable.. not all the text in one if you know what I mean. Anyways, when you''ve sorted that out, you get the letters to move in the direction you want. let''s say; Right.. Well, and while the text is moving right(Along the X axis), you also want the text to move up and down. Obviously this is where you get to use that sinus function. You need a loop from 0 to 360 degrees as well.. or something which counts from 0 and upwards.. it dosent matter if you loop it cause sin(0), sin(360) and sin(720) is the same result..
ie:
Text[charNumber].Pos.x+= 1.0f;
Text[charNumber].Pos.y+= sin(theVariableThatCounts)*amplitude;
where amplitude is how much you want the text to be swinging around.. I believe.. =)

Wherthere this actually works, I dont know(someone back me up).. But I''m only thinking theory here you''d have to figure the code out for youself.

Good Luck

Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder
quote:Original post by kenwi
I suppose you use the sinus function then! :D
Seriously, How I would have done it was something like this. You first load up all the text in seperate variables, i mean each letter in one variable.. not all the text in one if you know what I mean. Anyways, when you''ve sorted that out, you get the letters to move in the direction you want. let''s say; Right.. Well, and while the text is moving right(Along the X axis), you also want the text to move up and down. Obviously this is where you get to use that sinus function. You need a loop from 0 to 360 degrees as well.. or something which counts from 0 and upwards.. it dosent matter if you loop it cause sin(0), sin(360) and sin(720) is the same result..
ie:
Text[charNumber].Pos.x+= 1.0f;
Text[charNumber].Pos.y+= sin(theVariableThatCounts)*amplitude;
where amplitude is how much you want the text to be swinging around.. I believe.. =)

Wherthere this actually works, I dont know(someone back me up).. But I''m only thinking theory here you''d have to figure the code out for youself.

Good Luck

Kenneth Wilhelmsen
Try my little 3D Engine project, and mail me the FPS. WEngine
Or just visit my site
--------------------------
He who joyfully marches to music in rank and file has already earned my contempt. He has
been given a large brain by mistake, since for him the spinal cord would fully suffice. This
disgrace to civilization should be done away with at once. Heroism at command, senseless
brutality, deplorable love-of-country stance, how violently I hate all this, how despicable and ignoble war is; I would rather be torn to shreds than be a part of so base an action! It is my conviction that killing under the cloak of war is nothing but an act of murder


Thanks...
but i didn''t get the code to work... i think i would be easier if some one knew where to get an example.. :/
thats because you failed to understand the concept. its quite simple really, you use sin() to get the wave effect because if you every plotted the curve you would know you only get values between -1.0 and 1.0, furthermore realizing that you can multiple a value you against this to scale the values. i am sure you know how to draw text across the screen in a straight line, well you do that except you use sin to modify the height. now you are saying how can a figure out what values to give the sin() function, well is takes radians nd and from basic math you learned how to ocnvert degrees to radians. i will leave the rest up to you, i will not promote your cut and paste coding.

for gods sakes do some expiermenting. understand the concept and the code will flow.

This topic is closed to new replies.

Advertisement