Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Craps Game

    Im looking to make a simple craps game and i need some help on it this is what the final outcome should look like

    http://ctech.smccme.edu/~zeke/cw/save/craps/craps.pl

    if you want the code and my site that i have as of right now and you think you can help me a little at a time i'd appreciate it.

    Thanks

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts
    It doesn't appear that you've followed the suggestions that you were given in your cross posts on devshed.com and bytes.com and wherever else you've posted this question.

    You need to show us your full script and ask specific questions on the part(s) that is giving you trouble. However, keep in mind that we are not going to do your homework for you, but we can give you a little guidance.

  • #3
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    Theres my code and here's my site
    
    http://ctech.smccme.edu/~rhodge/cw/craps/craps.pl
    
    
    
    #!/usr/bin/perl
    use CGI ':standard';
    use CGI::Carp "fatalsToBrowser";
    
    print header;
    
    &form;
    &input;
    
    #######sub routines###########
    
    sub form{
    
    print"
    
    <form method=post action=craps.pl>
    <input type=hidden name=dice1 value=dice1>
    <input type=hidden name=dice2 value=dice2>
    <input type=hidden name=total1 value=total1>
    <input type=hidden name=ctrl value=ctrl>
    <input type=submit value='Throw Again'>
    </form>
    
    
    <img src=images/1.gif><img src=images/3.gif>
    <img src=images/blank.gif><img src=images/blank.gif>
    
    ";
    }
    
    #########param#########
    sub input{
    
    $dice1=param('dice1');
    $dice2=param('dice2');
    $total1=param('total1');
    $ctrl=param('ctrl');
    
    int(rand(6))
    }

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts
    You haven't implemented the suggestions I gave you on devshed.com and you haven't asked a specific question so how can you expect me or anyone else to assist you. We are not going to write your homework script for you.

  • #5
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to know how to switch images everytime i hit the submit button so it picks random pictures. My images are called 1.gif 2.gif ect.. to 6.

    Once i get that than i can use conditions to say when the two dice add up to 7 or 11 on the first roll then it says i win.

    If i roll the number ect... then i lose and if i roll a "point" then the two images below it change and until i match the number i win but if i get a 7 or 11 on the second role i lose.

  • #6
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts
    There are several ways to select a random image.

    This should get you started.
    http://search.cpan.org/~bigj/File-Random-0.17/Random.pm

  • #7
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    doesnt help me too much

  • #8
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Quote Originally Posted by Rhodge09 View Post
    doesnt help me too much
    That response doesn't tell me what you don't understand, so it's hard for me to help you.

    The module I pointed you to has several clear examples on how to select a random image file. From there you just need to use that var in your img tags.

  • #9
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can't give me an idea what im supposed to do with these images?

    Like an example or something? I know you gave me a sight and stuff but i can't relate it to what im doing.


    print "<img src=\"dice" . $dice_side . "\.jpg\" \/>\n";

    will that work?
    Last edited by Rhodge09; 12-04-2009 at 01:47 AM.

  • #10
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    better to use print qq( html in here ); instead of having to escape everything with a \.

    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #11
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    print qq? never heard of that

  • #12
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    yeh, it's

    Code:
     print qq();
    where you put your output between the brackets

    Code:
    print qq(  <img src='filename' alt='' title='' />  );
    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #13
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So say i have two images on my screen and i hit the submit button and i want those images to go randomly through 6 images because in this case there are six sides to a dice and i have 6 pictures saved.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •