Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with my RPG
#1
I want to randomize monster encounter then i keep on getting same monster (which is number 1) over and over again

jajaarmy = INT(RND * 3) + 1
IF jajaarmy = 1 THEN
'you encounter monster 1

ELSEIF jajaarmy = 2 THEN
' you encounter monster 2

ELSEIF jajaarmy = 3 THEN
'you encounter monster 3

any idea?
Reply
#2
Place this at the top of your program:

[syntax="QBASIC"]
RANDOMIZE TIMER
[/syntax]

The RANDOMIZE instruction tells QB to change the 'seed' of the pseudo-random number generator (i.e. the number that it bases the next pseudo-random numbers from). Passing it TIMER will take the time elapsed in seconds since midnight. Thus, the only time you'll get the same sequence of numbers produced is if you run the program exactly 24 hours later. Wink
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#3
Quote:Place this at the top of your program:

[syntax="QBASIC"]
RANDOMIZE TIMER
[/syntax]

The RANDOMIZE instruction tells QB to change the 'seed' of the pseudo-random number generator (i.e. the number that it bases the next pseudo-random numbers from). Passing it TIMER will take the time elapsed in seconds since midnight. Thus, the only time you'll get the same sequence of numbers produced is if you run the program exactly 24 hours later. Wink

doesn't work Cry I am tryint to say if randomized variable which is "jajaarmy" equal to 1 or 2 or 3 then you encounter difffernt monster not night time thingy (i don't know RANDOMIZE TIMER because i am noob)
Reply
#4
logicalaxiom:
You have been given very good advice. Run this little program over and over, to see how the advise given can help you:

Code:
without = INT(RND * 3) + 1
RANDOMIZE TIMER
with = INT(RND * 3) + 1
PRINT "With and WithOut RANDOMIZE TIMER"; with; without
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#5
OMG thank YOU Sooo much i fixed it :rotfl: thanks to your help i can't describe how happy i am rite now :bounce:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)