home *** CD-ROM | disk | FTP | other *** search
/ MikeOS 4.5 / mikeos.iso / mikeos.flp / example.bas < prev    next >
BASIC Source File  |  2014-12-21  |  2KB  |  165 lines

  1. rem *** MikeOS BASIC demo ***
  2.  
  3. cls
  4.  
  5. $1 = "Hex dumper,MikeTron"
  6. $2 = "Choose a program to run,"
  7. $3 = "Or press Esc to exit"
  8.  
  9. listbox $1 $2 $3 a
  10.  
  11. if a = 1 then goto runhex
  12. if a = 2 then goto runmiketron
  13.  
  14. cls
  15. end
  16.  
  17.  
  18. runhex:
  19.  
  20. rem *** Hex dumper ***
  21.  
  22. cls
  23.  
  24. print "Enter a filename to make a hex dump from:"
  25. input $1
  26.  
  27. x = RAMSTART
  28.  
  29. load $1 x
  30. if r = 1 then goto hexerror
  31.  
  32. hexloop:
  33.   peek a x
  34.   print hex a ;
  35.   print "  " ;
  36.   x = x + 1
  37.   s = s - 1
  38.   if s = 0 then goto hexfinish
  39.   goto hexloop
  40.  
  41. hexfinish:
  42. print ""
  43. end
  44.  
  45. hexerror:
  46. print "Could not load file! Does it exist?"
  47. end
  48.  
  49.  
  50.  
  51. runmiketron:
  52.  
  53. rem *** MikeTron ***
  54.  
  55. cls
  56.  
  57. print "You control a vehicle leaving a trail behind it."
  58. print ""
  59. print "It is always moving, and if it crosses any part"
  60. print "of the trail or border (+ characters), the game"
  61. print "is over. Use the Q and A keys to change the direction"
  62. print "to up and down, and O and P for left and right."
  63. print "See how long you can survive! Score at the end."
  64. print ""
  65. print "NOTE: May perform at wrong speed in emulators!"
  66. print ""
  67. print "Hit a key to begin..."
  68.  
  69. waitkey x
  70.  
  71.  
  72. cls
  73. cursor off
  74.  
  75.  
  76. rem *** Draw border around screen ***
  77.  
  78. gosub setupscreen
  79.  
  80.  
  81. rem *** Start in the middle of the screen ***
  82.  
  83. x = 40
  84. y = 12
  85.  
  86. move x y
  87.  
  88.  
  89. rem *** Movement directions: 1 - 4 = up, down, left, right ***
  90. rem *** We start the game moving right ***
  91.  
  92. d = 4
  93.  
  94.  
  95. rem *** S = score variable ***
  96.  
  97. s = 0
  98.  
  99.  
  100. mainloop:
  101.   print "+" ;
  102.  
  103.   pause 1
  104.  
  105.   getkey k
  106.  
  107.   if k = 'q' then d = 1
  108.   if k = 'a' then d = 2
  109.   if k = 'o' then d = 3
  110.   if k = 'p' then d = 4
  111.  
  112.   if d = 1 then y = y - 1
  113.   if d = 2 then y = y + 1
  114.   if d = 3 then x = x - 1
  115.   if d = 4 then x = x + 1
  116.  
  117.   move x y
  118.  
  119.   curschar c
  120.   if c = '+' then goto finish
  121.  
  122.   s = s + 1
  123.   goto mainloop
  124.  
  125.  
  126. finish:
  127. cursor on
  128. cls
  129.  
  130. print "Your score was: " ;
  131. print s
  132. print "Press Esc to finish"
  133.  
  134. escloop:
  135.   waitkey x
  136.   if x = 27 then end
  137.   goto escloop
  138.  
  139.  
  140. setupscreen:
  141.   move 0 0
  142.   for x = 0 to 78
  143.     print "+" ;
  144.   next x
  145.  
  146.   move 0 24
  147.   for x = 0 to 78
  148.     print "+" ;
  149.   next x
  150.  
  151.   move 0 0
  152.   for y = 0 to 24
  153.     move 0 y
  154.     print "+" ;
  155.   next y
  156.  
  157.   move 78 0
  158.   for y = 0 to 24
  159.     move 78 y
  160.     print "+" ;
  161.   next y
  162.  
  163.   return
  164.  
  165.