homeless - a text game in BBC BASIC

Started by ron77, July 12, 2021, 09:50:52

Previous topic - Next topic

ron77

hello...

here is a small text game in BBC BASIC called "homeless"

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

round157

Quote from: lonely_star on July 12, 2021, 09:50:52
hello...



Hello,

Is BBC BASIC easy for learning?

(Welcome to the forum!)


BasicBoy

I would advise sticking to uppercase-only keywords for BBC BASIC programs. I know that's very old-fashioned these days, and some would say it's rather ugly, and I also know that some dialects (e.g. Russell-branch BBC BASIC) support lowercase-only keywords, but the vast majority of programs written in the language use only uppercase (all capitals) keywords. Most people using BBC BASIC these days will be using 'BBC BASIC for Windows' or 'BBC BASIC for SDL 2.0', and you have to manually switch the IDEs to lowercase mode which is a bit of an inconvenience, because you usually then have to switch it back to uppercase mode afterwards. RISC OS's resident BBC BASIC interpreters (BASIC V and BASIC VI) don't accept lowercase keywords at all.

round157

Quote from: BasicBoy on July 13, 2021, 18:08:34
I would advise sticking to uppercase-only keywords for BBC BASIC programs. I know that's very old-fashioned these days, and some would say it's rather ugly, and I also know that some dialects (e.g. Russell-branch BBC BASIC) support lowercase-only keywords, but the vast majority of programs written in the language use only uppercase (all capitals) keywords. Most people using BBC BASIC these days will be using 'BBC BASIC for Windows' or 'BBC BASIC for SDL 2.0', and you have to manually switch the IDEs to lowercase mode which is a bit of an inconvenience, because you usually then have to switch it back to uppercase mode afterwards. RISC OS's resident BBC BASIC interpreters (BASIC V and BASIC VI) don't accept lowercase keywords at all.

Thanks....very interesting concepts.

Pfaber11

I saw a version of BBC basic by a guy called R.T.Russel . Is this what you're programming in? I had a BBC micro back in the 80's and quite liked it back then . I had a sprite utility tool for it and made one game but it was really too slow at the time to write games in Basic. Is it now a fast language ? I think it's about £30 so not particularly cheap. I guess the language is about 40 years old now and still being used . Anyway happy coding. Bonjour
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

Pfaber11

Just took a look at BBC Basic for windows and can't say it looks user friendly to me .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

BasicBoy

Quote from: Pfaber11 on July 29, 2021, 17:34:46
Just took a look at BBC Basic for windows and can't say it looks user friendly to me .

Three SB code-a-game contest winners (and one 2nd place entry) were made with it, so it can't be that bad?  ;D

The IDE is rather minimalistic, but it is stable and easy to use. My only real complaint is that it doesn't feature a 'Dark Mode', and the near-white window does my f------ head (and eyes) in when I'm coding in the early hours. (There is now an alternative IDE available, but I haven't tried it yet.)

One of the things BBC BASIC for Windows and its cousin BBC BASIC for SDL2.0 lack is much of a game-making community. There's only a tiny handful of us as far as I'm aware, and I'm barely active these days.

Steve Elliott

Quote
Just took a look at BBC Basic for windows and can't say it looks user friendly to me .

Nor does AGK at times with commands like 'ThisIsaCommandToDoSomething'.  BBC BASIC was highly optimized and full featured back in the 80's - better than the other BASIC's on other systems, it was highly regarded.  It's a language from the 80's, so why are you even comparing it to anything in 2021?

And yes Three SB code-a-game contest winners (and one 2nd place entry) were made with it, so it can't be that bad?  ;D  Exactly, plus you could add some machine code easily.

So basically  ;D it comes down to the coder, not the language that gets great results.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Pfaber11

#8
Yes I suppose so , I'm not saying it's bad just saying it looks harder to learn than a language of the present. I did have a BBC computer back then amongst others and did have some experience with it. What I'm saying is it looks hard to master. Haven't seen any BBC basic in 35 years or so .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

BasicBoy

As with any programming language there is of course a learning curve, but I don't feel it's especially steep with BBC BASIC. The main issue I think you'll find is that, because BBC BASIC programs are purely interpreted rather than native (or bytecode) compiled, it's very slow compared to the languages used by most of the folks here and in general game development. At a guess, I'd say it's probably 40 to 120 times slower than C depending on various specifics. This is why the built-in assembler occasionally comes in handy (if you know some assembly language!), as is the ability to import functions/routines from DLLs (Windows library files) built from compiled C/C++ or whatever source code.

Pfaber11

#10
I use AGK Studio which is interpreted and it really is not too bad in the speed stakes and is probably not much different to the BBC basic of today. When I used it in 1984 it was very slow but not in terms as slow as a spectrum . I did write one game on it using a sprite utility package which was ok for fun but not anything commercial as just was not fast enough. The reason I've returned to programming in the last few years is now it is possible to write commercial software in basic which is what I know and as far as programming goes is the only language I like. I've looked at a few languages like C++ Java and Python but they are not for me . Java and Python are both interpreted languages as well but seem to be very popular.
  I bought a compiler for my BBC micro can't remember what it was called but never managed to get it to work. It was supposed to compile to machine code and an intermediate code they called G code . Anyway never got it to work which was a shame as cost me a fair bit . Came on a rom chip. 
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz

round157

#11
Quote from: Pfaber11 on July 29, 2021, 15:20:01
I think it's about £30 so not particularly cheap. I guess the language is about 40 years old now and still being used . Anyway happy coding. Bonjour


Hello....I found this. [https://www.bbcbasic.co.uk/bbcsdl/index.html]

'BBC BASIC for SDL 2.0 (BBCSDL) is an entirely free advanced cross-platform implementation of BBC BASIC for Linux (x86 CPU only), MacOS, Raspberry Pi (Pi OS), Windows, Android, iOS or for running in a browser. It combines the simplicity of BASIC with the sophistication of a structured language, allowing you to write utilities and games, use sound and graphics, and perform calculations.'

Since it is free, may you try it and write a short review? Our members may be quite interested in reading the review.

round157

Quote from: Pfaber11 on July 29, 2021, 15:20:01
  Is it now a fast language ?

I found many examples or games which are on these two channels. I guess that the language is not slow.
https://www.youtube.com/user/rtrussellcouk/videos
https://www.youtube.com/user/dw1664/videos

Pfaber11

I think Basic Boy is the guy to give us a review on BBC Basic . I looked at those YT channels and it does look very nice . I'm not up for learning another language right now but if I were BBC Basic would be on my radar. I did discover it a few years ago but went with Blitz3D as it was free and then got AGK in a sale . I did use what I learnt of BBC Basic in stos for the Atari ste and it seemed to like that style of basic. Not 100% compatible but did get me going without too much effort . used it to do one game and some educational stuff and that was it until 2017 when I decided to try and learn how to program a modern pc . Still learning and maybe for a long time yet. 
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz