Text-based game - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Text-based game

Hey, I'm trying to learn BASIC by writing a text-based game. Where I'm at now is trying to figure out how to do the inventory. Now, I was thinking that, whenever someone picks up, say, a gun, then it writes that to a file. How do I do that, though? I tried using the "open...append" and then "Write" commands to write to the file whenever someone picked it up, but then how do I get the program to go back and check that? I also tried to use the "open...binary" command to write to the file in binary, but that didn't work out well. Any ideas? Can I do an inventory without opening another file?


Comments

  • Try this:

    If the player has picked up the gun, the variable gun should be filled with 1.

    gun = 1

    Now you can check the inventory very easy:

    if gun = 0 ( NO GUN )

    if gun = 1 ( ALREADY PICKED UP GUN )

    For save-games you can save the inventory like this:

    SaveGame:
    if gun = 1 then
    open "savegame.001" for output as #1
    print #1,"gun1"
    close
    else
    open "savegame.001" for output as #1
    print #1,"gun0"
    close
    end if

    LoadGame:
    open "savegame.001" for imput as #1
    input #1,inventory$
    close

    if inventory$ = "gun1" then gun = 1
    else
    gun = 0
    end if




  • It's always the easiest way! Here I was screwing around with all these complicated commands and all I had to do was...uck, never mind. My head hurts. *L* Thanks a lot for your help. Very much appreciated, man.


Sign In or Register to comment.