set display mode 1024, 768, 32 : sync on : sync rate 60 : hide mouse : autocam off : randomize timer() : set ambient light 20 : Orange = rgb(244, 168, 53) : box 0, 0, 255, 255, rgb(150, 150, 150), rgb(150, 150, 150), rgb(150, 150, 150), rgb(150, 150, 150) : for x = 1 to 50 : xpos = rnd(256) : ypos = rnd(256) : box xpos, ypos, xpos + 3, ypos + 3, rgb(200, 200, 200), rgb(200, 200, 200), rgb(200, 200, 200), rgb(200, 200, 200) : next x : get image 1, 0, 0, 255, 255 : cls : ink rgb(0, 200, 255), 0 : fillcirc(128, 128, 100) : get image 2, 0, 0, 255, 255 : ink rgb(255, 255, 255), 0 : cls : ink rgb(49, 61, 24), 0 : fillcirc(128, 128, 100) : get image 3, 0, 0, 255, 255 : cls
col = rgb(0, 0, 0) : for x = 0 to 219 : ink col, 0 : line xp, 0, xp - 20, 30 : inc ccount : inc xp : if ccount > 20 : ccount = 0 : if col = rgb(0, 0, 0) : col = rgb(255, 255, 0) : else : col = rgb(0, 0, 0) : endif : endif : next x : get image 4, 0, 0, 219, 30 : ink rgb(255, 255, 255), 0 : make particles 1, 2, 100, 2 : rotate particles 1, 270, 0, 0 : set particle gravity 1, -8 : set particle life 1, 5 : set particle speed 1, 0.01 : for x = 2 to 5 : make particles x, 3, 100, 8 : position particles x, (x - 3.5) * 5, 1, -2
rotate particles x, 90, 0, 0 : set particle gravity 1, 2 : set particle life 1, 5 : set particle speed 1, 0.01 : next x : make object box 1, 1, 0.2, 2 : position object 1, 0, 0.1, 0 : make object cube 9999, 0.5 : make object sphere 10000, 1 : scale object 10000, 50, 100, 250 : make object sphere 10001, 1 : scale object 10001, 100, 100, 50 : make object sphere 10002, 0.7 : make mesh from object 1, 9999 : make mesh from object 2, 10000 : make mesh from object 3, 10001 : make mesh from object 4, 10002 : delete object 9999 : delete object 10000 : delete object 10001 : delete object 10002 : add limb 1, 1, 1 : offset limb 1, 1, 0, 0, -1.2 : color limb 1, 1, rgb(50, 50, 50) : add limb 1, 2, 2
offset limb 1, 2, 0.7, 0, 0 : add limb 1, 3, 2 : offset limb 1, 3, -0.7, 0, 0 : add limb 1, 4, 3 : offset limb 1, 4, 0, 0, 1.2 : add limb 1, 5, 4 : offset limb 1, 5, 0.5, 0, 1 : add limb 1, 6, 4 : offset limb 1, 6, -0.5, 0, 1 : add limb 1, 7, 4 : offset limb 1, 7, 0.5, 0, -1 : add limb 1, 8, 4 : offset limb 1, 8, -0.5, 0, -1 : for x = 2 to 8 : color limb 1, x, Orange : set limb normals 1, x : next x : make object plain 2, 20, 30 : color object 2, rgb(0, 100, 255) : position object 2, 0, 0, 10 : xrotate object 2, 270
_game: sync
if file exist("DATA.txt") = 0 : open to write 1, "DATA.txt" : write string 1, "Sewer Runner" : write string 1, "0" : scorer$ = "NoOne" : hiscore = 0 : close file 1 : else : open to read 1, "DATA.txt" : read string 1, scorer$ : read string 1, hiscore$ : hiscore = val(hiscore$) : close file 1 : endif
gosub _menu : dim obz#(19) : for x = 20 to 39 : if object exist(x) = 0 : make object box x, rnd(1) + 1, 0.5, 0.2 : endif : position object x, rnd(16) - 8, 1, rnd(40) + 20 : texture object x, 4 : obz#(x - 20) = object position z(x) : next x : dim wallz#(7) : for x = 4 to 19 : if object exist(x) = 0 : make object cube x, 5 : endif : position object x, (12 * (-2 * (x mod 2)) + 12), 2.5, ((x / 2) - 4) * 5 : scale object x, rnd(20) + 100, 500, 100 : texture object x, 1 : wallz#((x / 2) - 2) = object position z(x) : next x : playx# = 0 : playz# = 0 : score = 0 : scoreinc = 0 : health = 100
do : gosub _controls : box 0, -1, screen width(), 20, rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0) : righttext("FPS : " + str$(screen fps()), 5) : text 0, 5, "Polygons : " + str$(statistic(1)) : text (screen width() / 2) - 300, 5, "Score : " + str$(score) : text (screen width() / 2) - 200, 5, "HighScore : " + str$(hiscore) : center text (screen width() / 2) + 150, 5, "Health : " + str$(health) : for x = 4 to 19 : dec wallz#((x / 2) - 2), 0.2 : if wallz#((x / 2) - 2) < -5 : wallz#((x / 2) - 2) = 25 : endif : position object x, object position x(x), object position y(x), wallz#((x / 2) - 2) : next x : for x = 20 to 39 : dec obz#(x - 20), 0.2 : if obz#(x - 20) < -5 : obz#(x - 20) = rnd(20) + 25 : endif : if object collision(1, x) = 1 and object position z(x) > object position z(1) : obz#(x - 20) = rnd(20) + 25 : dec health, 20 : endif : position object x, object position x(x), object position y(x), obz#(x - 20)
next x : inc scoreinc : if scoreinc = 10 : inc score : scoreinc = 0 : endif : if score > hiscore : hiscore = score : endif : if object position z(1) < -3 : health = 0 : endif : if health <= 0 : goto _death : endif
position particles 1, limb position x(1, 1), limb position y(1, 1), limb position z(1, 1) - 0.5 : position camera 0, 20, 10 : point camera 0, 0, 10 : sync : loop
_death: set text size 48 : center text screen width() / 2, screen height() / 2, "OH NOES!!! YOU'RE DEAD!!!" : sync : set text size 12 : wait key : if score = hiscore : set cursor (screen width() / 2), screen height() / 2 : center text screen width() / 2, screen height() / 2, "New HighScore! Press Return to enter name!" : sync : wait key : input scorer$ : : delete file "DATA.txt" : open to write 1, "DATA.txt" : write string 1, scorer$ : write string 1, str$(hiscore) : close file 1 : endif : goto _game
_menu: box 0, 0, screen width(), screen height(), rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0) : center text screen width() / 2, 300, "SEWER RUNNER!" : center text screen width() / 2, 350, "Arrowkeys to move, avoid the obstacles, don't fall back into the wave of sludge!" : center text screen width() / 2, 400, "HighScore : " + str$(hiscore) + " Scored by : " + scorer$ : center text screen width() / 2, 600, "Press any key to play" : sync : wait key : return
_controls: if upkey() = 1 : inc playz#, 0.2 : endif : if downkey() = 1 : dec playz#, 0.2 : endif : if rightkey() = 1 : inc playx#, 0.2 : endif : if leftkey() = 1 : dec playx#, 0.2 : endif : if playx# > 8 : playx# = 8 : endif : if playx# < -8 : playx# = -8 : endif : if playz# > 20 : playz# = 20 : endif : position object 1, curvevalue(playx#, object position x(1), 10), 1, curvevalue(playz#, object position z(1), 10) : return
function righttext(strn$, yp) : text screen width() - text width(strn$), yp, strn$
endfunction
function fillcirc(xp, yp, rad) : ang#=0 : steps#=0.5 : repeat : ang#=ang#+steps# : x#=(sin(ang#)*rad) : y#=(cos(ang#)*(rad*0.9)) : line -x#+xp,y#+yp,x#+xp,y#+yp : until ang#>=180
endfunction
17 lines
877855