a simple text game - first program in BBC BASIC

Discussions related to graphics (2D and 3D), animation and games programming
ron77
Posts: 6
Joined: Sun 11 Jul 2021, 09:58

a simple text game - first program in BBC BASIC

Post by ron77 »

Code: Select all

   10 dim start$(4), money$(4), phone$(5), work$(3), sleep$(3), drugs$(3)
   20 gameover% = 0 days% = 1 health% = 100 money% = 50
   30 proc_init
   40 cls
   50 input "what is your name?: " a$
   60 print a$ + " " +start$(rnd(4))
   70 wait 500
   80 repeat
   90   cls
  100   print
  110   if health% <= 0 then proc_bad : end
  120   print "status :: days on the streets: " + str$(days%) + " health: " + str$(health%) + " money: " + str$(money%)
  130   print "press key 1 for begging for food and money"
  140   print "press key 2 for calling someone"
  150   print "press key 3 for trying to find a job"
  160   print "press key 4 for finding shelter for the night"
  170   print "press key 5 for buying drugs or alcohol to forget your troubles"
  180   print
  190   input "what will you choose?: " c%
  200   print
  210   if c% < 1 or c% > 5 then print "invalid input!"
  220   if c% = 1 then
  230     r1% = rnd(4)
  240     print money$(r1%)
  250     health% += 30
  260     money% += 40
  270   endif
  280   if c% = 2 then
  290     r2% = rnd(5)
  300     print phone$(r2%)
  310     if r2% = 5 then
  320       proc_good
  330     endif
  340   endif
  350   if c% = 3 then
  360     if health% < 30 then
  370       print "you are not enough healthy to get a job!"
  380       goto 610
  390     endif
  400     r3% = rnd(3)
  410     print work$(r3%)
  420     if r3% = 3 then
  430       proc_good
  440     endif
  450   endif
  460   if c% = 4 then
  470     print sleep$(rnd(3))
  480     health% += 40
  490   endif
  500   if c% = 5 then
  510     if money% < 25 then
  520       print "you don't have enough money to but drugs/alcohol!"
  530       goto 610
  540     endif
  550     r5% = rnd(3)
  560     print drugs$(r5%)
  570     if r5% = 3 then
  580       proc_bad
  590     endif
  600   endif
  610   
  620   wait 500
  630   days% += 1
  640   health% -= 10
  650   money% -= 5
  660 until gameover% = -1
  670 end
  680 
  690 
  700 
  710 
  720 
  730 
  740 
  750 
  760 
  770 
  780 
  790 data "you are a runaway teen that ran from home"
  800 data "you are a middle-aged man who left home after your wife failed a divorce"
  810 data "you are man who is struggling with mental illness"
  820 data "you got fired from work and got avicted from your apartment"
  830 
  840 data "you try to find food and beg for money but in vain"
  850 data "a kind woman gives you some money"
  860 data "you find some food"
  870 data "people give you some money to hang on"
  880 
  890 data "you call home but no one answers"
  900 data "you call your grandma and tell her about yourself and you both cry she promises to send some money"
  910 data "you call your friend and she picks you up and you get to stay with at her place for a week"
  920 data "you call a help line but they can't help you"
  930 data "you call your parents and they pick you up - you are safe from the streets"
  940 
  950 data "you try to find work but nobody is interested"
  960 data "you find a job but get layed off really quick"
  970 data "you find a good job - after two weeks you can affored housing!"
  980 
  990 data "you find a safe place for the night under a bridge"
 1000 data "you go to the local shelter and when you wake up all your belongings have been stolened"
 1010 data "you rent a room at a motel for the weekend - you take a shower wash your clouths shave eat well and rest in a warm bed"
 1020 
 1030 data "you buy some cheap alcohol and get drunk and pass out on the side walk"
 1040 data "you buy some cheap drug and smoke it and OD you wake up in the hospital"
 1050 data "you buy some buzz and drugs you get OD and you die on the streets - RIP"
 1060 
 1070 
 1080 
 1090 
 1100 def proc_init
 1110 for i% = 1 to 4
 1120   read start$(i%)
 1130 next i%
 1140 for i% = 1 to 4
 1150   read money$(i%)
 1160 next i%
 1170 for i% = 1 to 5
 1180   read phone$(i%)
 1190 next i%
 1200 for i% = 1 to 3
 1210   read work$(i%)
 1220 next i%
 1230 for i% = 1 to 3
 1240   read sleep$(i%)
 1250 next i%
 1260 for i% = 1 to 3
 1270   read drugs$(i%)
 1280 next i%
 1290 
 1300 endproc
 1310 
 1320 
 1330 def proc_good
 1340 gameover% = -1
 1350 print
 1360 print "you are safe you survived the streets!"
 1370 print "you were: " + str$(days%) + " days homeless"
 1380 endproc
 1390 
 1400 def proc_bad
 1410 gameover% = -1
 1420 print
 1430 print "you died on the street! game over!"
 1440 print "you lasted: " + str$(days%) + " days on the streets"
 1450 endproc