' Bobsleigh 1.1 ' Allan Crossman, 2001 ' Inspired by but not copied from "The Dragon 32 Book of Games" ' Move with 4 and 6. ' Keep the sleigh in the course! hide console hidecursor fullscreen mode screen width, screen height, 8 randomize timer width = 300 depth = 400 left = screen width / 2 - (width / 2) top = screen height / 2 - (depth / 2) right = screen width / 2 + (width / 2) bottom = screen height / 2 + (depth / 2) disable done dim left(depth) dim right(depth) slopeleft = 1 sloperight = 2 startseparation = 60 ' Higher is easier minseparation = 30 ' How close the two sides can come to each other verticalpos = 40 decreasetime = 2000 ' ie every 2000 ticks it reduces the width decreasevalue = 2 ' How much each side closes in changeprob = 0.025 backcolor 0, 0, 0 forecolor 65535, 65535, 65535 virtue = init screen(0, 0, width, depth) Restart: set screen to virtue cls mypos = width / 2 separation = startseparation forecolor 65535, 65535, 65535 x = 0 y = -1 makestart: x = x + 1 y = y + 1 left(y) = x right(y) = width - x if right(y) - left(y) > separation then goto makestart makerest: y = y + 1 if y < depth then left(y) = x right(y) = width - x goto makerest end if for y = 0 to depth plot left(y), y plot right(y), y next y copyrect 0, 0, width, depth, left, top, right, bottom, 0, virtue, 0 if rnd < 0.5 then slopedirection = slopeleft else slopedirection = sloperight tick = 0 set screen to console cls set screen to virtue mainloop: tick = tick + 1 set screen to console textmode 0 forecolor 0, 65535, 0 text left, top - 30, "Score: " + str$(tick) text right - 100, top - 30, "High: " + str$(highscore) set screen to virtue starttime = timer keymap scan if keymap key ("q") then goto EndProg end if if keymap key ("4") then mypos = mypos - 1 end if if keymap key ("6") then mypos = mypos + 1 end if if mypos < left(verticalpos) or mypos > right(verticalpos) then if tick > highscore then highscore = tick wait 1 goto Restart end if for y = 0 to depth - 2 left(y) = left(y + 1) right(y) = right(y + 1) next y if tick mod decreasetime = 0 then decreaseflag = 1 if decreaseflag then if decreased = decreasevalue or separation - 2 < minseparation then decreaseflag = 0 decreased = 0 else left(depth - 1) = left(depth - 2) + 1 right(depth - 1) = right(depth - 2) - 1 separation = separation - 2 decreased = decreased + 1 end if end if if decreaseflag = 0 then ' otherwise the generation has already been done if slopedirection = slopeleft then if left(depth - 1) < 20 then slopedirection = sloperight left(depth - 1) = 20 else left(depth - 1) = left(depth - 2) - 1 end if right(depth - 1) = left(depth - 1) + separation else if right(depth - 1) > width - 20 then slopedirection = slopeleft right(depth - 1) = width - 20 else right(depth - 1) = right(depth - 2) + 1 end if left(depth - 1) = right(depth - 1) - separation end if end if if rnd < changeprob then if slopedirection = slopeleft then slopedirection = sloperight else slopedirection = slopeleft end if copyrect 0, 1, width, depth, 0, 0, width, depth - 1, 0, virtue, virtue forecolor 0, 0, 0 line 0, depth - 1, width, depth - 1 forecolor 65535, 65535, 65535 plot left(depth - 1), depth - 1 plot right(depth - 1), depth - 1 for y = verticalpos - 7 to verticalpos plot left(y), y plot right(y), y next y forecolor 65535, 65535, 0 fcircle mypos, verticalpos, 5 copyrect 0, 0, width, depth, left, top, right, bottom, 0, virtue, console forecolor 0, 0, 0 fcircle mypos, verticalpos, 5 KillTime: if abs(timer - starttime) < 0.005 then goto KillTime goto mainloop EndProg: wait 1 set screen to console kill screen virtue normal screen showcursor end