<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHail [dot net] Blog - Design, Programming, and other things. &#187; Tutorials</title>
	<atom:link href="http://phail.net/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://phail.net</link>
	<description>A creative and sometimes technical blog about Design and Programming as well as other things.</description>
	<lastBuildDate>Sat, 22 May 2010 04:23:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>(mostly) Painless Illustration</title>
		<link>http://phail.net/2008/05/05/mostly-painless-illustration/</link>
		<comments>http://phail.net/2008/05/05/mostly-painless-illustration/#comments</comments>
		<pubDate>Mon, 05 May 2008 18:00:08 +0000</pubDate>
		<dc:creator>Mike Wojo</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[draw]]></category>
		<category><![CDATA[illustration]]></category>
		<category><![CDATA[illustrator]]></category>
		<category><![CDATA[iMac]]></category>
		<category><![CDATA[mostly]]></category>
		<category><![CDATA[painless]]></category>
		<category><![CDATA[pen]]></category>
		<category><![CDATA[scan]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://phail.net/?p=16</guid>
		<description><![CDATA[&#8230;using Adobe Illustrator. Lately I&#8217;ve gotten into making simple illustrations for sites (like this one!).  I know that to most, my art isn&#8217;t amazing, but it works and it can be used to make a creative, cleanly designed website. This is kind of a mini-tutorial, and isn&#8217;t terribly detailed, but shows the basics of how I [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230;using <strong>Adobe Illustrator.</strong></p>
<p>Lately I&#8217;ve gotten into making simple illustrations for sites (like this one!).  I know that to most, my art isn&#8217;t <em>amazing</em>, but it works and it can be used to make a creative, cleanly designed website.</p>
<p>This is kind of a <strong>mini-tutorial</strong>, and isn&#8217;t terribly detailed, but shows the basics of how I make my humble art.</p>
<p> <strong>    1. Draw it on paper!</strong></p>
<p>Here&#8217;s a little sample I sketched before:</p>
<p><a href="http://phail.net/wp-content/uploads/2008/05/mr_illus_1.jpg"><img class="alignnone size-medium wp-image-17" title="mr_illus_1" src="http://phail.net/wp-content/uploads/2008/05/mr_illus_1-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p>This is the easiest part for me.  I am not that great of an artist, but it&#8217;s definitely easier to draw something on paper compared to trying to draw with a tablet or mouse.  Whatever you&#8217;re drawing, whether it be a logo or a potato, paper lets you be messy.  <strong>Go ahead, scribble or sketch, it&#8217;ll be refined later!</strong></p>
<p><strong>     2. Scan it or take a picture of it with a digital camera.</strong></p>
<p>(Below is a Canon PowerShot SD1000; Just an example of a nice Digital Camera.)</p>
<p><a href="http://phail.net/wp-content/uploads/2008/05/canon_powershot_sd1000.jpg"><img class="alignnone size-medium wp-image-18" title="canon_powershot_sd1000" src="http://phail.net/wp-content/uploads/2008/05/canon_powershot_sd1000.jpg" alt="" width="177" height="150" /></a></p>
<p> Instead of a digital camera, I use the iSight camera on my Apple iMac.  It&#8217;s conveniant (built in) and simple.  Just hold up the paper and snap a pic.  However, a camera or scanner will do just fine.</p>
<p>     <strong>3. Open up Illustrator and drag your scanned/captured image onto the canvas in a new layer.</strong></p>
<p>A new layer should be used so you can adjust opacity and see what you&#8217;re going to draw over it more clearly.</p>
<p>     <strong>4. <em>Pen Tool!</em></strong></p>
<p>Using the pen tool, trace over the outlines of the things you drew on paper (make sure to keep your pen tool created lines in a new layer over the original drawing!).  Also try to connect/close your pen tool shapes so you can fill them with colors or patterns after you&#8217;re done tracing.</p>
<p>     <strong>5. Color it!</strong></p>
<p>If you&#8217;ve closed/connected the shapes you drew with the pen tool, just fill everything with color you think would look good.  Adjust the order of your shapes in the layer if needed.  Be free and creative! <img src='http://phail.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>     <strong>6.</strong> <strong>Look at your finished product.</strong></p>
<p><a href="http://phail.net/wp-content/uploads/2008/05/mr_illus_sample.png"><img class="alignnone size-medium wp-image-19" title="mr_illus_sample" src="http://phail.net/wp-content/uploads/2008/05/mr_illus_sample-300x140.png" alt="" width="300" height="140" /></a></p>
<p>Does it look good? Is it how you like it?  If not, go back and fix or add some things.  Be creative with it.  Have fun.</p>
<p>And that&#8217;s it.  Yes, I know, this tutorial isn&#8217;t much better than the quality of my art, but I hope to help others learning to do Illustration like me. Good luck!  (By the way, I can probably attach pictures of using the pen tool and Illustrator, so let me know if that would be helpful to do.)</p>
]]></content:encoded>
			<wfw:commentRss>http://phail.net/2008/05/05/mostly-painless-illustration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Class Practice: Creating a Simple Pet Script</title>
		<link>http://phail.net/2008/04/21/php-class-practice-creating-a-simple-pet-script/</link>
		<comments>http://phail.net/2008/04/21/php-class-practice-creating-a-simple-pet-script/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 18:12:13 +0000</pubDate>
		<dc:creator>Mike Wojo</dc:creator>
				<category><![CDATA[Codes & Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[pet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://phail.net/?p=14</guid>
		<description><![CDATA[For the vast majority of the time I&#8217;ve been programming I haven&#8217;t used Classes in my code. They are relatively new to me. Because of this, I decided to practice writing classes since I realized how useful they are. Here&#8217;s something I made when I was learning. What We&#8217;re Making Today: We&#8217;re going to be [...]]]></description>
			<content:encoded><![CDATA[<p>For the vast majority of the time I&#8217;ve been programming I haven&#8217;t used Classes in my code. They are relatively new to me. Because of this, I decided to practice writing classes since I realized how useful they are. Here&#8217;s something I made when I was learning.</p>
<p><strong>What We&#8217;re Making Today:</strong><br />
We&#8217;re going to be making a small script comprised of a class, called <strong>Pet</strong>, with variables and functions inside of it to perform actions. Also keep in mind that this is <em>extremely</em> simple and most likely cannot be used for anything outside of practice without heavy modification.</p>
<p><strong>Let&#8217;s Begin, Shall We?</strong></p>
<ol>
<li>Create a new file. Let&#8217;s call it <strong>pet.php</strong>.</li>
<li>Open up the file and prepare for editing! (I use Dreamweaver for most code editing, but you can use plenty of other programs like the built in TextEdit (Mac) and NotePad (Windows).</li>
<li>Always remember to save it as a PHP file! Saving it accidentally as .txt or .rtf will make it not work at all.</li>
</ol>
<p><strong>Now for some code.</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//Some class practice.</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Pet<br />
<span style="color: #009900;">&#123;</span></div></div>
<p>We&#8217;ve now started the file and recognized it&#8217;s a PHP document. Then we initiated the class &#8220;Pet&#8221;.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$age</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$fullness</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$health</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">70</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$dead</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span></div></div>
<p>We&#8217;ve now created the variables name, age, fullness, and health for the class to use, and a public variable &#8216;dead&#8217;.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SetName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$txt</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;You have named your pet &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$txt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fullness: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Health: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Age: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">age</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Now we have a <strong>public function</strong> (A function that can be used outside of just inside the class code) called SetName. By calling the function with a string parameter, you assign that string to the class variable $name. It also echoes some text telling you about the pet.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> GetName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Since the variables we set earlier in the class (like $name) are <b>not public</b>, we can only access them through the inside code.  So, using this simple function called GetName(), we can retrieve the contents of the $name variable for that object.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//Increase pet's fullness by a random amount between 5 and 10.</span><br />
<span style="color: #000088;">$fulladd</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$fulladd</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;&lt;p&gt;You have fed &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; some food. Fullness increased by <span style="color: #006699; font-weight: bold;">$fulladd</span>.&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Every pet needs to be fed, right?  Well, since I said this is simple, we are just picking a number between 5 and 10 to add to it&#8217;s Fullness total.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> PassTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//Simulate some sort of reality I suppose..</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #339933;">*</span><span style="color:#800080;">.10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span> <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//Make sure stats are whole numbers</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ceil"><span style="color: #990000;">ceil</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ceil"><span style="color: #990000;">ceil</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//Increase age by a day? (Not really logical, but oh well.)</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">age</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p style='color:#999999;'&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Some time has passed.&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fullness: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Health: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Age: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">age</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Alrighty, this is a fun one.  We&#8217;re pretty much giving a little illustion that there&#8217;s time with our little pet.  We&#8217;re decreasing it&#8217;s fullness by 10% plus 5 (so it <i>can</i> die eventually), decreasing it&#8217;s hunger by a random percentage between 10% and 25% plus 2 (same reason as fullness), and using the php function <b>ceil</b> to round the numbers up so they are whole numbers.  We&#8217;re then increasing age by one count (a day perhaps?), making the text color gray, and echo&#8217;ing out what happened to the screen.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Killed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p style='color:red;'&gt;Your pet, &lt;b&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/b&gt;, is now in pet heaven.&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dead</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>This function checks to see if the pet has died due to hunger and health failure.  Once it&#8217;s fullness or health reach 0 or lower, the pet &#8220;goes to a better place&#8221;. <img src='http://phail.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Notice that it&#8217;s variable $dead is set true.  This will be used for exiting the loop later on.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#125;</span></div></div>
<p>Close up our class and we&#8217;re ready for the main part: The Loop!</p>
<p>We&#8217;re going to be using a loop to simulate a created pet&#8217;s life.  This loop will keep going as long as the pet is alive, and stop when it dies.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//Demonstrate the Pet class!</span><br />
<span style="color: #000088;">$Fluffy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #339933;">;</span><br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SetName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Fluffy The Sheep&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>We&#8217;ve created our pet and set his name to &#8220;Fluffy The Sheep&#8221;.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dead</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Feed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">PassTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Killed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Is our poor pet deceased?</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>The final part is the loop.  Like I said before, the loop keeps going as long as the pet is alive.  Once it is dead (determined by the Killed() function), it&#8217;s state changes and the loop exits.</p>
<p>And there you have it! Try running the program and see your little pet in action. Feel free to also customize the experience (name it!).  I hope you were able to learn something new out of this. <img src='http://phail.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Happy coding!</p>
<p>(By the way, using these settings my pet lived to be around 12-14 age.)</p>
]]></content:encoded>
			<wfw:commentRss>http://phail.net/2008/04/21/php-class-practice-creating-a-simple-pet-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
