• Print

Author Topic: Hello to all the QB users out there.  (Read 252 times)

therealdavetaylor

  • Newbie
  • *
  • Posts: 22
  • Qbasic for life.
    • Email
Hello to all the QB users out there.
« on: March 16, 2013, 02:04:41 PM »
I am having a bit of a problem over here in snowy Edmonton AB.
My problem is that i'm working on another qbasic text adventure
game. This game is something I've never done before. A text hunting
game and my problem is for when someone types in "FIRE" how can
I randomize between a miss and a hit? If anyone could help me, I
will be truly grateful. Also I will post the game once it's complete.

 
How come I'm the only person I know who writes text adventures in basic???

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Hello to all the QB users out there.
« Reply #1 on: March 16, 2013, 02:10:38 PM »
Hi all,
    Here's an example, run it a few times. Even 50% chance.
Code: [Select]
REM
DEFINT A-Z

PRINT "Enter in the word FIRE"
INPUT Word$
IF UCASE$(Word$) = "FIRE" THEN
  RANDOMIZE TIMER
  z% = INT(RND * 2) + 1
  IF z% = 1 THEN PRINT "On Fire!" ELSE PRINT "Not on Fire"
END IF
OlDosLover.

fluffrabbit

  • Sr. Member
  • ****
  • Posts: 393
Re: Hello to all the QB users out there.
« Reply #2 on: March 17, 2013, 09:30:30 AM »
Code: [Select]
  z% = INT(RND * 2) + 1
  IF z% = 1 THEN PRINT "On Fire!" ELSE PRINT "Not on Fire"
What? INT(RND * 2) will equal 1 50% of the time anyways.

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Hello to all the QB users out there.
« Reply #3 on: March 17, 2013, 10:59:06 AM »
Hi all,
   
Code: [Select]
z% = INT(RND * 2) + 1    Will produce 1 or 2.

   
Code: [Select]
z% = INT(RND * 2)     Will produce 0 or 1.
Either will work if reacting to z% being 1.
OlDosLover.

therealdavetaylor

  • Newbie
  • *
  • Posts: 22
  • Qbasic for life.
    • Email
Re: Hello to all the QB users out there.
« Reply #4 on: March 17, 2013, 12:00:26 PM »
Alright, alright, alright everybody. I believe the time has arrived.
I would like to thank OlDosLover for helping me out in my time
of need. I would also like to thank fluffrabbit for breaking it down
for me on this topic. Though I do love to program text adventure's
in Qbasic, I am still somewhat of a novice when it comes to
programming. So any help I can get will help me out so very much.
Because I can't stand using authoring software to make games.
As a fan and user of Qbasic. I would like to continue creating in
Qbasic. With that said here is the finished version of "Through
the Storm". In the zip file you will find said game and a map with
a command list. I would like to thank you all again.
How come I'm the only person I know who writes text adventures in basic???

Novicaine

  • Newbie
  • *
  • Posts: 11
Re: Hello to all the QB users out there.
« Reply #5 on: March 29, 2013, 07:32:19 AM »
I see you got it working, but I wanted to throw this out for a potential solution also:

Code: [Select]
   IF RND < 0.50 THEN PRINT "HIT!"

And if you wanted it to hit only 13% of the time:

Code: [Select]
   IF RND < 0.13 THEN PRINT "HIT!"





OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Hello to all the QB users out there.
« Reply #6 on: March 29, 2013, 07:39:41 AM »
Hi all,
    Very good solution Novicaine. The simplest i've seen so far!
OlDosLover.

  • Print