my 1st IF adventure

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
User avatar
bongomeno
Veteran
Posts: 231
Joined: Wed Dec 10, 2008 9:08 am
Location: San Bernardino CA
Contact:

my 1st IF adventure

Post by bongomeno » Wed Dec 10, 2008 9:22 am

I love playing IF games, so i made one...
here is the code pls try it and tell me if you like...

Code: Select all


REM HOUNTED HOUSE - Geek Basic Software

REM PROGRAMMED BY : Gemino Michael Smothers
REM EMAIL         : bongo_meno@yahoo.com
REM HOME          : http://www.freewebs.com/geekbasic

REM I made this in about 2 or 3 hours just for fun.
REM This is my first REAL IF game.
REM Im only 15 so gimmie sum slak if it sux lol.

FOR s = 1 TO 40 STEP 5
COLOR INT(RND * 15) + 1
PRINT SPACE$(s); " HAUNTED HOUSE ";
NEXT s
PLAY "L7O1GFGGGBABBBBCO3BBBBDGGGGFGGABCGO4DBBBBGFG"
menu:
CLS
COLOR 4
PRINT " HAUNTED HOUSE  - BY GEEK BASIC SOFTWARE"
COLOR 12
PRINT
PRINT "MENU -"
PRINT "1> PLAY GAME"
PRINT "2> HELP"
PRINT "0> QUIT"
DO
LET k$ = INKEY$
IF k$ = "1" THEN : GOTO playgame
IF k$ = "2" THEN : GOTO help
IF k$ = "0" THEN : CLS : END
LOOP

help:
CLS
COLOR 4
PRINT "HERE ARE SOME BASIC COMMANDS THAT CAN BE USED IN THE GAME..."
PRINT
COLOR 12
PRINT "LOOK                         - CHECKS FOR AVAILABLE EXITS"
PRINT "INVENTORY                    - VIEW ALL OF YOUR ITEMS"
PRINT "NORTH, WEST, SOUTH, AND EAST - MOVES YOU TO AVAILABLE LOCATIONS"
PRINT "EXAMINE (OBJECT)             - EXAMINES AN OBJECT"
PRINT "USE (OBJECT)                 - USE AN OBJECT"
PRINT "TAKE (OBJECT)                - TAKE AN OBJECT"
PRINT "UNLOCK (OBJECT)              - UNLOCK AN OBJECT"
PRINT "HELP                         - VIEW THIS SCREEN"
PRINT "PRESS ANY KEY..."
DO
LOOP UNTIL LEN(INKEY$)
GOTO menu

playgame:

LET r = 1
LET gotmainkey = 0
LET gotboxkey1 = 0
LET gotboxkey2 = 0
LET gotcandle = 0
LET gotnote = 0
LET gottp = 0
LET boxopen = 0

CLS
COLOR 4
PRINT "HAUNTED HOUSE"
PRINT
COLOR 12
PRINT "IT IS HALLOWEEN DAY AT MARIPOSA DRIVE."
PRINT "YOUR MOM HAS GROUNDED YOU FOR THE DAY BECAUSE YOU AND YOUR FRIENDS"
PRINT "THREW TOILET PAPER OVER THE NEIGHBORS HOUSE LAST NIGHT..."
PRINT "AFTER YOU SPEND ABOUT HALF OF THE DAY IN YOUR ROOM STARING AT YOUR"
PRINT "SOCKS AND LISTENING TO THE CHILDREN PLAY OUTSIDE, YOU DICIDE TO LEAVE"
PRINT "AND GO ON YOUR OWN LITTLE HALLOWEEN ADVENTURE. YOU RMEMBER THE LOCAL"
PRINT "RUMERS ABOUT THE OLD HOUSE ACROSS THE STREET BIENG HAUNTED."
PRINT "YOU THINK IT MIGHT BE FUN TO GO INSIDE AND EXPLORE IT."
PRINT "YOU PICK UP THE PHONE TO INVITE YOUR FRIENDS TO COME, BUT YOU REMEMBER"
PRINT "THAT THEY ARE GROUNDED TO... YOU PUT THE PHONE BACK DOWN, OPEN THE WINDOW,"
PRINT "AND JUMP OUT."
PRINT "PRESS ANY KEY..."
DO
LOOP UNTIL LEN(INKEY$)
CLS
PRINT "YOU RUN ACROSS THE STREET TO THE 'HAUNTED HOUSE' TO SEE THAT THE DOOR"
PRINT "IS SLIGHTLY OPEN, EVEN THOUGH NOBODY LIVES THERE."
PRINT "YOU RUN INSIDE THE HOUSE AND THE DOOR SLAMS BEHIND YOU."
PRINT "YOU TRY TO OPEN THE DOOR, BUT THERE IS A HUGE LOCK PREVENTING YOU"
PRINT "FROM OPENING IT."
PRINT "PRESS ANY KEY..."
DO
LOOP UNTIL LEN(INKEY$)

DO
CLS
GOSUB room
GOSUB parser
LOOP

room:
IF r = 1 THEN : GOSUB r1
IF r = 2 THEN : GOSUB r2
IF r = 3 THEN : GOSUB r3
IF r = 4 THEN : GOSUB r4
IF r = 5 THEN : GOSUB r5
IF r = 6 THEN : GOSUB r6
RETURN

parser:
COLOR 12
LINE INPUT "> "; cmd$
PRINT
COLOR 4
LET cmd$ = LTRIM$(RTRIM$(UCASE$(cmd$)))
IF cmd$ = "END" OR cmd$ = "QUIT" OR cmd$ = "EXIT" OR cmd$ = "Q" OR cmd$ = "QUIT" THEN
GOTO menu
END IF
IF cmd$ = "HELP" THEN
CLS
COLOR 4
PRINT "HERE ARE SOME BASIC COMMANDS THAT CAN BE USED IN THE GAME..."
PRINT
COLOR 12
PRINT "LOOK                         - CHECKS FOR AVAILABLE EXITS"
PRINT "INVENTORY                    - VIEW ALL OF YOUR ITEMS"
PRINT "NORTH, WEST, SOUTH, AND EAST - MOVES YOU TO AVAILABLE LOCATIONS"
PRINT "EXAMINE (OBJECT)             - EXAMINES AN OBJECT"
PRINT "USE (OBJECT)                 - USE AN OBJECT"
PRINT "TAKE (OBJECT)                - TAKE AN OBJECT"
PRINT "UNLOCK (OBJECT)              - UNLOCK AN OBJECT"
PRINT "HELP                         - VIEW THIS SCREEN"
PRINT "PRESS ANY KEY..."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF cmd$ = "LOOK" OR cmd$ = "LOOK AROUND" OR cmd$ = "L" THEN
IF r = 1 THEN : PRINT "YOU CAN MOVE NORTH AND WEST."
IF r = 2 THEN : PRINT "YOU CAN MOVE NORTH, SOUTH, AND WEST."
IF r = 3 THEN : PRINT "YOU CAN MOVE WEST AND SOUTH."
IF r = 4 THEN : PRINT "YOU CAN MOVE EAST."
IF r = 5 THEN : PRINT "YOU CAN MOVE EAST."
IF r = 6 THEN : PRINT "YOU CAN MOVE EAST."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF cmd$ = "INVENTORY" OR cmd$ = "INV" OR cmd$ = "ITEMS" THEN
PRINT "INVENTORY: "
IF gotmainkey = 1 THEN : PRINT "BRONZE KEY"
IF gotboxkey1 = 1 THEN : PRINT "SMALL KEY"
IF gotboxkey2 = 1 THEN : PRINT "SMALL KEY"
IF gotnote = 1 THEN : PRINT "NOTE"
IF gotcandle = 1 THEN : PRINT "CANDLE"
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF cmd$ = "NORTH" OR cmd$ = "GO NORTH" OR cmd$ = "N" THEN
IF r = 1 THEN : LET r = 2: GOTO moved
IF r = 2 THEN : LET r = 3: GOTO moved
END IF
IF cmd$ = "WEST" OR cmd$ = "GO WEST" OR cmd$ = "W" THEN
IF r = 1 THEN : LET r = 5: GOTO moved
IF r = 2 THEN : LET r = 6: GOTO moved
IF r = 3 THEN : LET r = 4: GOTO moved
IF r = 7 THEN : LET r = 2: GOTO moved
END IF
IF cmd$ = "SOUTH" OR cmd$ = "GO SOUTH" OR cmd$ = "S" THEN
IF r = 2 THEN : LET r = 1: GOTO moved
IF r = 3 THEN : LET r = 2: GOTO moved
END IF
IF cmd$ = "EAST" OR cmd$ = "GO EAST" OR cmd$ = "E" THEN
IF r = 4 THEN : LET r = 3: GOTO moved
IF r = 5 THEN : LET r = 1: GOTO moved
IF r = 6 THEN : LET r = 2: GOTO moved
END IF
IF (cmd$ = "EXAMINE OLD RUG" OR cmd$ = "EXAMINE RUG") AND r = 1 THEN
PRINT "IT IS OLD, STAINED AND WORN OUT."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE HUGE TABLE" OR cmd$ = "EXAMINE TABLE") AND r = 2 THEN
PRINT "IT IS A LARGE GRAND LOOKING HARDWOOD TABLE."
PRINT "IT IS COVERED IN DUST AND HAS CHIPS IN IT."
IF gotnote = 0 THEN : PRINT "THERE IS A SMALL NOTE ON TOP OF IT."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE CHAIR" OR cmd$ = "EXAMINE CHAIRS") AND r = 2 THEN
PRINT "IT MIGHT NOT BE A GOOD IDEA TO SIT ON THE ONES THAT ARE NOT BROKEN"
PRINT "BECAUSE THEY MIGHT BREAK TOO."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE PAINTING") AND r = 2 THEN
PRINT "IT IS A PICTURE OF A MIDEVAL CASTLE."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE SINK") AND r = 3 THEN
PRINT "YOU SEE DRIED OUT SPATTERS OF BLOOD IN THE SINK."
PRINT "YOU ALSO SEE A CANDLE AND SOME MATCHES IN IT."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE COUNTER") AND r = 3 THEN
PRINT "IT IS PLAIN AND IS VERY DUSTY."
PRINT "THERE IS WRITING IN THE DUST."
PRINT "IT SAYS:"
PRINT "'I HAVE BEEN TRAPPED IN THIS HOUSE FOR DAYS NOW, UNABLE TO ESCAPE."
PRINT "THE FRONT DOOR REQUIRES A SPECIAL KEY TO BE OPEN FROM THE INSIDE."
PRINT "IT IS NOT THE SAME AS THE ONE THAT OPENS IT FROM THE FRONT."
PRINT "I WILL NOT LIVE MUCH LONGER, BUT FOR ANYONE WHO FINDS THEMSELF"
PRINT "TRAPPED IN THIS TERRIBLE PLACE, I HAVE JUST MADE AN INTERRESTING DISCOVERY."
PRINT "I AM NOT ONE HUNDRED PERCENT SURE, BUT I THINK...'"
PRINT "THE REST IS SMEARED AWAY."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE BUCKET" OR cmd$ = "EXAMINE SMELLY BUCKET") AND r = 4 THEN
PRINT "IT IS FULL OF GREENISH BROWN SEMIHARD STUFF."
IF gotboxkey2 = 0 THEN : PRINT "THERE IS A SMALL KEY IN IT."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE TOILET PAPER" OR cmd$ = "EXAMINE PAPER") AND gottp = 0 AND r = 4 THEN
PRINT "IT IS VERY OLD LOOKING."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE PLAIN MAT" OR cmd$ = "EXAMINE MAT") AND r = 5 THEN
PRINT "IT LOOKS SLIGHTLY LESS THAN COZY..."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE TORN UP BLANKET" OR cmd$ = "EXAMINE BLANKET") AND r = 5 THEN
PRINT "IT PROBABLY WONT KEEP YOU VERY WARM."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE LARGE JEWLERY BOX" OR cmd$ = "EXAMINE JEWLERY BOX") AND r = 5 THEN
PRINT "IT IS INLAID WITH WHAT LOOKS LIKE MARBLE."
PRINT "THERE ARE TWO SMALL KEY HOLES IN THE MIDDLE."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE ROPE") AND r = 6 THEN
PRINT "IT IS HANGING FROM AN ODD LOOKING DEVICE IN THE ROOF."
PRINT "IT LOOKS LIKE IT MIGHT ACTIVATE SOMETHING IF YOU PULL IT."
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "EXAMINE BLOOD") AND r = 6 THEN
PRINT "IT IS DRIED UP BLOOD ON THE FLOOR, WHAT MORE CAN I SAY!?"
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "TAKE NOTE" OR cmd$ = "GET NOTE") AND r = 2 AND gotnote = 0 THEN
PRINT "YOU TAKE THE NOTE."
LET gotnote = 1
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "TAKE PAINTING" OR cmd$ = "GET PAINTING") AND r = 2 AND gotboxkey1 = 0 THEN
PRINT "YOU GRAB THE PAINTING AND A SMALL KEY FALLS OUT FROM THE BACK OF IT."
PRINT "YOU PUT THE PAINTING BACK AND GRAB THE SMALL KEY."
LET gotboxkey1 = 1
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "TAKE CANDLE" OR cmd$ = "GET CANDLE") AND r = 3 AND gotcandle = 0 THEN
PRINT "YOU TAKE THE CANDLE."
LET gotcandle = 1
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "TAKE SMALL KEY" OR cmd$ = "TAKE KEY" OR cmd$ = "GET SMALL KEY" OR cmd$ = "GET KEY") AND r = 4 THEN
PRINT "YOU TAKE THE KEY AND GET NASTY STUFF ALL OVER YOUR HAND..."
LET gotboxkey2 = 1
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "TAKE LARGE BRONZE KEY" OR cmd$ = "TAKE BRONZE KEY" OR cmd$ = "TAKE KEY" OR cmd$ = "GET LARGE BRONZE KEY" OR cmd$ = "GET BRONZE KEY" OR cmd$ = "GET KEY") AND boxopen = 1 AND r = 5 THEN
PRINT "YOU TAKE THE LARGE BRONZE KEY."
LET gotmainkey = 1
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "TAKE ROLL OF TOILET PAPER" OR cmd$ = "TAKE TOILET PAPER" OR cmd$ = "GET ROLL OF TOILET PAPER" OR cmd$ = "GET TOILET PAPER") AND gottp = 0 THEN
PRINT "YOU PICK UP THE TOILET PAPER AND IT COMPLTELY FALLS APART IN YOUR HAND."
LET gottp = 1
DO
LOOP UNTIL LEN(INKEY$)
END IF

IF (cmd$ = "READ NOTE" OR cmd$ = "USE NOTE") AND gotnote = 1 THEN
PRINT "THE NOTE SAYS:"
PRINT "'BEHIND THE OLD CASTLE LIES HALF OF A TOOL OF YOUR FREEDOM.'"
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "PULL ROPE" OR cmd$ = "USE ROPE") AND r = 6 THEN
GOTO lose
END IF
IF (cmd$ = "UNLOCK JEWLERY BOX" OR cmd$ = "UNLOCK BOX") AND gotboxkey1 = 1 AND gotboxkey2 = 1 AND r = 5 THEN
PRINT "YOU INSERT THE TWO SMALL KEYS IN THE BOX AND IS SPRINGS OPEN"
PRINT "TO REVEAL A LAGRE BRONZE KEY."
LET boxopen = 1
DO
LOOP UNTIL LEN(INKEY$)
END IF
IF (cmd$ = "UNLOCK FRONT DOOR" OR cmd$ = "UNLOCK DOOR") AND gotmainkey = 1 AND r = 1 THEN
GOTO win
END IF
moved:
RETURN

r1:
COLOR 4
PRINT "YOU ENTER THE ENTRY WAY."
PRINT "YOU SEE AN OLD RUG LEADING TO WHAT APPEARS TO BE THE DINING ROOM."
PRINT "ANOTHER RUG LEADS TO A DIFFERENT ROOM."
PRINT
RETURN

r2:
COLOR 4
PRINT "YOU ENTER THE DINING ROOM."
PRINT "THERE ARE NO WINDOWS IN HERE, BUT THERE IS LIGHT FLOWING IN FROM THE"
PRINT "OTHER ROOM, YOU CAN BARELY SEE ANYTHING."
PRINT "THERE ARE SEVERAL DOORS LEADING TO DIFFERENT LOCATIONS."
PRINT "YOU SEE A TRAP DOOR THAT PROBABLY LEADS DOWN TO THE BASEMENT."
PRINT "THERE IS A HUGE TABLE IN THE MIDDLE OF THE ROOM."
PRINT "MOST OF THE CHAIRS SURROUNDING THE TABLE HAVE BROKEN LEGS."
PRINT "YOU ALSO SEE A PAINTING ON THE WALL."
PRINT
RETURN

r3:
COLOR 4
PRINT "YOU ENTER THE KITCHEN."
PRINT "YOU SEE A DOORWAY WITH THE DOOR MISSING."
PRINT "THERE IS A SINK AND A COUNTER."
PRINT "THERE IS A TON OF DUST ON THE COUNTER."
PRINT
RETURN

r4:
COLOR 4
PRINT "YOU ENTER THE BATHROOM."
PRINT "THERE IS A SMALL OPAQUE WINDOW ON THE WALL."
PRINT "THERE IS A DOOR THAT LEADS BACK TO THE KITCHEN."
PRINT "YOU SEE A BUCKET OF VILE SMELLING STUFF IN THE CORNER."
IF gottp = 0 THEN : PRINT "THERE IS A ROLL OF TOILET PAPER NEXT TO IT."
PRINT
RETURN

r5:
COLOR 4
PRINT "YOU ENTER THE BEDROOM."
PRINT "THERE IS A DOOR THAT LEADS BACK TO THE DINING ROOM."
PRINT "YOU SEE A PLAIN MAT ON THE FLOOR WITH A TORN UP BLANKET."
PRINT "YOU ALSO SEE A LARGE JEWLERY BOX."
PRINT
RETURN

r6:
COLOR 4
PRINT "YOU ENTER THE BASEMENT."
IF gotcandle = 1 THEN
PRINT "YOU LIGHT A CANDLE."
PRINT "YOU SEE A ROPE IN THE CENTER OF THE ROOM."
PRINT "THERE IS ALSO DREID UP BLOOD ON THE FLOOR."
ELSE
PRINT "THERE ARE NO WINDOWS IN HERE AND YOU CANT SEE ANYTHING."
PRINT "TRY TO SEE IF YOU CAN FIND A CANDLE."
PRINT "YOU HEAD BACK UP THE LADDER."
LET r = 2
END IF
PRINT
RETURN

win:
COLOR 14
PRINT "YOU UNLOCK THE DOOR, OPEN IT AND WALK OUTSIDE AND SMELL THE FRESH AIR."
PRINT "THE SUN IS SETTING. IF YOU HAD STAYED IN THERE LONGER, YOU WOULD"
PRINT "BE IN COMPLETE DARKNESS AND PROBABLY HAD TO SPEND THE NIGHT IN THERE!"
PRINT "REALIZING THAT YOU ARE STILL GROUNDED, YOU HEAD BACK HOME BEFORE YOUR"
PRINT "MOM NOTICES THAT YOU WERE GONE..."
PRINT
PRINT "YOU WIN!"
PRINT "PRESS ANY KEY..."
DO
LOOP UNTIL LEN(INKEY$)
GOTO menu

lose:
COLOR 14
PRINT "YOU HEAR SOMETHING UNLOCK FOLLOWD BY A BIG CRASH."
PRINT "YOUR CANDLE BLOWS OUT."
PRINT "A LARGE BLADE SWINGS DOWN FROOM THE CIELING AND DECAPITATES YOU!"
PRINT
PRINT "GAME OVER!"
PRINT "PRESS ANY KEY..."
DO
LOOP UNTIL LEN(INKEY$)
GOTO menu

[/url]
Home: http://www.geekbasic.com" target="_blank
Forum: http://www.geekbasic.com/index.gbws?$page=forumsmain" target="_blank
QB64 powered web server: http://www.geekbasic.com/index.gbws?$pa ... inter=%201" target="_blank

User avatar
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Post by sid6.7 » Sun Dec 14, 2008 8:13 pm

good little game you made...

only complaint is the text is sometimes too dark to read on a black background. try to stay with colors like yellow white and red and cyan.

User avatar
burger2227
Veteran
Posts: 2344
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Sun Dec 14, 2008 8:23 pm

Sid means colors over 9 for brighter screen text.

To change colors 1 to 7 brighter add 8 to the color number you were using.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

User avatar
bongomeno
Veteran
Posts: 231
Joined: Wed Dec 10, 2008 9:08 am
Location: San Bernardino CA
Contact:

thanx

Post by bongomeno » Mon Dec 15, 2008 8:49 am

thanx 4 the review. i chose those colours, because I like to make the writing stand out over a black backgroung, but ill change up the colors in my next if :D
Home: http://www.geekbasic.com" target="_blank
Forum: http://www.geekbasic.com/index.gbws?$page=forumsmain" target="_blank
QB64 powered web server: http://www.geekbasic.com/index.gbws?$pa ... inter=%201" target="_blank

Post Reply