This is a little rolling marble game that I wrote.
You control the yellow marble, dodge the red marbles and collect the green marble. The game ends when you are hit by a red marble. Once the green marble has been collectec, another one appears in a random location.
To control the yellow marble you use the mouse. You have to sort of repeatedly flick the mouse left, right and up and down to get the marble to roll. I find it works best on a laptop touch pad.
The game was originally written in DBC but the method I used to get the marbles to roll didn\'t work in DBPro, so I had to change it. It\'s not as good but it looks ok.
DBC version:
dim pos#(20,2) : dim av#(20,2) : dim flag(20) : sync rate 65 : sync on : hide mouse : randomize timer() : rad# = 30.0 : pm# = 0.05 : fric# = 0.01 : ek# = 0.01 : ed# = 0.01 : pi# = 3.14159 : ob = 7 : size = 1000
make matrix 1, size, size, 10, 10 : create bitmap 1, 10,10 : set current bitmap 1 : for i = 1 to ob : if i < ob-1 : ink rgb(250,0,0), 0 : box 0,0,9,9 : ink rgb(250,0,250), 0 : line 0,4, 10,4 : get image i,0,0,10,10 : endif : if i = ob-1
ink rgb(0,250,0), 0 : box 0,0,9,9 : ink rgb(250,0,250), 0 : line 0,4, 10,4 : get image i,0,0,10,10 : endif : if i = ob : ink rgb(250,250,0), 0 : box 0,0,9,9 : ink rgb(0,250,0), 0 : line 0,4, 10,4 : get image i,0,0,10,10 : endif
make object sphere i, rad#*2 : texture object i,i : next i : set current bitmap 0 : delete bitmap 1 : ink rgb(255,255,255),0 : do : over = 0 : score = 0 : pos#(ob,1) = 500.0 : pos#(ob,2) = 500.0 : av#(ob,1) = 0.0 : av#(ob,2) = 0.0
for i = 1 to ob-1 : flag(i) = i * 100 : for j = 1 to 2 : repeat : pos#(i,j) = rnd(size-2*rad#)+rad# : until abs(pos#(ob,j) - pos#(i,j)) > size/3 : if i < ob - 1 : av#(i,j) = (pos#(ob,j) - pos#(i,j))*ek# - av#(i,j)*ed# : endif : next j : next i
repeat : center text screen width()/2, 50, \"MOVE MOUSE TO START\" : for i = 1 to ob : position object i, pos#(i,1), rad#, pos#(i,2) : next i : position camera 500,1000,0 : point camera 500,0,500 : sync : until mousemovex() + mousemovey() <> 0
repeat : av#(ob,1) = av#(ob,1) - mousemovex() * pm# * -1 : av#(ob,2) = av#(ob,2) - mousemovey() * pm# : av#(ob,1) = av#(ob,1) - fric# * av#(ob,1) : av#(ob,2) = av#(ob,2) - fric# * av#(ob,2) : for i = 1 to ob-2 : flag(i) = flag(i) - 1
if flag(i) < 200 : for j = 1 to 2 : av#(i,j) = av#(i,j)+(pos#(ob,j)-pos#(i,j))*ek#-av#(i,j)*ed# : if av#(i,j) > 8 : av#(i,j) = 8 : endif : if av#(i,j) < -8 : av#(i,j) = -8 : endif : next j : endif : if flag(i) < 0 : flag(i) = 1000 : endif : next i
for i = 1 to ob : for j = 1 to 2 : pos#(i,j) = pos#(i,j)+rad#*av#(i,j)*pi#/180 : if pos#(i,j) < rad# : pos#(i,j) = rad# : av#(i,j) = av#(i,j)*-1 : endif : if pos#(i,j) > size - rad# : pos#(i,j) = size - rad# : av#(i,j) = av#(i,j)*-1 : endif : next j
position object i, pos#(i,1), rad#, pos#(i,2) : zrotate object i, wrapvalue(av#(i,1)*-1) : fix object pivot i : xrotate object i, wrapvalue(av#(i,2)) : fix object pivot i : next i
for i = 1 to ob - 1 : dist# = sqrt((pos#(i,1)-pos#(ob,1))^2+(pos#(i,2)-pos#(ob,2))^2) : if dist# < rad#*2 : if i < ob - 1 : over = 1 : else : score = score + 1 : for j = 1 to 2 : pos#(i,j) = rnd(size) : next j : endif : endif : next i
position camera 500,1000,0 : point camera 500,0,500 : center text screen width()/2, 20, \"SCORE : \" + str$(score) : center text screen width()/2, 40, \"HIGH SCORE : \" + str$(high_score) : sync : until over = 1
if score > high_score : high_score = score : message$ = \"! NEW HIGH SCORE !\" : else : message$ = \"GAME OVER\" : endif
repeat : center text screen width()/2, 10, message$ : center text screen width()/2, 30, \"SCORE = \" + str$(score) : center text screen width()/2, 50, \"PRESS SPACE TO RESTART\" : sync : until spacekey() = 1 : loop : end
DBPro version:
dim pos#(20,2) : dim av#(20,2) : dim flag(20) : dim ax#(20) : sync rate 65 : sync on : set window off : hide mouse : randomize timer() : rad# = 30.0 : pm# = 0.05 : fric# = 0.01 : ek# = 0.01 : ed# = 0.01 : pi# = 3.14159 : ob = 7 : size = 1000
make matrix 1, size, size, 10, 10 : create bitmap 1, 11,11 : set current bitmap 1 : for i = 1 to ob : if i < ob-1 : ink rgb(250,0,0), 0 : box 0,0,10,10 : ink rgb(250,0,250), 0 : box 0,3, 10,6 : get image i,0,0,10,10 : endif : if i = ob-1
ink rgb(0,250,0), 0 : box 0,0,10,10 : ink rgb(250,0,250), 0 : box 0,3, 10,6 : get image i,0,0,10,10 : endif : if i = ob : ink rgb(250,250,0), 0 : box 0,0,10,10 : ink rgb(0,250,0), 0 : box 0,3, 10,6 : get image i,0,0,10,10 : endif
make object sphere i, rad#*2 : texture object i,i : next i : set current bitmap 0 : delete bitmap 1 : ink rgb(255,255,255),0 : do : over = 0 : score = 0 : pos#(ob,1) = 500.0 : pos#(ob,2) = 500.0 : av#(ob,1) = 0.0 : av#(ob,2) = 0.0 : ax#(ob) = 0.0
for i = 1 to ob-1 : flag(i) = i * 100 : ax#(i) = 0.0 : for j = 1 to 2 : repeat : pos#(i,j) = rnd(size-2*rad#)+rad# : until abs(pos#(ob,j)-pos#(i,j)) > size/3 : if i < ob - 1 : av#(i,j) = (pos#(ob,j)-pos#(i,j))*ek#-av#(i,j)*ed# : endif : next j : next i
for i = 1 to ob : position object i, pos#(i,1), rad#, pos#(i,2) : point object i, pos#(i,1), rad#, pos#(i,2)+1000 : next i
repeat : center text screen width()/2, 50, \"MOVE MOUSE TO START\" : position camera 500,1000,0 : point camera 500,0,500 : sync : until mousemovex() + mousemovey() <> 0 : av#(ob,1) = 0.0 : av#(ob,2) = 0.0
repeat : av#(ob,1) = av#(ob,1) - mousemovex() * pm# * -1 : av#(ob,2) = av#(ob,2) - mousemovey() * pm# : av#(ob,1) = av#(ob,1) - fric# * av#(ob,1) : av#(ob,2) = av#(ob,2) - fric# * av#(ob,2) : for i = 1 to ob-2 : flag(i) = flag(i) - 1
if flag(i) < 200 : for j = 1 to 2 : av#(i,j) = av#(i,j) + (pos#(ob,j)-pos#(i,j))*ek#-av#(i,j)*ed# : if av#(i,j) > 8 : av#(i,j) = 8 : endif : if av#(i,j) < -8 : av#(i,j) = -8 : endif : next j : endif : if flag(i) < 0 : flag(i) = 1000 : endif : next i
for i = 1 to ob : for j = 1 to 2 : pos#(i,j) = pos#(i,j) + rad#*av#(i,j)*pi#/180 : if pos#(i,j) < rad# : pos#(i,j) = rad# : av#(i,j) = av#(i,j)*-1 : endif : if pos#(i,j) > size - rad# : pos#(i,j) = size - rad# : av#(i,j) = av#(i,j)*-1 : endif : next j : ax#(i) = wrapvalue(ax#(i) + sqrt(av#(i,1)^2+av#(i,2)^2))
position object i, pos#(i,1), rad#, pos#(i,2) : point object i, pos#(i,1), rad#, pos#(i,2)+1000 : yrotate object i, atanfull(av#(i,1),av#(i,2)) : xrotate object i, wrapvalue(ax#(i)) : next i
for i = 1 to ob - 1 : dist# = sqrt((pos#(i,1) - pos#(ob,1))^2 + (pos#(i,2) - pos#(ob,2))^2) : if dist# < rad#*2 : if i < ob - 1 : over = 1 : else : score = score + 1 : for j = 1 to 2 : pos#(i,j) = rnd(size) : next j : endif : endif : next i
position camera 500,1000,0 : point camera 500,0,500 : center text screen width()/2, 20, \"SCORE : \" + str$(score) : center text screen width()/2, 40, \"HIGH SCORE : \" + str$(high_score) : sync : until over = 1
if score > high_score : high_score = score : message$ = \"! NEW HIGH SCORE !\" : else : message$ = \"GAME OVER\" : endif
repeat : center text screen width()/2, 10, message$ : center text screen width()/2, 30, \"SCORE = \" + str$(score) : center text screen width()/2, 50, \"PRESS SPACE TO RESTART\" : xxx = mousemovex() : yyy = mousemovey() : sync : until spacekey() = 1 : loop : end
Hope you like it.