REM Project: side scroller Rem By Coding Fodder sync on:sync rate 0 color backdrop 0 backdrop off hide mouse dim screen(33,24) global bd_height# global bd_dx# global bd_dx2 global score global tiles bd_height#=0.0 bd_dx2=1 create bitmap 1,640,480 make_sprites() for i=1 to 640 generate_background() next i for i=1 to 33 screen(i,23)=1 next i ballx#=320 bally#=20 DO if rightkey()=1 inc ballx# rotate sprite 103,wrapvalue(sprite angle(103)+5.73) if ballx#>320 ballx#=320 dec x inc cycle endif if x=-20 x=0 make_level() inc tiles if tiles>1000 then endgame() endif endif if leftkey()=1 dec ballx# if ballx#<0 then ballx#=0 rotate sprite 103,wrapvalue(sprite angle(103)-5.73) endif bvy#=bvy#+0.1 bally#=bally#+bvy# if screen(int(ballx#/20.0+0.5),int(bally#/20.0))=1 or screen(int(ballx#/20.0+0.5)+1,int(bally#/20.0))=1 bally#=20*(int(bally#/20.0)) if spacekey()=1 bvy#=0 else bvy#=-bvy# endif if bvy#<1 if ballx#=0 then bvy#=-4 endif endif if screen(int(ballx#/20.0+0.5),int(bally#/20.0-1.0))=1 or screen(int(ballx#/20.0+0.5)+1,int(bally#/20.0-1.0))=1 bally#=20*(int(bally#/20.0+1)) if spacekey()=1 bvy#=-bvy# else bvy#=0 endif endif if screen(int(ballx#/20.0+0.5),int(bally#/20.0-1))=2 or screen(int(ballx#/20.0+0.5)+1,int(bally#/20.0-1))=2 bally#=20*(int(bally#/20.0)) bvy#=-4 endif if screen(int(ballx#/20.0+1),int(bally#/20.0-1.0))=3 screen(int(ballx#/20.0+1),int(bally#/20.0-1.0))=0 inc score,10 endif if screen(int(ballx#/20.0),int(bally#/20.0-1.0))=3 screen(int(ballx#/20.0),int(bally#/20.0-1.0))=0 inc score,10 endif if bally#>460 bally#=460 bvy#=0 endif if bally#<20 bally#=20 endif if cycle=3 generate_background() cycle=0 endif copy bitmap 1,0 for i=0 to 32 for j=0 to 23 if screen(i,j)=1 then paste sprite 101,i*20+x,j*20 if screen(i,j)=2 then paste sprite 102,i*20+x,j*20 if screen(i,j)=3 then paste sprite 104,i*20+x,j*20 next j next i paste sprite 103,int(ballx#)-cos(sprite angle(103)+45)*10.0*sqrt(2.0)+10,int(bally#)-sin(sprite angle(103)+45)*10.0*sqrt(2.0)-10 text 100,1,"Score "+str$(score) text 1,1,"Distance "+str$(tiles) sync LOOP function make_sprites() br#=0.2 for i=0 to 20 for j=0 to 20 am=100-int(sqrt((i-10.0)^2.0+(j-10.0)^2.0)*5.5) ink rgb(am-abs((i-10)*(j-10)*br#),am-abs((i-10)*(j-10)*br#),am+155),0 dot i,j next j next i get image 101,0,0,20,20 sprite 101,0,0,101 `set sprite alpha 101,99.9 hide sprite 101 ink 0,0 cls br#=0.2 for i=0 to 20 for j=0 to 20 if i+j>=19 am=100-int(sqrt((i-10.0)^2.0+(j-10.0)^2.0)*5.5) ink rgb(am-abs((i-10)*(j-10)*br#),am-abs((i-10)*(j-10)*br#),am+155),0 dot i+20,j+20 endif next j next i get image 102,20,20,40,40 sprite 102,20,20,102 SET SPRITE TEXTURE COORD 102, 0, 0.05, 0.05 hide sprite 102 cls br#=0.2 for i=0 to 20 for j=0 to 20 if sqrt((i-10.0)^2.0+(j-10.0)^2.0)-0.5<=10.0 am=100-int(sqrt((i-10.0)^2.0+(j-10.0)^2.0)*5.5) ink rgb(am+155,am,am),0 dot i+40,j+40 endif next j next i get image 103,40,40,60,60 sprite 103,20,20,103 `set sprite alpha 103,99.9 hide sprite 103 cls br#=0.2 for i=0 to 20 for j=0 to 20 if abs(i-10.0)+abs(j-10.0)<=10.0 am=100-int((abs(i-10.0)+abs(j-10.0))*5.5) ink rgb(am+155,am+100,am),0 dot i+40,j+40 endif next j next i get image 104,40,40,60,60 sprite 104,20,20,104 `set sprite alpha 103,99.9 hide sprite 104 endfunction function make_level() for i=0 to 32 for j=0 to 23 screen(i,j)=screen(i+1,j) next j next i screen(33,23)=1 for j=3 to 22 if rnd(100)<2 if screen(32,j-1)=0 and screen(33,j-1)=0 and screen(32,j-2)=0 and screen(33,j-2)=0 and (screen(32,j+1)=1 or screen(32,j+2)=0) then screen(33,j)=2 else screen(33,j)=0 endif if screen(32,j)>0 and screen(32,j)<3 if rnd(100)<92 screen(33,j)=1 else screen(33,j)=0 endif endif if rnd(100)<2 if screen(33,j)=0 screen(33,j)=3 endif endif next j endfunction function generate_background() set current bitmap 1 copy bitmap 1,1,0,640,479,1,0,0,639,479 max_slope#=0.6 lock pixels if bd_dx2=1 bd_dx#=bd_dx#+(rnd(10)/200.0) if bd_dx#>max_slope# then bd_dx#=max_slope# bd_height#=bd_height#+bd_dx# if bd_height#>230.0 then bd_dx2=-1 else bd_dx#=bd_dx#-(rnd(10)/200.0) if bd_dx#<-max_slope# then bd_dx#=-max_slope# bd_height#=bd_height#+bd_dx# if bd_height#<50.0 then bd_dx2=1 endif if rnd(500)<10 if bd_dx2=1 bd_dx2=-1 else bd_dx2=1 endif endif for i=0 to 479-int(bd_height#) if i>-1 and i<480 then set_locked_pixel(639,i,rgb(i/4,i/4,i/2.3+50)) next i for i=479-int(bd_height#) to 479 if i>-1 and i<480 then set_locked_pixel(639,i,rgb(int((479-i)/3),rnd(50)+10+int((479-i)*190.0/bd_height#),int((479-i)/2.5))) next i unlock pixels set current bitmap 0 endfunction function set_locked_pixel(x,y,color_value) start=get pixels pointer() repeat_number=get pixels pitch() bits_per_pixel=bitmap depth(num)/8 pointer=start+y*repeat_number+x*bits_per_pixel *pointer=color_value endfunction function endgame() copy bitmap 1,0 text 100,1,"Score "+str$(score) text 1,1,"Distance "+str$(tiles) text 1,20,"Game Over" sync suspend for key end endfunction