Experience bar image

Place to place any code snippets, completed games, or even uncompleted games for IR users to use.
Post Reply
stefans
Posts: 48
Joined: Wed Sep 14, 2011 7:14 pm

Experience bar image

Post by stefans »

Hello all,

I made an exp bar image, you can configure the height and the width of it, or just the standard (width = 100, height = 20)
Configured one:
Image

Code: Select all

http://skillaria.byethost3.com/phpimages/bar.php?amount=25&width=200&height=100
Default one:
Image

Code: Select all

http://skillaria.byethost3.com/phpimages/bar.php?amount=90
The code used for this image:

Code: Select all

<?php
if(!isset($_GET['height'])) {
	$height = 20;
} else {
	$height = $_GET['height'];
}
if(!isset($_GET['width'])) {
	$width = 100;
} else {
	$width = $_GET['width'];
}
$amount = intval($_GET['amount']);
$im = Imagecreatetruecolor($width, $height);
$red = Imagecolorallocate($im, 255, 0, 0);
$green = Imagecolorallocate($im, 0, 255, 0);
imagefill($im, 0, 0, $red);
imagefilledrectangle($im, 0, 0, $amount * $width/100, $height, $green);
$border = ImageColorAllocate($im, 0, 0, 0);
ImageRectangle($im, 0, 0, $width - 1, $height - 1, $border);
$font = 3;
$font_width = ImageFontWidth($font);
$font_height = ImageFontHeight($font);
$text = $amount . "%";
$text_width = $font_width * strlen($text);
$position_center = ceil(($width - $text_width) / 2);
$text_height = $font_height;
$position_middle = ceil(($height - $text_height) / 2);
$textcolor = imagecolorallocate($im, 0, 0, 0);
ImageString($im, $font, $position_center, $position_middle, $text, $textcolor);

header("Content-type: image/png");
Imagepng($im);
Imagedestroy($im);
?>
I don't know if this is a good code or not, but it works :) so..
Have fun!
Last edited by stefans on Tue Dec 13, 2011 6:17 pm, edited 2 times in total.
Current project: http://www.mmtycoon.eu
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Experience bar image

Post by Jackolantern »

Images seem to be broken :(
The indelible lord of tl;dr
stefans
Posts: 48
Joined: Wed Sep 14, 2011 7:14 pm

Re: Experience bar image

Post by stefans »

yeah probably because they are reviewing my website --'
i hope they won't delete it..

Code: Select all

7. We do not allow online gaming scripts such as ogame, mafia, etc.. (allowed if you upgrade account)
XD
Current project: http://www.mmtycoon.eu
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Experience bar image

Post by Jackolantern »

Who is your host? Do you actually have a whole, working game up on them?
The indelible lord of tl;dr
stefans
Posts: 48
Joined: Wed Sep 14, 2011 7:14 pm

Re: Experience bar image

Post by stefans »

000webhost, i tried the other one, they recommended me.. but that site doesn't load at all..
and my game is not really finished yet.. XD
i don't have money for a paid host right now so..
Current project: http://www.mmtycoon.eu
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Experience bar image

Post by Jackolantern »

Ohhhh, yeah...000 is quite game-unfriendly on their free hosting. You basically have to bait and switch on them and just put up some crap static pages for a couple of weeks until you are basically sure they have already checked it, then you can add your game scripts.
The indelible lord of tl;dr
stefans
Posts: 48
Joined: Wed Sep 14, 2011 7:14 pm

Re: Experience bar image

Post by stefans »

updated image :p
i uploaded it on one of my older websites :p
Current project: http://www.mmtycoon.eu
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Experience bar image

Post by OldRod »

ESET security blocks your links for some reason...
stefans
Posts: 48
Joined: Wed Sep 14, 2011 7:14 pm

Re: Experience bar image

Post by stefans »

weird :p
Current project: http://www.mmtycoon.eu
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Experience bar image

Post by Jackolantern »

They still just look broken to me, and I don't use ESET :shock:
The indelible lord of tl;dr
Post Reply

Return to “Code Sharing”