
drseuss
Members-
Posts
14 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
drseuss's Achievements

Newbie (1/5)
0
Reputation
-
Does no one know what I am talking about -.-
-
What is the following in bold called? I do know what it does, I just do not know the name of it. switch($command[$i]{0}) {
-
I got the problem fixed. I had to do the image tag like you said. Thanks for your help.
-
The subject says it all. I'm trying to build a tiled map. Using the same ideas for an avatar. avatar.lib.php <?PHP //include 'db.lib.php'; class avatar { var $filename; //the filename of the final image var $width = 100; //the final width of your icon var $height = 100; //the final height of the icon var $parts = array(); //the different images that will be superimposed on top of each other /** * SET WIDTH * This function sets the final width of our avatar icon. Because we want the image to be * proportional we don't need to set the height (as it will distort the image) * The height will automatically be computed. * * @param Integer $width */ function set_width($width) { //setting the width $this->width = $width; } /** * SET FILENAME * This sets the final filename of our icon. We set this variable if we want * to save the icon to the hard drive. * * @param String $filename */ function set_filename($filename) { $this->filename = $filename; } /** * SET BACKGROUND * From this function we can add one of two types of backgrounds * either an image or a solid color. * * @param String $background */ function set_background($background) { $this->background_source = $background; } /** * ADD LAYER * This is the meat and potatoes of this class (And it's so small!) * This function let's us add images to our final composition * * @param String $filename */ function add_layer($filename) { //by using the syntax $this->parts[] we are automatically incrementing the array pointer by 1 //There is no need to do $this->parts[$index] = $filename; // $index = $index + 1; $this->parts[] = $filename; } /** * BUILD BACKGROUND * This function takes our background information and compiles it */ function build_background() { //---------------------------------------- // Getting the height //---------------------------------------- //grabbing the first image in the array $first_image = $this->parts[0]; //getting the width and height of that image list($width, $height) = getimagesize($first_image); //finding the height of the final image (from a simple proportion equation) $this->height = ($this->width/$width)*$height; //---------------------------------------- // Compiling the background //---------------------------------------- //the background canvas, it will be the same width and height $this->background = imagecreatetruecolor($this->width, $this->height); //---------------------------------------- // Adding a background color // I'm going to be sending hex color values (#FFFFFF), //---------------------------------------- //checking to make sure it's a color if(substr_count($this->background_source, "#")>0) { //converting the 16 digit hex value to the standard 10 digit value $int = hexdec(str_replace("#", "", $this->background_source)); //getting rgb color $background_color = imagecolorallocate ($this->background, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int); //filling the background image with that color imagefill($this->background, 0,0,$background_color); //---------------------------------------- // Adding a background image // If $background is not a color, assume that it's an image //---------------------------------------- }else{ //getting the width and height of the image list($bg_w, $bg_h) = getimagesize($this->background_source); // Make sure that the background image is a png as well. $img = imagecreatefrompng($this->background_source); //This function copies and resizes the image onto the background canvas imagecopyresampled($this->background, $img, 0,0,0,0,$this->width, $this->height, $bg_w, $bg_h); } } /** * Build Composition * This function compiles all the information and builds the image */ function build_composition() { //---------------------------------------- // The Canvas // Creating the canvas for the final image, by default the canvas is black //---------------------------------------- $this->canvas = imagecreatetruecolor($this->width, $this->height); //---------------------------------------- // Adding the background // If the background is set, use it gosh darnit //---------------------------------------- if($this->background) { imagecopyresampled($this->canvas, $this->background, 0,0,0,0,$this->width, $this->height, $this->width, $this->height); } //---------------------------------------- // Adding the body parts // Here we go, the best part //---------------------------------------- //looping through the array of parts for($i=0; $i<count($this->parts); $i++) { //getting the width and height of the body part image, (should be the same size as the canvas) list($part_w, $part_h) = getimagesize($this->parts[$i]); //storing that image into memory (make sure it's a png image) $body_part = imagecreatefrompng($this->parts[$i]); //making sure that alpha blending is enabled imageAlphaBlending($body_part, true); //making sure to preserve the alpha info imageSaveAlpha($body_part, true); //finally, putting that image on top of our canvas imagecopyresampled($this->canvas, $body_part, 0,0,0,0,$this->width, $this->height, $part_w, $part_h); } } /** * OUTPUT * This function checks to see if we're going to ouput to the header or to a file */ function output() { // If the filename is set, save it to a file if(!empty($this->filename)) { //notice that this function has the added $this->filename value (by setting this you are saving it to the hard drive) imagejpeg($this->canvas, $this->filename,100); //Otherwise output to the header }else{ //before you can output to the header, you must tell the browser to interpret this document //as an image (specifically a jpeg image) header("content-type: image/jpeg"); //Output, notice that I ommitted $this->filename imagejpeg($this->canvas, "", 100); } //Removes the image from the buffer and frees up memory imagedestroy($this->canvas); } /** * BUILD * The final function, this builds the image and outputs it */ function build() { //Builds the background $this->build_background(); //builds the image $this->build_composition(); //outputs the image $this->output(); } }//end of class ?> theMap.php <?PHP include '../../lib/avatar.lib.php'; include '../../lib/settings.lib.php'; $sql = "select * from map where id='1'"; $result = $db->db_query($sql); $mInfo = $db->db_fetch_array($result); $MAX = $mInfo['maxX']; $MAY = $mInfo['maxY']; $tImg = $MAX * $MAY; $x = 0; $y = 0; $mapData = explode('/',$mInfo['mapCords']); $mapCnt = count($mapData); for($iC=0;$iC<$tImg;$iC++) { $tile = new avatar; $tile->set_width('40'); $tile->set_background('#000000'); $cords = $x.",".$y; for($s=0;$s<$mapCnt;$s++) { $ok = explode(':',$mapData[$s]); if($ok[0] == $cords) { break; } } $mData = explode(':',$mapData[$s]); if($mapData[$s]) { $sql = "select * from tiles where id='".$mData[1]."'"; $result = $db->db_query($sql); $tInfo = $db->db_fetch_array($result); $tile->add_layer('../../images/map/'.$tInfo['img'].'.png'); $tile->build(); } else { $tile->add_layer('../../images/map/0.png'); $tile->build(); } if ( ($iC % $MAX) == 0) { echo '<BR />'; $y++; $x = 0; } $x++; } ?> The avatar.lib.php file works good when I use it alone with theMap.php file. When I throw in the other includes, which do work correctly, it starts showing this: ÿØÿà�JFIF������ÿþ�<Éw,—SÞ¤®“ù6økYïäßs$jÑ4°/Ï1µŽCŸ/Nˆ<3iãÛKOø™ZÃonËkk§jrjÿ�Ú+{owä$]½ºÏc§¥¬WÍ'“qwýHŸùz—ÒÁª«ìñ•«ª8hÓ§NOêŸ\Ä*pÅTå\ðŠ”Z…H >ÆPDI/KÁ8,ž–6–2ߎXL¡g–SÌ+¼5<Ëš¥\EJmNIQÄ:~Ö•J1©É:’§ÃjÖö_cm>]6Ìêö±@MÞ«iÄ6Öz³¶“i<ÄÙjZö©;é¦ÕÑ|Ȭív\^]j~{aÜÜ=æ©®ÿ�£Ë<ÖË¡®Ú¤zÜ:-Þ¯§ø>æîÃS±€éöÚt÷ãx© :Š_EÞ´½»¹f·º÷ýÎM?|5Ñ!Õmõ˜F·¥E©^"Å¢^hö–—WºËÝÝ}®X/-mµ‹uÓ"P‹´_%tÛëë”ò? é×(ѧ»ðõľð×…l.#ñ—�™ Ó¡ÔmUÔÒÑ^Cq©ßj:zJ¶ÐC6¡$m8ªåtp¸Š˜|±5]|6'á*q…zˆJRÅɨPx^|:”)Ê3ýí*uU%5gåf¼5—`ñ0ÃäñÄãêc0Xì-,;ž\>a—âTkb1ËÙC õiaœªAT*ôêB£NU(ÓI"×íþêG£ÙO K;è÷Ù4ë¦"2ÞEq¨\‚æÞÖöX.-îyVXÝ£¶ó®¥ëèÖ/âvð^¯>©cu©\jÚš¤ºÜó7‘{rëq ækqy}©]‹HÞÅ.mâ[Y.´àö$)‚�W«G&ÊiÒ§Wì«VÅB8‰4kÖƆ%,|(á§F2ÃÑ^Ê4’¥RZ¤k9Ô It's actually a lot longer than that.... But any help would be appreciated. Thanks in advance
-
Hi. I'm working on a project that involves taking two or more images and placing them on top of each other. I remember there used to be a Tutorial on the web that used brian griffin as an example. I am looking and looking and I cannot find anything about it, unless I am searching incorrectly. Any help would suffice Thanks in advance.
-
Yup... Looks like I do need to go to bed... Thanks a lot.
-
I've been trying to figure this error out for a while now. $sql = "select * inventory where pid=".$settings['user']['stats']['id']." AND id=".$itemId; $result = $db->db_query($sql); $item = $db->db_fetch_array($result); I use have been doing all of my queries like this. But now I get an error like this. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'inventory where pid=1 AND id=1' at line 1 Please help me figure it out.
-
Hello everyone, i'm playing with the PHP GD library, just to keep myself practicing. In the code I am grabbing the coords from a DB and putting them in an array. The code works, but I don't think its the best way of doing it... it just doesn't look right. I'm not really used to making arrays out of loops, but this is my code; $place = 0; $pixelQ = $class->query("select * from pixelCoords where owner='1'"); while($pixelF = $class->fetch()) { $corners[$place+1] = array('x' => $pixelF['x'], 'y' => $pixelF['y']); $place++; } This is a small part of the script, of me calling the array to be used; imagesetpixel($gd, round($x),round($y), $red); $a = rand(1, $place); $x = ($x + $corners[$a]['x']) / 2; $y = ($y + $corners[$a]['y']) / 2;
-
Ok, I have a basic idea of what I should do for this. But I also do not believe it is an efficient way of doing this. My basic idea: Set all tiles to unsigned Place a few random land seeds Check all adjacent tiles to see if unsigned if unsigned, give it a property (land water whatever) (70% chance to be water, if land make unsigned tiles around it land) Like I said... basic. I just don't know how i would make the land stop growing after it starts... I don't know how I would make the land look more natural (not so square)... and shore lines I think are going to be hard. I don't want the code for a random generator... Just help understanding how this process would be completed (a push in the right directions) Thank you for any and all help from everyone in advance; drseuss
-
All is well now. Thanks a lot for you help. Now I continue testing.
-
I didn't change a lot. And it does not error out. <?PHP error_reporting(E_ALL); include 'lib/database.class.php'; $db = new Database(); $query = $db->query('select * from accounts'); while ($a = $db->fetch($query)){ echo $a['id'].$a['username']."<br />".$a['password']; } ?>
-
Well it doesn't loop non-stop anymore. But it still wont display results. Thanks for your help, I guess I didn't fully understand how the loop works. Lol
-
Yea thats the credentials I use on my home comp (xxamp haha). I'd never give my info out lol I understand where you are coming from, but I cannot think of how to make the $this->query() run only once while the results keep going.
-
Hello, I am new to OOP. I am trying to make a Database Class, which was going well up to the testing period. When I run the test, the script runs without parse errors or anything, but the output never stops, kind of like the script is in an infinite loop. Oh and if you plan to bitch and moan about me being new to OOP coding, have at it. Just remember that it shows how immature a person you are. Thank you in advanced. database.class.php <?PHP class Database { var $host; var $user; var $pass; var $selectDb; var $connection; var $Db; var $query; var $error; function __construct() { $this->host = 'localhost'; $this->user = 'dwsonet'; $this->pass = 'p1a2s3s4'; $this->selectDb = 'dwsonet_game'; $this->connect(); } function connect() { $this->connection = mysql_connect($this->host, $this->user, $this->pass); if(!$this->connection) { $this->error = mysql_error(); die('Can not continue'); } $this->Db = mysql_select_db($this->selectDb,$this->connection); if(!$this->Db) { $this->error = mysql_error(); die('Can not continue'); } } function query($sql) { $this->query = mysql_query($sql)or die(mysql_error()); return $this->query; } function fetch() { return mysql_fetch_array($this->query)or die(mysql_error()); } } test.php (I made it simple to show how I am using it. Please correct me if I am wrong) <?PHP error_reporting(E_ALL); include 'lib/database.class.php'; $db = new Database(); $query = 'select * from accounts'; while ($a = $db->fetch($db->query($query))){ echo $a['username']."<br />".$a['password']; } ?>