Proudly hosted with Dreamhost

Save $20 when signing up for Dreamhost by using the promo code amnuts20
If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh to encourage me to continue? Every little helps!
|
Battleships By Email (BBE)
Play battleships against an opponent via email! No database required as all information is passed along a URL.
A database is used in the script, however, to allow for recording of wins and losses.
One problem with this script is that Outlook's maximum querystring length seems to be 255 characters (or there abouts), and the URL created by this script is almost always longer than that. However, it works great with other mail clients such as Mozilla, Eudora, Pine, Elm, Mutt, etc.
index.php
20.36kb in size last modified May 6, 2006 at 1:54pm 6172 views, 6373 downloads
makeboard.php
3.29kb in size last modified May 6, 2006 at 1:54pm 4708 views, 5552 downloads
makelegend.php
<?php
include "setup.php";
// work out size - height is going to be total rows, plus // gaps between each row of, say, 2 pixels. Width is the block // and the largest size string // height $totalrows = SHIPTYPES + count($misccolours); $h = (PSIZE * $totalrows) + (($totalrows - 1) * (SPACER*2));
// width $size = 0; for ($i=0; $i<SHIPTYPES; $i++) { if (strlen($ships[$i][name]) > $size) { $size = strlen($ships[$i][name]); } } $w = PSIZE + (SPACER*4) + ($size*ImageFontWidth(FONT));
// create image $l = ImageCreate($w,$h); // setup colours $black = ImageColorAllocate($l,0,0,0); $white = ImageColorAllocate($l,255,255,255); $miss = ImageColorAllocate($l,$misccolours[MISS][0],$misccolours[MISS][1],$misccolours[MISS][2]); $hit = ImageColorAllocate($l,$misccolours[HIT][0],$misccolours[HIT][1],$misccolours[HIT][2]); $sea = ImageColorAllocate($l,$misccolours[SEA][0],$misccolours[SEA][1],$misccolours[SEA][2]); // make sea ImageFilledRectangle($l,0,0,$w,$h,$white);
$w_at = 0; $h_at = 0; for ($i=1; $i<=count($misccolours); $i++) { switch($i) { case HIT: ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$hit); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,"Hit",$black); break; case MISS: ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$miss); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,"Miss",$black); break; case SEA: ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$sea); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,"Sea",$black); break; } $h_at += PSIZE+(SPACER*2); }
for ($i=0; $i<=count($shipcolours); $i++) { switch($i) { case CARRIER: $sc[CARRIER] = ImageColorAllocate($l,$shipcolours[CARRIER][0],$shipcolours[CARRIER][1],$shipcolours[CARRIER][2]); ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$sc[CARRIER]); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,$ships[CARRIER][name],$black); break; case BATTLE: $sc[BATTLE] = ImageColorAllocate($l,$shipcolours[BATTLE][0],$shipcolours[BATTLE][1],$shipcolours[BATTLE][2]); ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$sc[BATTLE]); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,$ships[BATTLE][name],$black); break; case DESTROYER: $sc[DESTROYER] = ImageColorAllocate($l,$shipcolours[DESTROYER][0],$shipcolours[DESTROYER][1],$shipcolours[DESTROYER][2]); ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$sc[DESTROYER]); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,$ships[DESTROYER][name],$black); break; case SUBMARINE: $sc[SUBMARINE] = ImageColorAllocate($l,$shipcolours[SUBMARINE][0],$shipcolours[SUBMARINE][1],$shipcolours[SUBMARINE][2]); ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$sc[SUBMARINE]); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,$ships[SUBMARINE][name],$black); break; case PTBOAT: $sc[PTBOAT] = ImageColorAllocate($l,$shipcolours[PTBOAT][0],$shipcolours[PTBOAT][1],$shipcolours[PTBOAT][2]); ImageFilledRectangle($l,SPACER,$h_at,SPACER+PSIZE,$h_at+PSIZE,$sc[PTBOAT]); ImageString($l,FONT,(SPACER*3)+PSIZE,$h_at,$ships[PTBOAT][name],$black); break; } $h_at += PSIZE+(SPACER*2); }
// now output the image header("Content-type: image/png"); ImagePNG($l);
// clean up //ImageDestroy($b);
?>
3.29kb in size last modified May 6, 2006 at 1:54pm 4773 views, 5478 downloads
makemap.php
437b in size last modified May 6, 2006 at 1:54pm 4432 views, 5501 downloads
setup.php
2.27kb in size last modified May 6, 2006 at 1:54pm 4523 views, 5571 downloads
|