sync on : randomize timer()
 
`save some common colors to variables for speedy color use
red = rgb(255,0,0) : green=rgb(0,255,0) : blue=rgb(0,0,255) : white=rgb(255,255,255)
 
gosub _main_menu
 
`make a grass image for bottom of game screen
ink rgb(0,255,0),0  : box 0,450,639,479
GroundImg=1 : get image GroundImg,0,450,640,480
 
cls
 
new_shot:
 
trampolinex#=rnd(600)+20
 
do
 
set text size 20
 
paste image GroundImg,0,450
 
ink rgb(255,255,255),0
circle 5,445,5
 
mx=mousex()
my=mousey()
angle=atanfull(mx-5,my-445)
mousedist#=distance#(5,445,mx,my)
if mousedist#>500
   power#=50
else
   power#=mousedist#/10
endif
line 5,445,5+sin(angle)*power#,445+(cos(angle)*power#)
 
ink red,0 : box 580,300-(power#*4),630,300 : ink white,0 : center text 600,300-(power#*4)-20,"Power"
 
text 10,10,"Space to Fire"
 
box 547,450,553,479
 
ink blue,0 : ellipse trampolinex#,446,10,4 : ink white,0
 
set text size 10
text 500,30,"Round Best - "+str$(oldhiscore#)
 
sync
 
cls
 
if spacekey()=1 then goto FIRE
 
loop
 
FIRE:
 
forward#=(sin(angle)*(power#/3.5))
 
up#=(cos(180-angle)*(power#/3.5))
 
originalup#=up#
 
posx=5 : posy=445 : dist#=0.0 : stripe_spot#=550
 
do
 
if dist#<=550
   circle posx,posy,5
else
   circle 550,posy,5
   posx=550
   dec stripe_spot#,forward#
   dec trampolinex#,forward#
endif
 
if stripe_spot#<3 then stripe_spot#=637
if trampolinex#<10 then trampolinex#=640+rnd(200)
 
paste image GroundImg,0,450
 
box stripe_spot#-3,450,stripe_spot#+3,479
 
text 10,10,str$(dist#)+"ft"
 
if trampolinex#<=630 then ink blue,0 : ellipse trampolinex#,446,10,4 : ink white,0
 
set text size 10
text 500,30,"Round Best - "+str$(oldhiscore#)
set text size 20
 
sync
 
cls
 
dec posy,up#
 
inc posx,forward#
inc dist#,int(forward#)
 
dec up#,.5
 
inc forward#,(diffweight-17)/150.0
if forward#<=0 then forward#=0
 
if originalup#<=.5 then goto end_bounce
 
if posy>=445
   if originalup#<=.5
      goto end_bounce
   else
      posy=445
      if abs(trampolinex#-posx)<20 then originalup#=originalup#*3.0
      originalup#=originalup#*(3/4.0)
      up#=originalup#
   endif
endif
 
loop
 
end_bounce:
 
circle posx,445,5
 
do
paste image GroundImg,0,450
text 10,10,str$(dist#)+"ft"
text 10,40,"Click to Fire Again"
if oldhiscore#<dist# then text 10,100,"NEW BEST ROUND SCORE!!" : oldhiscore#=dist#
if mouseclick()=1 then goto new_shot
if posx>550 : circle 550,445,5 : else : circle posx,445,5 : endif
box stripe_spot#-3,450,stripe_spot#+3,479
ink blue,0 : ellipse trampolinex#,446,10,4 : ink white,0
sync
cls
loop
 
 
`------------------------------------------------------------
_main_menu:
`------------------------------------------------------------
 
cls blue
 
for percent=0 to 100 step 10
   ink color_change_percent(blue,white,percent),0
   circle percent,480-percent,5
   circle 530+percent,370+percent,5
next percent
 
ink color_change_percent(blue,red,50),0 : set text size 32 : text 20,20,"READY"
ink color_change_percent(blue,red,75),0 : set text size 32 : center text 320,20,"AIM"
ink color_change_percent(blue,red,100),0 : set text size 32 : center text 545,20,"FLING!!"
 
set text size 20
 
get image 2,0,0,639,479
 
`make a few arrays to hold stuff for our options
dim button$(4) : dim buttoncoords(4,4)
buttonnum=4
 
set text size 20
 
`fill our 2 arrays with data
button$(1)="Easy" : button$(2)="Medium" : button$(3)="Hard" : button$(4)="Instructions"
for button = 1 to 3
halfwidth=(.5*text width(button$(button))) : buttoncoords(button,1)=320-halfwidth : buttoncoords(button,3)=320+2*halfwidth
halfheight=(.5*text height(button$(button))) : buttoncoords(button,2)=(button*120)-halfheight : buttoncoords(button,4)=(button*120)+2*halfheight
next button
 
buttoncoords(4,1)=50 : buttoncoords(4,3)=50+2*text width("Instructions")
buttoncoords(4,2)=240-(.5*text height("Instructions")) : buttoncoords(4,4)=240+(text height("Instructions"))
 
do
 
set text size 20
 
`this for-next loop will make the buttons
for button=1 to buttonnum
 
if mouseover(buttoncoords(button,1)-10,buttoncoords(button,2)-10,buttoncoords(button,3)+10,buttoncoords(button,4)+10)=1
   set text opaque
   if button<4
      diffweight=19-(2*button)
      if mouseclick()=1 then goto button_chosen
   else
      if mouseclick()=1 then gosub Instructions
   endif
else
   set text transparent
endif
ink green,red
text buttoncoords(button,1),buttoncoords(button,2),button$(button)
 
next button
 
sync
 
paste image 2,0,0
 
loop
 
button_chosen:
 
return
 
Instructions:
 
cls blue
 
ink red,0
set text transparent
set text size 15
 
center text 320,80,"The object of Ready, Aim, Fling is to throw the ball as far as possible"
center text 320,160,"Before the throw, aim with the mouse, then fire with space"
center text 320,240,"Watch in amazement as the ball flies through the air based on your aim"
center text 320,320,"When the ball comes to a stop, click to restart the process"
center text 320,400,"Press any key to return to the main menu"
 
suspend for key
 
return
 
 
`----------------------------------------------------------
`FUNCTIONS
`----------------------------------------------------------
 
 
 
 
 
function mouseover(x1,y1,x2,y2)
 
mx=mousex() : my=mousey()
 
if x1<mx and mx<x2
   if y1<my and my<y2
      exitfunction 1
   endif
endif
 
endfunction 0
 
 
 
 
function color_change_percent(startcolor,endcolor,percent)
 
red1 = rgbr(startcolor) : red2 = rgbr(endcolor)
green1 = rgbg(startcolor) : green2 = rgbg(endcolor)
blue1 = rgbb(startcolor) : blue2 = rgbb(endcolor)
 
newred=(red2-red1)*(percent/100.0)+red1
newgreen=(green2-green1)*(percent/100.0)+green1
newblue=(blue2-blue1)*(percent/100.0)+blue1
 
endfunction rgb(newred,newgreen,newblue)
 
function distance#(x1,y1,x2,y2)
 
xdist=abs(x2-x1) : ydist=abs(y2-y1)
distance#=sqrt((xdist*xdist)+(ydist*ydist))
 
endfunction distance#