Statistics: Posted by burger2227 — Sat Jan 23, 2010 7:35 pm
Statistics: Posted by BigBadKing — Sat Jan 23, 2010 7:41 am
Statistics: Posted by burger2227 — Sat Jan 23, 2010 5:59 am
Statistics: Posted by BigBadKing — Sat Jan 23, 2010 3:52 am
Statistics: Posted by burger2227 — Sat Jan 23, 2010 1:01 am
Statistics: Posted by BigBadKing — Sat Jan 23, 2010 12:30 am
Code:
Type LOOP UNTIL INKEY$ = CHR$(27) ' where the GOTO line is
Statistics: Posted by burger2227 — Fri Jan 22, 2010 3:34 pm
Statistics: Posted by BigBadKing — Fri Jan 22, 2010 3:21 pm
Code:
declare sub ShowBackpack declare sub TakeItem(NameOfItem$) dim shared items dim shared Inventory$(100) 20 input c$ c$ = ucase$(c$) ' make the command case-insensitive if c$ = "TAKE CAMERA" then TakeItem("Camera") end if if c$ = "BACKPACK" then ShowBackpack end if goto 20 sub ShowBackpack for i = 1 to items print Inventory$(i) next i end sub sub TakeItem(NameOfItem$) for i = 1 to Items if NameOfItem$ = Inventory$(i) then GotIt = 1: exit for next i if GotIt = 1 then print "You already have it!" end sub
Statistics: Posted by BigBadKing — Fri Jan 22, 2010 3:18 pm
Statistics: Posted by BigBadKing — Fri Jan 22, 2010 3:13 pm
As you can see, he makes use of a subroutine. This is so that the user can type "BACKPACK" at any point in the game, and he will be directed to the BACKPACK sub, which will return him to the point in the game where he was at when he exits the BACKPACK. I attempted to use this code, but it didn't exactly work as planned. Here's a piece of code from my game:10 Rem *** Main Loop ***
print LocationDescription$(PlayerLocation)
Print : Print "Enter Command: ";
Input PlayerInput$
If (PlayerInput$ = "i") or (PlayerInput$ = "I") then gosub 1000 'Take Inventory
Goto 10
1000 Rem *** Take Inventory ***
Print "You are carrying the following items:"
ItemsCarried = 0
for i = 1 to MaxItemNumber
if ItemLocation(i) = 0 then ItemsCarried = ItemsCarried + 1: Print ItemName$(i)
Next i
If ItemsCarried = 0 then print "Nothing."
Return
So, if the user types one of the three available commands (TAKE A SHOWER, HELP, and TURN ON LIGHT) then he is taken to their corresponding pages. If he typed anything other than those three commands, then he was taken to a page which said, in so many words, that the command was not one of the available actions. This worked fine until I added the BACKPACK parts. For some reason, when the user types BACKPACK, it refuses to GOSUB: it takes the user to the "Command not available" message. It's not recognizing BACKPACK as one of the available commands. Here is the corresponding SUB.INPUT " INPUT: ", l$
IF l$ = "TAKE A SHOWER" THEN GOTO 21
IF l$ = "HELP" THEN GOTO 22
IF l$ = "TURN ON LIGHT" THEN GOTO 24
IF l$ = "BACKPACK" THEN GOSUB Backpack
IF l$ <> "TURN ON LIGHT" OR l$ <> "BACKPACK" OR l$ <> "TAKE A SHOWER" OR l$ <> "HELP" THEN GOTO 23
END
So what's the major malfunction here? At first I thought it was because the SUB is all the way at the end of all the code. But, from my understanding of how SUBs work, this shouldn't matter. I'd like to make use of a SUB because I don't want to have to write a new inventory code for every scene, but I'd also like to make use of your inventory code, as it's much cleaner than this guy's inventory code.SUB Backpack
1000 CLS
PRINT " Your Backpack:"
PRINT " _______________________"
ItemsCarried = 0
FOR i = 1 TO MaxItemNumber
IF ItemLocation(i) = 0 THEN ItemsCarried = ItemsCarried + 1: PRINT ItemName$(i)
NEXT i
IF ItemsCarried = 0 THEN PRINT "Nothing."
RETURN
END SUB
Statistics: Posted by JBender23 — Fri Jan 22, 2010 10:22 am
Statistics: Posted by burger2227 — Fri Jan 22, 2010 1:23 am
Statistics: Posted by BigBadKing — Fri Jan 22, 2010 12:55 am
'\\\\UNTITLED TEXT ADVENTURE////
'This will be some sort of text adventure involving a day in the life of a
'Fountain-Fort Carson High School Student
PRINT " ____________
PRINT " |____ ____| _______ __ __ ___ _______ ______
PRINT " | | \ | || \ | || \ | || \ 's
PRINT " _ | | B || ____|| \ || D || ____|| RR |
PRINT " | | | | / | |_ | |\ || D || |_ | __/
PRINT " | |__| | \ | _} |__| |__||____/ | _} | \ \
PRINT " |_______| B || |_____________________| |____ | | \ \
PRINT " (c)2009|_____ / |________________________________||__| \__\
PRINT " _
PRINT " / \
PRINT " / /_\ \
PRINT " / _____ \
PRINT " /___/ \___\
PRINT " _________ _________
PRINT " |___ ___| |___ ___|
PRINT " | | | |
PRINT " | | | |
PRINT " |_| ROJAN |_| ALE
PRINT " FRESHMAN YEAR
INPUT " Press any button to play. " , a$
IF a$ = "" THEN GOTO 10
10 CLS
COLOR 15
PRINT " It still seems as though you were just getting out of school"
PRINT " yesterday, but summer has already faded away. You feel as "
PRINT " though you wasted the time that was given to you. Now you are"
PRINT " starting at a new school: Fountain-Fort Carson High. "
PRINT " As the car approaches the school, you feel the sensation of"
PRINT " encroaching doom. What could you possibly do to avoid starting"
PRINT " high school so soon? Maybe you could jump off a cliff and break"
PRINT " your leg. No, you're parents would still make you go. Perhaps"
PRINT " you could gouge out your own eyeballs?"
PRINT " It's the day of freshman registration, and your mom sits next"
PRINT " to you, filling out some sort of medical form. She says you must"
PRINT " sign your name at the bottom."
COLOR 7
INPUT " (NAME): " , nm$
IF nm$ = "" THEN GOTO 10
15 CLS
COLOR 15
PRINT " After finishing the forms, you have your picture taken for your"
PRINT " School I.D. You talk to a few friends from the middle school, but "
PRINT " everyone seems too nervous to hold much of a conversation. You"
PRINT " get your I.D., and then you have to wait in the library to get your"
PRINT " laptop. After everything is finally taken care of, you return home"
PRINT " for your final week of vacation.
COLOR 11
PRINT " ONE WEEK LATER..."
COLOR 12
PRINT " BUZZ! BUZZ! BUZZ! BUZZ! BUZZ! BUZZ! BUZZ!
COLOR 7
INPUT " INPUT: " , c$
PRINT " For help, type "HELP"
IF c$ = "HELP" THEN GOTO 16
IF c$ = "TURN OFF ALARM" THEN GOTO 20
16 PRINT
PRINT " Try turning off the alarm "type commands in ALL CAPS"
20 CLS
Statistics: Posted by JBender23 — Thu Jan 21, 2010 10:24 pm