Author Topic: Sinus scrolling done right?  (Read 2461 times)

0 Members and 1 Guest are viewing this topic.

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Sinus scrolling done right?
« on: January 26, 2008 »


I know how to make my text flow in sin() waves but my question is how to do it "correctly".

How do you usually pair this with scrolling text?

What is the method used most commonly to make your scrollers wrap around the screen?

How do you avoid slowdown when you are drawing say 20 sentences?

That is alot to ask at once but I would like to start with the best solution rather than poke around in the dark on this one.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Sinus scrolling done right?
« Reply #1 on: January 26, 2008 »
Slowdown should not really be a problem on todays computers, the method behind a sine scroll is straight forward.

If you view your letter as a bitmap:

Code: [Select]
  #####
#######
##      ##
#######
##      ##
##      ##

It is made out of rows and columns.
In most programming languages/apis there is usually a method that allows you to cut a rectangle out of a bitmap and draw it.

So for the letter "a" above the program would need to  chop it up into vertical slices which can then be drawn in the right position.

Sin is straight forward;

n=sin(theta)

Returns a value in n between -1 and +1 depending on the angle you feed it (theta).

you can transform this into something more useful;

y=(99*sin(theta)) + 100

Produces a large sine wave that ranges from the top of the screen to about 200 pixels down.

So it's really a matter of chopping those letters up and drawing them in the right place. On the Amiga, they were done using the Blitter chip, you could set up a "blitter window" and move this around as you were blitting the letters.

There are dozens of sine scrollers here, if you need more help please ask :)
Shockwave ^ Codigos
Challenge Trophies Won: