CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Moving positions

 



Lynn
Novice

Sep 23, 2012, 1:01 PM

Post #1 of 3 (2528 views)
Moving positions Can't Post

I need to increment xpos according to a random number 1-6 or deincrement it 1-6. I do not know how to go about that. My thought was:

Code
my $range = 1; 
my $minimum = 6;

my $random_number = int(rand($range)) + $minimum;

$xpos = $random_number; #instead of $xpos++ to move one position at a time


And then to deincrement 1-6 spaces, I have no idea. Can anyone point me in the right direction, or a good tutorial?
Thanks


BillKSmith
Veteran

Sep 23, 2012, 2:06 PM

Post #2 of 3 (2526 views)
Re: [Lynn] Moving positions [In reply to] Can't Post


Code
 
$xpos += (1 + int rand 6); # increment

$xpos -= (1 + int rand 6); # decrement

Good Luck,
Bill


Lynn
Novice

Sep 24, 2012, 11:21 AM

Post #3 of 3 (2506 views)
Re: [BillKSmith] Moving positions [In reply to] Can't Post

Thank you! This helped so much!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives