DarkForge Snippets Volume 5 Intro by Richard Davey29th Sep 2003 14:10
|
---|
Summary A large bouncing scroller, bouncing stars and distorting logos! Old-skool rules - sorry for the poor code structure, no time to optimise. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` ------------------------------------------------------------------------- ` Snippets Volume 5 Intro DarkForge 10/2/2001 ` ------------------------------------------------------------------------- ` A large bouncing scroller, bouncing stars and distorting logos! ` Old-skool rules - sorry for the poor code structure, no time to optimise. sync rate 0 sync on hide mouse load bitmap "geo_font.bmp",1 load bitmap "dflogo.bmp",7 ` Pre-calc the sine wave sih = bitmap height(7) siw = bitmap width(7) set current bitmap 7 for i=1 to sih get image i,0,i-1,siw,i next i create bitmap 2,640,480 r = 0 : e = 120 : step = 3 : sx = 0 : speed = 3 repeat cls ` pre-calc the sine wave pattern for i=1 to sih s# = 30+sin(sx+i*step)*25 paste image i,s#,i next i get image 1000+r,0,0,325,sih ` pre-calc the cosine wave pattern for i=1 to sih s# = 30+cos(sx+i*step)*25 paste image i,s#,sih+i next i get image 1500+r,0,sih,325,sih+sih inc sx,speed : inc r until r=e for i=1 to sih delete image i next i set current bitmap 0 delete bitmap 2 cls ` Make our little star graphic and arrays ink rgb(0,255,255),0 : dot 1,1 ink rgb(100,50,155),0 : dot 1,0 : dot 1,2 : dot 0,1 : dot 2,1 get image 2100,0,0,3,3 n=75 dim stx(n,3) for i=1 to n stx(i,1)=rnd(639)+1 stx(i,2)=rnd(479)+ 1 stx(i,3)=rnd(7)+3 next i cls ` Get scroller font set set current bitmap 1 os=5 : s=10 : ox=32 : oy=30 : x=0 : y=0 : bw#=ox*os for i=1 to 60 get image i,x,y,x+ox,y+oy inc x,ox if x>=319 x=0 inc y,oy endif sync next i i=1 create bitmap 2,640,480 if os>1 for z=61 to 120 create bitmap 1,ox*os,oy*os paste image i,0,0 set current bitmap 2 copy bitmap 1,0,0,ox,oy,2,0,0,ox*os+os,oy*os get image z,0,0,ox*os+os,oy*os inc i next z endif set current bitmap 0 delete bitmap 2 bc=640/bw#+1 for a=1 to bc st$=st$+" " next a read s$ st$=st$+s$ lot=len(st$)+1 if lot<12 then st$=st$+" " dim x#(bc) dim t$(bc) for a=1 to bc x#(a)=bw#*a t$(a)=mid$(st$,a) as=asc(t$(a)) next a y=(480-oy*os)/2 : t=bc create bitmap 3,640,480 : r=0 ` The Main Loop do cls s# = 1+sin(sx+i*step)*25 for i=1 to n stx(i,1)=stx(i,1)-stx(i,3) if stx(i,1)<=1 stx(i,1)=640 stx(i,2)=rnd(479)+1 endif paste image 2100,stx(i,1),stx(i,2)+s# next i inc sx,speed ` sine wave routine for a=0 to 480-sih step sih*2 paste image 1000+r,180,a,1 paste image 1500+r,180,a+sih,1 next a inc r : if r=e then r=0 ` scroller routine for a=1 to bc x#=x#(a) dec x#,s if x#=<-0-bw# x#(a)=640 inc t if t=lot t=1 read st$ if st$="*" restore read st$ endif lot=len(st$)+1 endif t$(a)=mid$(st$,t) else x#(a)=x# endif as=asc(t$(a)) paste image 29+as,x#(a),175+sin(y)*180,1 next a inc y copy bitmap 3,0 sync loop data "DARKFORGE PRESENTS YOU WITH SNIPPETS VOLUME 5! YEEHAAA... " data "DAMN I LOVE SCROLLTEXTS... THIS ONE USES MY MEGASCROLLER " data "ROUTINE FROM LAST YEAR BUT WITH THE NEW DB 1.07 PASTE IMAGE " data "FUNCTIONS FOR EXTRA SPEED! THIS RUNS AT A SMOOTH 60 FPS ON MY " data "P3 450 WITH GEFORCE CARD... " data "HAVE YOU VISITED MY WEB SITE YET? IT IS AT WWW.DARKBASIC.ORG " data "AND CONTAINS LOADS OF THE LATEST DB NEWS AND RELEASES AS WELL " data "AS SOME FUNKY-ASS FREE SERVICES. " data "THIS SNIPPETS VOLUME IS A LITTLE LATER THAN I WOULD HAVE LIKED " data "BUT I'VE BEEN HARD AT WORK ON ANOTHER PROJECT WHICH SHOULD BE OUT " data "SOON TOO! ALSO THE CODE IN THIS VOLUME IS SOME OF MY BEST YET FOR " data "PURE SPEED AND OPTIMISATIONS. I WILL BE WORKING ON SOME GAMES NEXT " data "JUST BECAUSE I FEEL LIKE IT AGAIN, BUT OF COURSE DEMO FANS WILL " data "NOT BE DISAPPOINTED EITHER! IF YOU WANT TO HAVE YOUR OWN SNIPPETS " data "FEATURED ON VOLUME 6 THEN WHY NOT EMAIL THEM TO ME? THE ADDRESS IS " data "RICH AT DARKFORGE.CO.UK " data "OKAY THAT IS ALL I HAVE TIME FOR RIGHT NOW, SEE YOU SOON PEOPLE!" data " LETS WRAPPPPPP..................... " data "*" |