[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programming Question



When I want a "PRESS ANY KEY" routine, I figure that something might as well
happen if the program is going to be running.  Here is my routine.

140 PRINT "PRESS ANY KEY TO CONTINUE..."
 150 A =  RND (1)
 155  IF  PEEK ( - 16384) < 128 THEN 150
 160  GET A$

The line that constantly assigns A to a random number is great to use in games
where random chance is involved.  As most programmers know, computers don't
generate true random numbers.  By using a routine like the above, you can more
realistically simulate them.  Since the loop runs several times per second,
and you almost never press a key at the exact same moment, things seem a bit
more random.  I like to run a routine like this before playing some old BASIC
games I have (like a blackjack game.)  It makes things less predictable.  I
wrote this routine after I got tired of knowing what the first few "random"
numbers would be at power-up.

Adam Myrow