TGC Codebase Backup



a Cool simple Scroll bar by Alastair Zotos

31st Dec 2003 7:32
Summary

This is a cool but simple scroll bar like you see on windows at the side of your screen, it isnt very decorated tho!



Description

This scroll bar is made pretty simply, the text movement has absolutely nothing to do with the actuall scroll bar. I made it by making a simple box and then making a sprite from it, then i made a variable and if the cursor is ontop of the halfway point of the bar, the bar would go up and the text would go down!



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `syncronize
sync on

`ask for info
print "Hello, this is a simple scroll bar program I made, to make it look"
print "better, you add some info about yourself, doesnt have to be real!"
print "Its just to show you how to make a simple scroll bar!"
print
print "Press any key to continue."
suspend for key
cls 0
input "Please enter your name: ",name$
cls 0
input "Please enter your age: ",age$
cls 0
input "Please enter you fav. band: ",band$
cls 0
print "Thank you!"
print 
print "Press any key to continue."
suspend for key 

`variables
y=0
s=0
b=620

`scroll bar
ink rgb(128,128,128),1
box 0,0,20,100
get image 1,0,0,20,100

`main loop
do

`get sprite from scroll bar
sprite 1,b,s,1

`print stuff
cls 0
ink rgb(255,255,255),1
set cursor 0,y
print "Hello ";name$
print "My name is Alastair!"
print "I see your ";age$;" years old!"
print "Im 13."
print "So your fav. band is ";band$;" ?"
print "My fav. band is Metallica!"
print "They rock!"
print 
print " |)|)"
print "( - -)"
print "/__(')')"
print
print "BEWARE OF THE BUNNY!"
print
print "(lol, do you like this bunny!)"
print "I'll have to see you later!"
print
print "Bye!"

`move scroll bar
if mousex()>b and mousey()>s and mousey()<s+50 and mouseclick()=1
dec s,10
inc y,10
endif
if mousex()>b and mousey()>s+25 and mousey()<s+100 and mouseclick()=1
inc s,10
dec y,10
endif

`fast move scroll bar
if mousex()>b and mousey()<s and mouseclick()=1
dec s,30
inc y,30
endif
if mousex()>b and mousey()>s+100 and mouseclick()=1
inc s,30
dec y,30
endif

`update scroll bar
if s<0 then s=0
if y>0 then y=0
if s>380 then s=380

`end loop
sync
loop