Page 1 of 1

Sine Scroller with scrolling background

Posted: Fri Mar 06, 2015 5:04 pm
by DrChip
REM Sine Scroller with Animated Back
REM iPhone 6 Plus / 8.3 b2
REM have fun!
' I modified my sine scroller and
' added a animated background.
' Any background that moves
' makes your program look nicer!

'setup screen
sw=Screen_Width()
sh=Screen_Height()
pi=3.1415
graphics

'text to scroll
s$="This is a test to see if the scroller is moving in a sine pattern..."
' blaaablaaa....


DIM strTextScroll$(LEN(s$)+1)
DIM trix(4),triy(4)
x = sw + LEN(s$)

'text information
space = 20
speed = 6
fontsize = 30
ypos = (sh/2)-(fontsize/2)

' sine informtion
height = 220
amp = 13


gridspeed = 10 'pos forward 10, neg backward -10
deltaspeed = 1 ' rate of inc...
stepp = 160 ' block size
ste = stepp/2
scrollmin=50
scrollmax=50
r=rnd(1)!g=rnd(1)!b=rnd(1)
dr=.01!dg=.01!db=.01
main:
r=r+dr!g=g+dr!b=b+db
if r>1 or r<0 then dr=-dr
if g>1 or g<0 then dg=-dg
if b>1 or b<0 then db=-db
refresh off
graphics clear r,g,b
GOSUB background
GOSUB scroller
refresh on
GOTO main

scroller:
x=x-speed
IF x < -(LEN(s$)*space) THEN
x = sw + LEN(s$)-1
END If
FOR i = 0 TO LEN(s$)-1
strTextScroll$(i) = mid$(s$,i,1)
yOffset = INT(y + (height * SIN(dAngle-(i*amp))/(10)))
yOffset2 = INT(y + (height * COS(dAngle-(i*amp))/(10)))
strTemp$ = "" & strTextScroll$(i)
draw COLOR 1,1,1
DRAW TEXT strTemp$ at x+(i*space), ypos+ yOffset
draw COLOR 100/255,100/255,100/255
DRAW TEXT strTemp$ at x+(i*space), ypos+ yOffset2+50
NEXT i
dAngle=dAngle+1
RETURN


background:
gridspeed=gridspeed+deltaspeed
IF gridspeed > scrollmin OR gridspeed < -scrollmax THEN
deltaspeed = -deltaspeed
END IF

'Draw Background
z=z+gridspeed
IF z>=0 THEN
z=z-gridspeed
END IF

FOR h=z TO sh STEP stepp
FOR w=0 TO sw STEP stepp
fill COLOR 15/255,15/255,60+(h/3)/256
fill RECT w,h to w+ste,h+ste
fill RECT w+ste,h+ste to w+stepp,h+stepp
NEXT w
NEXT h
RETURN