in the real game you get score for all kinds of things including the things you just said
I just made this program to prove that i could to a friend
sure, though im not sure how enlightening it will be as it is SLOPPY code.
i can explain the important stuff in it.
the wavy line is simply a complicated sine function ((sin(0.4*i)+cos(0.05*i)*sin(0.2*i))*150)
then i have calculated the derivate of it ((pi()*(16*cos(0.4*i)+5*cos(0.25*i)+3*cos(i*0.15)))/48.0)
the derivate says the value of incline the wavy line has at any point on the curve. now i have stored those values in arrays as to be faster than having to recalculate the complicated function again and again.
then i simple terms i compare the balls value of "incline" (kinda how steeply it is moving) and compare it to the wavy lines value of incline. The more similiar they are the smoother the landing is kinda. then its just vectors after that.
Rem Project: tiny
Rem Created: Wednesday, April 18, 2012
Rem ***** Main Source File *****
Rem Project: Dark Basic Pro Project
Rem Created: Wednesday, April 18, 2012
Rem ***** Main Source File *****
set display mode 800,600,32,1
sync on : sync rate 60 :
b = 11701
dim siny#(b)
dim sink#(b)
for i = 1 to b
siny#(i) = (sin(0.4*i)+cos(0.05*i)*sin(0.2*i))*150
sink#(i) = (pi()*(16*cos(0.4*i)+5*cos(0.25*i)+3*cos(i*0.15)))/48.0
NEXT
x# = 250
y# = siny#(50)-11
xvel# = 1
vel# = 5
F = find free vector()
n = make vector2(F)
V = find free vector()
n = make vector2(V)
gravity# = 0.005
set vector2 F,0,gravity#
set vector2 V,0.15,-0.50
friction# = 0.99
effect# = 0.5
a = 11700
spreelevel# = 0.8
zoom# = 0.3
do
if upkey() then inc a
if downkey() then dec a
print a
oxp = xp : xp = wrap(int(x#),1,a)
if spacekey() = 1 then xboost# = 0.0 : gravity# = 0.8
if spacekey() = 0 then xboost# = 0.2 : gravity# = 0.3
add vector2 V,F,V
oox# = ox# : ooy# = oy# : ox# = x# : oy# = y#
x# = x#+x vector2(V) : xpos# = xpos#+x vector2(V)
y# = y#+y vector2(V)
set vector2 F,0,gravity#
vel# = length vector2(V)
if y# > siny#(xp)
ang# = (atan((sink#(xp)+sink#(oxp))*0.5))
a# = gravity#*sin(ang#)
xdif# = a#*cos(ang#) : ydif# = a#*sin(ang#)
if didlast <= 0
kdif# = (getkdif(k#,(sink#(xp)+sink#(oxp))*0.5))
if kdif# > spreelevel# and x vector2(V) > 0 then inc spree
if kdif# <= spreelevel# then spree = 0
endif
if didlast > 0 then kdif# = 1
xdif# = xdif#*kdif#
y# = siny#(xp) : yo# = (y#-oy#) : set vector2 V,x vector2(V)*kdif#,(y#-oy#)*kdif#
if (sink#(xp)+sink#(oxp))*0.5 < 0 then set vector2 F,xdif#+xboost#,gravity#
if (sink#(xp)+sink#(oxp))*0.5 > 0 then set vector2 F,xdif#,gravity#
didlast = 20
else
dec didlast
endif
k# = curvevalue((y#-ooy#)/(x#-oox#),k#,5) : bang# = atan(k#)
if (y#-33)*zoom#+300 < 100 then zoom# = zoom#*0.995
if (y#-33)*zoom#+300 >= 300 then zoom# = zoom#*1.005
zoom# = min(0.4,zoom#)
if spree > 1 then a2fillcircle (x#-xpos#)*zoom#,(y#-33)*zoom#+300,33*zoom#,rgb(255,spree*30,spree*10)
if spree <= 1 then a2fillcircle (x#-xpos#)*zoom#,(y#-33)*zoom#+300,33*zoom#,rgb(255,0,0)
for i = int(xpos#) to int(xpos#)+int(800/zoom#)
iv = wrap(i,1,a-1)
xposv# = wrap(xpos#,1,a-1)
a2line (i-xpos#)*zoom#,(siny#(iv))*zoom#+300,(i+1-xpos#)*zoom#,(siny#(iv+1))*zoom#+300,rgb(255,255,255)
NEXT
sync
cls
LOOP
function getkdif(k1#,k2#)
V1 = createvector2() : V2 = createvector2()
set vector2 V1,1,k1# : set vector2 V2,1,k2# : normalize vector2 V1,V1 : normalize vector2 V2,V2
add vector2 V1,V1,V2
l# = ((length vector2(V1))^2)/2.0-1.0
delete vector2 V1 : delete vector2 V2
ENDFUNCTION l#
function createvector2()
v = find free vector()
n = make vector2(v)
ENDFUNCTION v