I hope I upload this right. This is a DBP program using Dark Physics
Use the mouse to tilt the board. The Goal is in the upper right.Hope to learn how to texture this and add sound. This program requires one external file "tilt-board2.x" included here.
rem tilt board game 20 line code by Dan Hooper "toydoctor" Requires Dark Physics
rem setup and declare variables and adjust lighting
sync on:sync rate 0:phy start:st as dword:ball=2:phy set gravity 0,-3,0:h=20:r=0:st=timer():ctdn = 100:balls=3
hide light 0:make light 1:position light 1,0,2,0:set light range 1,500:set ambient light 25
rem load assets
load mesh "tilt-board2.x",1:make object 1,1,0:phy make rigid body static mesh 1:set object ambient 1,1:color object 1,rgb(75,50,50)
_restart:
rem reset variables
position mouse 200,200:hide mouse:lose=0:win=0
rem load and start ball at initial position
make object sphere ball,1,16,16:position object ball,0,3,-9:phy make rigid body dynamic sphere ball:phy set rigid body mass ball,200:set object ambience 1,100:color object ball,rgb(50,50,255)
_main:
while lose=0
set cursor 0,0:print "balls left :",balls:print "score :",ctdn
rem trick to make tilt table tilt and simulate physics (cannot actually move rigid static object)
bx=object position x (ball):by=object position y (ball):bz=object position z (ball):zrotate camera r:xrotate camera p:position camera bx,10,bz-15
x#=mousex()-200 : y#=mousey()-200 : phy add rigid body force ball, x#/400, 0, -y#/400, 1:p=(y#/10)+20:r=x#/10
rem score count down
if timer() > st+1000 then dec ctdn:st=timer()
rem winning condition
if object position x (ball) + object position z (ball) >18 then goto _gameover:
rem oops lost a ball
if object position y (ball) <-5:lose = 1:dec balls:delete object ball:phy delete rigid body ball:inc ball:endif:if balls =0 :goto _gameover::endif:phy update:sync:endwhile:goto _restart:
_gameover:
if ctdn < 0 then ctdn=0
cls 0:set cursor 100,100:print "GAME OVER":print "FINAL SCORE: ",(ctdn*balls):print "PLAY AGAIN? (y)":sync:wait key
if inkey$() = "y" :delete object (ball):phy delete rigid body (ball):balls=3:ball=2:ctdn=100:goto _restart::endif:end
Toydoc Dan