...

View Full Version : Simple Craps Game



Rhodge09
12-03-2009, 05:13 AM
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

FishMonger
12-03-2009, 02:21 PM
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.

Rhodge09
12-03-2009, 03:19 PM
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))
}

FishMonger
12-03-2009, 05:42 PM
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.

Rhodge09
12-03-2009, 06:23 PM
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.

FishMonger
12-03-2009, 06:49 PM
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

Rhodge09
12-03-2009, 10:35 PM
doesnt help me too much

FishMonger
12-03-2009, 11:15 PM
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.

Rhodge09
12-04-2009, 01:45 AM
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?

bazz
12-04-2009, 02:00 AM
better to use print qq( html in here ); instead of having to escape everything with a \.

bazz

Rhodge09
12-04-2009, 02:03 AM
print qq? never heard of that

bazz
12-04-2009, 02:10 AM
yeh, it's



print qq();



where you put your output between the brackets



print qq( <img src='filename' alt='' title='' /> );


bazz

Rhodge09
12-04-2009, 02:32 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum