Sin Text Scroller

Blitz3D Forums/Blitz3D Beginners Area/Sin Text Scroller

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I figured out what my problem was. I need to recalculate the mod value according to the length of the text that's being scrolled. But, how do I calculate the mod value versus the text length??

(you can see I'm working on a slightly modified version of the bullet code posted by Semar in this forum for the ice flakes)

pic of demo in action here
demo in action

; LoadImage and DrawImage example 

; Declare a variable to hold the graphic file handle 
Global gfxBG, gfxflare
; Set a graphics mode 
Graphics3D 640, 480,32, 1
; Set drawing operations for double buffering 
SetBuffer BackBuffer() 
TFormFilter 1
Color 0,0,0
SeedRnd MilliSecs()
grlx = 1
grlxdir = 1
grly = 1
Type t_bullet
Field x,y
Field speedx,speedy
End Type
Global bullet.t_bullet
; Load the image and assign its file handle to the variable 
; - This assumes you have a graphic called player.bmp in the 
; same folder as this source code 
gfxBG=LoadImage("coolblue.png")
gfxgirl=LoadImage("amigagirl.png")
gfxflare=LoadImage("ice.png")
chnBackground=PlayMusic("z-tower.xm")
; Let's do a loop where the graphic is drawn wherever the 
; mouse is pointing. ESC will exit. 

While Not KeyHit(1) 
; clear the screen 
Cls
DrawImage gfxBG, 1, 1
x=MilliSecs()/10.0 Mod 2400
bulletchance = Rnd(0,10): If bulletchance = 5 Then bullet.t_bullet = New t_bullet: bullet\x = Rnd(0,200): bullet\y = Rnd(0,10): bullet\speedx = Rnd(1,3): bullet\speedy = Rnd(1,3)
bulletchance2 = Rnd(0,100): If bulletchance = 10 Then bullet.t_bullet = New t_bullet: bullet\x = Rnd(0,200): bullet\y = Rnd(0,10): bullet\speedx = Rnd(1,3): bullet\speedy = Rnd(1,3)
updategame()
rendergame()
;x=MilliSecs()/10.0 Mod 800
;If grlxdir = 1 Then grlx = grlx - 1
;If grlxdir = 2 Then grlx = grlx + 1
;If grlx = -639 Then grlxdir = 2
;If grlx = 1 Then grlxdir = 1
SinScroll (" ............... CodeD aka (DJ) Krazy K Presents Amiga Tribute Vol. 1 ... Press up/down to change songs ... Code: CodeD, Jeppe Neilson (SinScroll) Gfx: FrogDot (thx for the babe!), CodeD ... Mods for Charity ... your donations help children!!! ... Visit <a href="http://sites.gwala.net/tormented/amiga" target="_blank">http://sites.gwala.net/tormented/amiga</a> for more info and to order the CD ... greetings to: Ckob, Lenn, Noel Cower, JFK, DJ SeeNSay, LizardKing, FutureCrew, Paradox, Mark Sibly & The Blitz Basic Crew, The Anonymous Modder ... Gotta have mod??  Amiga Tribute Vol. 2 coming soon!!  Cybernoid 3D coming soon!! Quality apps like this and more from CrapSoft and Evolved Dev Studios ............................ ", -x-2400, 300, MilliSecs()/10.0)
SinScroll (" ............... CodeD aka (DJ) Krazy K Presents Amiga Tribute Vol. 1 ... Press up/down to change songs ... Code: CodeD, Jeppe Neilson (SinScroll) Gfx: FrogDot (thx for the babe!), CodeD ... Mods for Charity ... your donations help children!!! ... Visit <a href="http://sites.gwala.net/tormented/amiga" target="_blank">http://sites.gwala.net/tormented/amiga</a> for more info and to order the CD ... greetings to: Ckob, Lenn, Noel Cower, JFK, DJ SeeNSay, LizardKing, FutureCrew, Paradox, Mark Sibly & The Blitz Basic Crew, The Anonymous Modder ... Gotta have mod??  Amiga Tribute Vol. 2 coming soon!!  Cybernoid 3D coming soon!! Quality apps like this and more from CrapSoft and Evolved Dev Studios ............................ ", -x-1-2400, 300, MilliSecs()/10.0)
DrawImage gfxgirl, grlx, 1
;SinScroll (" ............... CodeD aka (DJ) Krazy K Presents Amiga Tribute Vol. 1 ... Press up/down to change songs ... Code: CodeD, Jeppe Neilson (SinScroll) Gfx: FrogDot (thx for the babe!), CodeD ... Mods for Charity ... your donations help children!!! ... Visit <a href="http://sites.gwala.net/tormented/amiga" target="_blank">http://sites.gwala.net/tormented/amiga</a> for more info and to order the CD ... greetings to: Ckob, Lenn, Noel Cower, JFK, DJ SeeNSay, LizardKing, FutureCrew, Paradox, Mark Sibly & The Blitz Basic Crew, The Anonymous Modder ... Gotta have mod??  Amiga Tribute Vol. 2 coming soon!!  Cybernoid 3D coming soon!! Quality apps like this and more from CrapSoft and Evolved Dev Studios ............................ ", 800-x, 300, MilliSecs()/10.0)
;SinScroll (" ............... CodeD aka (DJ) Krazy K Presents Amiga Tribute Vol. 1 ... Press up/down to change songs ... Code: CodeD, Jeppe Neilson (SinScroll) Gfx: FrogDot (thx for the babe!), CodeD ... Mods for Charity ... your donations help children!!! ... Visit <a href="http://sites.gwala.net/tormented/amiga" target="_blank">http://sites.gwala.net/tormented/amiga</a> for more info and to order the CD ... greetings to: Ckob, Lenn, Noel Cower, JFK, DJ SeeNSay, LizardKing, FutureCrew, Paradox, Mark Sibly & The Blitz Basic Crew, The Anonymous Modder ... Gotta have mod??  Amiga Tribute Vol. 2 coming soon!!  Cybernoid 3D coming soon!! Quality apps like this and more from CrapSoft and Evolved Dev Studios ............................ ", 800-x-800, 300, MilliSecs()/10.0)
Flip ; flip the image into view and clear the back buffer 
Wend 
;===================================
Function updategame()
;===================================
For bullet.t_bullet = Each t_bullet
bullet\x = bullet\x + bullet\speedx
bullet\y = bullet\y + bullet\speedy
Next
End Function
;===================================
Function rendergame()
;===================================
For bullet.t_bullet = Each t_bullet
;the bullet image is a global image called image_bullet

DrawImage gfxflare,bullet\x,bullet\y
Next
End Function
Function SinScroll(txt$,x,y,am,amp=50,per=20,d=10)
For n=1 To Len(txt$)
Text x+xx,y+Sin(am+n*per)*amp,Mid$(txt$,n,1)
xx=xx+d
Next
End Function