<?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>Development Soup</title>
	<atom:link href="http://dreamwagon.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dreamwagon.com/blog</link>
	<description>Web application development with flex, java and xml</description>
	<lastBuildDate>Wed, 06 Apr 2011 10:56:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ava the firefly on facebook- Level submission how-to</title>
		<link>http://dreamwagon.com/blog/?p=65</link>
		<comments>http://dreamwagon.com/blog/?p=65#comments</comments>
		<pubDate>Wed, 06 Apr 2011 02:14:36 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=65</guid>
		<description><![CDATA[If you would like to contribute a map for ava the firefly on facebook, please check out the map description file at:
http://dreamwagongames.net/webgames/avaMaps.xml
An example of the XML to submit



&#60;avaMap&#62;



&#60;name&#62;My awesome map&#60;/name&#62;



&#60;author&#62;my name&#60;/author&#62;



&#60;website&#62;my website&#60;/website&#62;



&#60;mapImage&#62;someImageIHaveRightsToUse.png&#60;/mapImage&#62;



&#60;mapMusicPath&#62;SomeMusicIHaveRightsToUse.mp3&#60;/mapMusicPath&#62;



&#60;mapMusicBy&#62;Music Artist Name&#60;/mapMusicBy&#62;



&#60;mapMusicWebsite&#62;Music Artist website&#60;/mapMusicWebsite&#62;



&#60;mapSongName&#62;some cool song&#60;/mapSongName&#62;



&#60;startingPoint&#62;



 &#60;x&#62;-500&#60;/x&#62;



 &#60;y&#62;-200&#60;/y&#62;



&#60;/startingPoint&#62;



&#60;lightSourceRect&#62;



&#60;x&#62;642&#60;/x&#62;



&#60;y&#62;507&#60;/y&#62;



&#60;height&#62;100&#60;/height&#62;



&#60;width&#62;100&#60;/width&#62;



&#60;/lightSourceRect&#62;



&#60;droneCountAtStart&#62;15&#60;/droneCountAtStart&#62;



&#60;droneLvlIncrement&#62;2&#60;/droneLvlIncrement&#62;



&#60;batCountAtStart&#62;4&#60;/batCountAtStart&#62;



&#60;batLvlIncrement&#62;2&#60;/batLvlIncrement&#62;



&#60;/avaMap&#62;



When creating your own map, please fill out all relevant information and submit a map image, [...]]]></description>
			<content:encoded><![CDATA[<p>If you would like to contribute a map for ava the firefly on facebook, please check out the map description file at:</p>
<p>http://dreamwagongames.net/webgames/avaMaps.xml</p>
<p>An example of the XML to submit</p>
<table border="0">
<tbody>
<tr>
<td><span>&lt;avaMap&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;name&gt;My awesome map</span><span>&lt;/name&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;author&gt;my name</span><span>&lt;/author&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;website&gt;</span>my website<span>&lt;/website&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;mapImage&gt;</span>someImageIHaveRightsToUse.png<span>&lt;/mapImage&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;mapMusicPath&gt;</span>SomeMusicIHaveRightsToUse.mp3<span>&lt;/mapMusicPath&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;mapMusicBy&gt;Music Artist Name</span><span>&lt;/mapMusicBy&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;mapMusicWebsite&gt;</span>Music Artist website<span>&lt;/mapMusicWebsite&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;mapSongName&gt;some cool song</span><span>&lt;/mapSongName&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;startingPoint&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span> &lt;x&gt;</span>-500<span>&lt;/x&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span> &lt;y&gt;</span>-200<span>&lt;/y&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;/startingPoint&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;lightSourceRect&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;x&gt;</span>642<span>&lt;/x&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;y&gt;</span>507<span>&lt;/y&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;height&gt;</span>100<span>&lt;/height&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;width&gt;</span>100<span>&lt;/width&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;/lightSourceRect&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;droneCountAtStart&gt;</span>15<span>&lt;/droneCountAtStart&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;droneLvlIncrement&gt;</span>2<span>&lt;/droneLvlIncrement&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;batCountAtStart&gt;</span>4<span>&lt;/batCountAtStart&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;batLvlIncrement&gt;</span>2<span>&lt;/batLvlIncrement&gt;</span></td>
</tr>
<tr>
<td></td>
<td><span>&lt;/avaMap&gt;</span></td>
</tr>
</tbody>
</table>
<p>When creating your own map, please fill out all relevant information and submit a map image, music, and the xml zipped to<br />
j at dreamwagon dot com</p>
<p>You must have the rights to use both the map image and the music submitted. The minimum image size for the map is 800 x 600 and the maximum size is 2400 x 2400. png, jpg, gif supported</p>
<p>Check out the game at http://apps.facebook.com/avathefirefly</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=65</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caching rotations as bitmapdata in flex AS3</title>
		<link>http://dreamwagon.com/blog/?p=56</link>
		<comments>http://dreamwagon.com/blog/?p=56#comments</comments>
		<pubDate>Tue, 15 Mar 2011 02:54:22 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=56</guid>
		<description><![CDATA[Well what would be better for PI day then a brief tutorial on caching rotation sprites in adobe flex. While porting &#8220;Ava the Firefly&#8221; to Flex, I have encountered a bit of a snag in how the Flex framework handles rotation. In XNA, it is as simple as passing a parameter to the draw method [...]]]></description>
			<content:encoded><![CDATA[<p>Well what would be better for PI day then a brief tutorial on caching rotation sprites in adobe flex. While porting &#8220;<a href="http://marketplace.xbox.com/en-US/Product/Ava-the-Firefly/66acd000-77fe-1000-9115-d8025855045f">Ava the Firefly</a>&#8221; to Flex, I have encountered a bit of a snag in how the Flex framework handles rotation. In XNA, it is as simple as passing a parameter to the draw method on the Spritebatch. In AS3/Flex&#8230; not so much. The issue..<a href="http://board.flashkit.com/board/showthread.php?t=760991"> discussed here</a>, is that performing a matrix operation to rotate a bitmapdata object once per frame will drastically impact performance in a negative way as the number of rendered sprites increases. The consensus appears to be to use a cache for the rotation information.</p>
<p>Here is how I handled the problem.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">		<span style="color: #0600FF;">static</span> <span style="color: #0600FF;">public</span> function rotate<span style="color: #000000;">&#40;</span>image<span style="color: #008000;">:</span>DisplayObject, degrees<span style="color: #008000;">:</span>Number <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>, colorTransform<span style="color: #008000;">:</span>ColorTransform <span style="color: #008000;">=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">:</span>BitmapData
		<span style="color: #000000;">&#123;</span>
			var matrix<span style="color: #008000;">:</span>Matrix <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Matrix<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			     matrix.<span style="color: #0000FF;">translate</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">-</span>image.<span style="color: #0000FF;">width</span><span style="color: #008000;">/</span><span style="color: #FF0000;">2</span>,<span style="color: #008000;">-</span>image.<span style="color: #0000FF;">height</span><span style="color: #008000;">/</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>
			     matrix.<span style="color: #0000FF;">rotate</span><span style="color: #000000;">&#40;</span>degrees <span style="color: #008000;">*</span> degreeToRadians<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			     matrix.<span style="color: #0000FF;">translate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>image.<span style="color: #0000FF;">width</span><span style="color: #008000;">/</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span>,<span style="color: #000000;">&#40;</span>image.<span style="color: #0000FF;">height</span><span style="color: #008000;">/</span><span style="color: #FF0000;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
&nbsp;
			var bitmap<span style="color: #008000;">:</span>BitmapData <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> BitmapData<span style="color: #000000;">&#40;</span>image.<span style="color: #0000FF;">width</span>, image.<span style="color: #0000FF;">height</span>, <span style="color: #0600FF;">true</span>, 0x000000<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			bitmap.<span style="color: #0000FF;">draw</span><span style="color: #000000;">&#40;</span>image, matrix, colorTransform, BlendMode.<span style="color: #0000FF;">LAYER</span>, <span style="color: #0600FF;">null</span>, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
			<span style="color: #0600FF;">return</span> bitmap<span style="color: #008000;">;</span>
		<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This will take an image an rotate it, returning the bitmapdata.<br />
In my case, I create an array of images from a sprite sheet and build a cache of all the possible rotations of each frame in the animation.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">		<span style="color: #008080; font-style: italic;">// Create a multidimensional array for the given index</span>
		<span style="color: #008080; font-style: italic;">// ie. increment of 10 will cache all rotations in 10 degree increments (36 bitmaps)</span>
		<span style="color: #0600FF;">static</span> <span style="color: #0600FF;">public</span> function buildRotationCache<span style="color: #000000;">&#40;</span>image<span style="color: #008000;">:</span>DisplayObject,
                                                                       imageArray<span style="color: #008000;">:</span>Array,
                                                                       frameIndex<span style="color: #008000;">:</span>Number,
								       increment<span style="color: #008000;">:</span>Number,
								       colorTransform<span style="color: #008000;">:</span>ColorTransform <span style="color: #008000;">=</span> <span style="color: #0600FF;">null</span> <span style="color: #000000;">&#41;</span><span style="color: #008000;">:</span><span style="color: #0600FF;">void</span>
		<span style="color: #000000;">&#123;</span>
			var rotationIndex<span style="color: #008000;">:</span>Number <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
			<span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span>var k<span style="color: #008000;">:</span>Number <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> k <span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span> <span style="color: #FF0000;">360</span><span style="color: #008000;">;</span> k<span style="color: #008000;">+=</span> increment <span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				var bm<span style="color: #008000;">:</span>Bitmap <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Bitmap<span style="color: #000000;">&#40;</span>GraphicsUtil.<span style="color: #0000FF;">rotate</span><span style="color: #000000;">&#40;</span>image , k, colorTransform<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
				var gr<span style="color: #008000;">:</span>GraphicsResource <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> GraphicsResource<span style="color: #000000;">&#40;</span>bm<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
				imageArray<span style="color: #000000;">&#91;</span>frameIndex<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span>rotationIndex<span style="color: #000000;">&#93;</span> <span style="color: #008000;">=</span> gr<span style="color: #008000;">;</span>
				rotationIndex<span style="color: #008000;">++;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span></pre></div></div>

<p>the graphics resource class is from a tutorial found <a href="http://www.brighthub.com/internet/web-development/articles/11010.aspx">here</a></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">package
<span style="color: #000000;">&#123;</span>
	import flash.<span style="color: #0000FF;">display</span>.<span style="color: #008000;">*;</span>
	import flash.<span style="color: #0000FF;">geom</span>.<span style="color: #0000FF;">ColorTransform</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> GraphicsResource
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0600FF;">public</span> var bitmap<span style="color: #008000;">:</span>BitmapData <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
		<span style="color: #0600FF;">public</span> var bitmapAlpha<span style="color: #008000;">:</span>BitmapData <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #0600FF;">public</span> function GraphicsResource<span style="color: #000000;">&#40;</span>image<span style="color: #008000;">:</span>DisplayObject<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			bitmap <span style="color: #008000;">=</span> createBitmapData<span style="color: #000000;">&#40;</span>image<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			bitmapAlpha <span style="color: #008000;">=</span> createAlphaBitmapData<span style="color: #000000;">&#40;</span>image<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0600FF;">protected</span> function createBitmapData<span style="color: #000000;">&#40;</span>image<span style="color: #008000;">:</span>DisplayObject, colorTransform<span style="color: #008000;">:</span>ColorTransform <span style="color: #008000;">=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">:</span>BitmapData
		<span style="color: #000000;">&#123;</span>
			var bitmap<span style="color: #008000;">:</span>BitmapData <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> BitmapData<span style="color: #000000;">&#40;</span>image.<span style="color: #0000FF;">width</span>, image.<span style="color: #0000FF;">height</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			bitmap.<span style="color: #0000FF;">draw</span><span style="color: #000000;">&#40;</span>image, <span style="color: #0600FF;">null</span>, colorTransform<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #0600FF;">return</span> bitmap<span style="color: #008000;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0600FF;">protected</span> function createAlphaBitmapData<span style="color: #000000;">&#40;</span>image<span style="color: #008000;">:</span>DisplayObject<span style="color: #000000;">&#41;</span><span style="color: #008000;">:</span>BitmapData
		<span style="color: #000000;">&#123;</span>
			var bitmap<span style="color: #008000;">:</span>BitmapData <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> BitmapData<span style="color: #000000;">&#40;</span>image.<span style="color: #0000FF;">width</span>, image.<span style="color: #0000FF;">height</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			bitmap.<span style="color: #0000FF;">draw</span><span style="color: #000000;">&#40;</span>image, <span style="color: #0600FF;">null</span>, <span style="color: #0600FF;">null</span>, flash.<span style="color: #0000FF;">display</span>.<span style="color: #0000FF;">BlendMode</span>.<span style="color: #0000FF;">ALPHA</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #0600FF;">return</span> bitmap<span style="color: #008000;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>All for now. Happy coding..</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=56</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I will never buy an Adobe product ever again!</title>
		<link>http://dreamwagon.com/blog/?p=54</link>
		<comments>http://dreamwagon.com/blog/?p=54#comments</comments>
		<pubDate>Thu, 03 Jun 2010 02:47:57 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[consumer alerts]]></category>
		<category><![CDATA[indie game development]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=54</guid>
		<description><![CDATA[About a year and a half ago I bought Adobe Photoshop CS3 Design Premium. Being a web developer and game developer have relied on these products heavily. I started Photoshop about a week ago and I get:  &#8221;Licensing for this product has stopped working&#8221; and the program closes
Three days later, after running their Licensing removal [...]]]></description>
			<content:encoded><![CDATA[<p>About a year and a half ago I bought Adobe Photoshop CS3 Design Premium. Being a web developer and game developer have relied on these products heavily. I started Photoshop about a week ago and I get:  &#8221;Licensing for this product has stopped working&#8221; and the program closes</p>
<p>Three days later, after running their Licensing removal tool at all levels, and following other exceptionally silly tasks found <a href="http://kb2.adobe.com/cps/401/kb401528.html">here</a>, running the cs3 clean script and then totally reinstalling the junkware I am still having the same issue. I called customer support, but just did not have 45min to 1Hour of time to wait.</p>
<p>I have seen several threads online regarding this issue, some people report success, some are still not able to use their software. I wish I could report that I am one of those lucky enough to get it working again, but I am not. How sad is it that since there is not much competition in this space we tolerate this from adobe? This is not just poor software design, it is bad business! I paid full price for this software, and it should work when I run it damn it!</p>
<p>All I can say is be very wary if you are considering purchasing Adobe products.</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=54</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XNA Tutorial: HLSL and SpriteBatch for 2D effects.</title>
		<link>http://dreamwagon.com/blog/?p=48</link>
		<comments>http://dreamwagon.com/blog/?p=48#comments</comments>
		<pubDate>Thu, 07 Jan 2010 15:20:14 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[CSharp]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[indie game development]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=48</guid>
		<description><![CDATA[After writing most of my first XNA game using the built in sorting capability of SpriteBatch, I ran into a pretty big problem. I wanted to add a HLSL effect to certain sprites. I followed the instructions I found, setting the SpriteSortMode to Immediate. What I did not realize at the time is Immediate means [...]]]></description>
			<content:encoded><![CDATA[<p>After writing most of my first XNA game using the built in sorting capability of SpriteBatch, I ran into a pretty big problem. I wanted to add a HLSL effect to certain sprites. I followed the instructions I found, setting the SpriteSortMode to Immediate. What I did not realize at the time is Immediate means IMMEDIATE.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">spriteBatch.<span style="color: #0000FF;">Begin</span><span style="color: #000000;">&#40;</span>SpriteBlendMode.<span style="color: #0000FF;">AlphaBlend</span>, SpriteSortMode.<span style="color: #0000FF;">Immediate</span>, SaveStateMode.<span style="color: #0000FF;">None</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>This means that you cannot rely on the spriteBatch.Draw method to sort for you, and must sort yourself.</p>
<p>I posted in the XNA forums, and learned that it is actually better to sort yourself. This way you know exactly how everything is working behind the scenes, and you can really improve upon the look by implementing same neat HLSL effects. Rewriting my draw functionality was not a huge undertaking but it did take some time.</p>
<p>For my purposes, I decided to create an object for handling everything needed to draw later on.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"> <span style="color: #FF0000;">class</span> DrawableObject
    <span style="color: #000000;">&#123;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> Texture2D Texture<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> Vector2 Position<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> Vector2 Origin<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> Color Color<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">float</span> Rotation<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">float</span> Scale<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">float</span> Z_Index<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> Rectangle DisplayRect<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> DrawType DrawType<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> Effect Effect<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">Object</span> ObjectRef<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> DrawableObject<span style="color: #000000;">&#40;</span>Texture2D texture, Vector2 position,Rectangle displayRect, Color color, <span style="color: #FF0000;">float</span> rotation, Vector2 origin, <span style="color: #FF0000;">float</span> scale, <span style="color: #FF0000;">float</span> z_Index, DrawType drawType, Effect effect, <span style="color: #FF0000;">Object</span> objectRef<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Texture</span> <span style="color: #008000;">=</span> texture<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Position</span> <span style="color: #008000;">=</span> position<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Origin</span> <span style="color: #008000;">=</span> origin<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Color</span> <span style="color: #008000;">=</span> color<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Rotation</span> <span style="color: #008000;">=</span> rotation<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Z_Index</span> <span style="color: #008000;">=</span> z_Index<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Scale</span> <span style="color: #008000;">=</span> scale<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">DisplayRect</span> <span style="color: #008000;">=</span> displayRect<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">DrawType</span> <span style="color: #008000;">=</span> drawType<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Effect</span> <span style="color: #008000;">=</span> effect<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">ObjectRef</span> <span style="color: #008000;">=</span> objectRef<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

<p>In this Object, DrawType is an enumeration used to mark each object so drawing can be handled differently depending on its type. For my purposes I had Player, Projectile, Shadow, etc<br />
I then create a list of DrawableObjects to sort based on the z index.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">List listToDraw <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> x <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> x <span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span> playerManager.<span style="color: #0000FF;">Players</span>.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> x<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">//Add all my players as drawable objects</span>
                    listToDraw.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">new</span> DrawableObject<span style="color: #000000;">&#40;</span>playerManager.<span style="color: #0000FF;">Players</span><span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">PlayerAnimation</span>.<span style="color: #0000FF;">CurrentTexture</span>, playerManager.<span style="color: #0000FF;">Players</span><span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">PlayerAnimation</span>.<span style="color: #0000FF;">ScreenPosition</span> ,                   playerManager.<span style="color: #0000FF;">Players</span><span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">PlayerAnimation</span>.<span style="color: #0000FF;">DisplayRect</span>, Color.<span style="color: #0000FF;">White</span>, 0f, Vector2.<span style="color: #0000FF;">Zero</span>, 1f, playerManager.<span style="color: #0000FF;">Players</span><span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">PlayerAnimation</span>.<span style="color: #0000FF;">ScreenPosition</span>.<span style="color: #0000FF;">Y</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">/</span> Map.<span style="color: #0000FF;">Height</span>, DrawType.<span style="color: #0000FF;">Player</span>, playerManager.<span style="color: #0000FF;">Players</span><span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">PlayerAnimation</span>.<span style="color: #0000FF;">PlayerEffect</span>,  playerManager.<span style="color: #0000FF;">Players</span><span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
              <span style="color: #000000;">&#125;</span></pre></div></div>

<p>I then sort &#8230;.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">           <span style="color: #008080; font-style: italic;">//Sort for the right order</span>
            listToDraw.<span style="color: #0000FF;">Sort</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">delegate</span> <span style="color: #000000;">&#40;</span>DrawableObject d1, DrawableObject d2<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #0600FF;">return</span> d2.<span style="color: #0000FF;">Z_Index</span>.<span style="color: #0000FF;">CompareTo</span><span style="color: #000000;">&#40;</span>d1.<span style="color: #0000FF;">Z_Index</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>and then draw the list</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"> <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> x <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> x <span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span> DrawObjectList.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> x<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">DrawType</span> <span style="color: #008000;">==</span> DrawType.<span style="color: #0000FF;">Player</span><span style="color: #000000;">&#41;</span>
                    <span style="color: #000000;">&#123;</span>
                        Player pn <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>Player<span style="color: #000000;">&#41;</span>DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ObjectRef</span><span style="color: #008000;">;</span>
&nbsp;
                        spriteBatch.<span style="color: #0000FF;">Begin</span><span style="color: #000000;">&#40;</span>SpriteBlendMode.<span style="color: #0000FF;">AlphaBlend</span>, SpriteSortMode.<span style="color: #0000FF;">Immediate</span>, SaveStateMode.<span style="color: #0000FF;">None</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Effect</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #000000;">&#41;</span>
                        <span style="color: #000000;">&#123;</span>
                            DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Effect</span>.<span style="color: #0000FF;">Begin</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                            DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Effect</span>.<span style="color: #0000FF;">CurrentTechnique</span>.<span style="color: #0000FF;">Passes</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Begin</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                        <span style="color: #000000;">&#125;</span>
                        spriteBatch.<span style="color: #0000FF;">Draw</span><span style="color: #000000;">&#40;</span>DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Texture</span>, DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Position</span>, DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">DisplayRect</span>, DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Color</span>,
                                         DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Rotation</span>, DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Origin</span>, DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Scale</span>, SpriteEffects.<span style="color: #0000FF;">None</span>, DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Z_Index</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Effect</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                        <span style="color: #000000;">&#123;</span>
                            DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Effect</span>.<span style="color: #0000FF;">CurrentTechnique</span>.<span style="color: #0000FF;">Passes</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">End</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                            DrawObjectList<span style="color: #000000;">&#91;</span>x<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Effect</span>.<span style="color: #0000FF;">End</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                        <span style="color: #000000;">&#125;</span>
&nbsp;
                        <span style="color: #008080; font-style: italic;">//etc etc.</span>
                 <span style="color: #000000;">&#125;</span></pre></div></div>

<p>Well I hope this helps someone looking for the same thing.</p>
<p>~J</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=48</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Will Philly make me cry again this week</title>
		<link>http://dreamwagon.com/blog/?p=46</link>
		<comments>http://dreamwagon.com/blog/?p=46#comments</comments>
		<pubDate>Thu, 07 Jan 2010 03:12:48 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[NFL]]></category>
		<category><![CDATA[sports]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=46</guid>
		<description><![CDATA[Three days. Thats how long it took me to even talk about the romping that the Cowboys handed the Eagles this past Sunday. After the game, I told myself I was done with football until the Super Bowl, whether the Eagles get there or not. That would not be me being a good fan though, [...]]]></description>
			<content:encoded><![CDATA[<p>Three days. Thats how long it took me to even talk about the romping that the Cowboys handed the Eagles this past Sunday. After the game, I told myself I was done with football until the Super Bowl, whether the Eagles get there or not. That would not be me being a good fan though, and I now realize that I have to watch the rematch on Saturday night. It is a very intriguing game, since I do believe that these two teams are move evenly matched than last Sundays score indicated. I will sit tight and watch. The Eagles can&#8217;t do any worse on offense, since its impossible for the score to go negative. Good luck birds. You will need some.</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=46</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Photoshop takes a long time to open or create files</title>
		<link>http://dreamwagon.com/blog/?p=33</link>
		<comments>http://dreamwagon.com/blog/?p=33#comments</comments>
		<pubDate>Mon, 25 May 2009 15:21:59 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[graphics]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=33</guid>
		<description><![CDATA[For that last month or so I was experiencing a rather frustrating problem. Every time I opened or created a new file, photoshop would hang for a minute or more before opening the file. I tried all the regular optimization tricks, such as defragmenting my drives, changing the scratch space and doing a memory test, [...]]]></description>
			<content:encoded><![CDATA[<p>For that last month or so I was experiencing a rather frustrating problem. Every time I opened or created a new file, photoshop would hang for a minute or more before opening the file. I tried all the regular optimization tricks, such as defragmenting my drives, changing the scratch space and doing a memory test, but still no luck. I did search after search to try to find an answer and finally found this forum that contained the answer.</p>
<p><a href="http://photo.net/digital-darkroom-forum/00KCiu" target="_blank">http://photo.net/digital-darkroom-forum/00KCiu</a></p>
<p>It turns out this happens when your default printer is a network printer that may be either inaccessible or has other problems. I had recently purchased a new router which uses a different local IP and had not changed the network location. Since I rarely print from that machine on my network, I did not notice that the printer was inaccessible. I simply changed my default printer from the network printer to PDF and now photoshop works as it should (quite fast). Seems like a rather odd problem for a well built application like CS3. One would think that it would check for printer issues on launch, and then ignore the printer if none exists, or if it is reporting some issue that prevents it from being properly detected. I am just glad to be able to work at a normal speed again.</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=33</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Fight Monkey of Magic</title>
		<link>http://dreamwagon.com/blog/?p=31</link>
		<comments>http://dreamwagon.com/blog/?p=31#comments</comments>
		<pubDate>Wed, 20 May 2009 11:22:14 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=31</guid>
		<description><![CDATA[Dreamwagon games is proud to announce its first title Fight Monkey of Magic (FMM).
FMM is a hybrid role playing fighting game with real time strategie elements. Although an arcade fighting game at heart, Fight Monkey of Magic provides several different ways to win. Play through in arcade mode or team up with your friends. Up [...]]]></description>
			<content:encoded><![CDATA[<p>Dreamwagon games is proud to announce its first title <a href="http://www.dreamwagon.com/fightmonkeyofmagic" target="_self">Fight Monkey of Magic</a> (FMM).</p>
<p>FMM is a hybrid role playing fighting game with real time strategie elements. Although an arcade fighting game at heart, Fight Monkey of Magic provides several different ways to win. Play through in arcade mode or team up with your friends. Up to 4 players capability will keep everyone in the game.</p>
<p>We are shooting for a release to the XBox arcade and windows in the fall 2009.</p>
<p>Check out the game page for more info:  <a href="http://dreamwagon.com/fightmonkeyofmagic" target="_self">http://dreamwagon.com/fightmonkeyofmagic</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=31</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>David Stern must read my blog</title>
		<link>http://dreamwagon.com/blog/?p=24</link>
		<comments>http://dreamwagon.com/blog/?p=24#comments</comments>
		<pubDate>Tue, 10 Feb 2009 12:38:26 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[NBA]]></category>
		<category><![CDATA[random thoughts]]></category>
		<category><![CDATA[sports]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=24</guid>
		<description><![CDATA[Anyone who reads my journal knows that one in three of my entries is some sort of rant, usually regarding NBA officiating. I love the game of basketball. I love to play, love to watch and hopefully one day I will have the opportunity to coach on some level. My journal entries that pertain to [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who reads my journal knows that one in three of my entries is some sort of rant, usually regarding NBA officiating. I love the game of basketball. I love to play, love to watch and hopefully one day I will have the opportunity to coach on some level. My journal entries that pertain to basketball often contain criticism of the NBA and its officials. I understand that the speed and strength of atheletes at the NBA level makes officiating a real challenge, but it does not excuse the wide variance in the amount of contact required to draw a whistle. At the begining of the NBA season I was ready to suffer through another season of wild calls, flopping and overall inefficient refereeing. I must admit that I am somewhat stunned by the turn around from seasons past, at least in the games I have had the opportunity to watch. While there still are bad calls, and there always will be, the officials seem to have finally adopted the &#8216;let em play&#8217; philosophy.</p>
<p>Here is a great example</p>
<p><a href="http://www.nba.com/playerfile/derek_fisher/" target="_blank">Derek Fisher</a> playing great off the ball defense on <a href="http://www.nba.com/playerfile/ray_allen/index.html" target="_blank">Ray Allen</a> in the Lakers-Celtics game prevents Allen from getting set to attempt a game winning three point shot. The refs did not blow a whistle simply because Allen falls down (which I sure he would not have done if it were not an end of game situation)</p>
<p>I can recall countless times so far this season where players glare at the refs with that &#8216;gimme the call&#8217; look on their faces. Instead of watching Lebron and Kobe run layup drills on the opposition (Kobe&#8217;s night at the Garden not withstanding), we are seeing defense cause missed shots and turnovers. Now I am not saying that everything is perfect in the NBA now, but the acceptable contact level has risen dramatically from years past. The bottom line is,  &#8216;Basketball is a contact sport.&#8217; The level of contact is dictated by the level of competition. Its too easy for a guy 6-8, 260 (Sorry Lebron) to get to the hoop and score when a defender knows he gets a whistle if he plays tough D. The soft fouls in the NBA have made me crazy for many seasons past, but seem to be going the way of the 8-track this season.</p>
<p>I don&#8217;t know if <a href="http://www.nba.com/nba101/david_j_stern_bio.html" target="_blank">David Stern</a> reads my blog or not, but regardless of where the concept came from (me!) its obvious to me that NBA officials have made a huge leap forward in eliminating soft fouls. I think it has enhanced the integrity of NBA basketball exponentially.</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The most over hyped non-storm of all time</title>
		<link>http://dreamwagon.com/blog/?p=22</link>
		<comments>http://dreamwagon.com/blog/?p=22#comments</comments>
		<pubDate>Sat, 31 Jan 2009 14:23:47 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[Meteorology]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=22</guid>
		<description><![CDATA[If the Presidents day storm of 2003 is known as the Blizzard of &#8216;03, this coming Presidents day non-storm should be titled &#8220;The non-blizzard of 2009.&#8221; I am a huge weather junky. I love to follow the weather models and keep abreast of the changes in those models at each new run. That why when [...]]]></description>
			<content:encoded><![CDATA[<p>If the Presidents day storm of 2003 is known as the Blizzard of &#8216;03, this coming Presidents day non-storm should be titled &#8220;The non-blizzard of 2009.&#8221; I am a huge weather junky. I love to follow the weather models and keep abreast of the changes in those models at each new run. That why when this storm first appeared on the long range GFS I had to get excited. After the next few days though, the models started to jump all over the place with the path of the storm. Thats ok though right? At least we are assured that there will be a storm right?</p>
<p>Watching the weather channel, the hype was constant. Will it go along the coast, up the I-95 corridor of west of the Appalachians? Every scenerio was discussed along with the impact it would have. Even CNN had a weather map with &#8220;BLIZZARD&#8221; over the north east. The hype was totally insane. No one seemed to even consider the possibilty of the whole thing just going out to sea missing completely. If this does happen, and in my opinion it will, this storm should go down as the most overhyped storm in weather history.</p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=22</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cforms ii custom submit script</title>
		<link>http://dreamwagon.com/blog/?p=21</link>
		<comments>http://dreamwagon.com/blog/?p=21#comments</comments>
		<pubDate>Fri, 15 Aug 2008 13:32:26 +0000</pubDate>
		<dc:creator>Jesse</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[cforms ii]]></category>
		<category><![CDATA[cformsii]]></category>
		<category><![CDATA[custom form submission]]></category>

		<guid isPermaLink="false">http://dreamwagon.com/blog/?p=21</guid>
		<description><![CDATA[Cforms ii is one of the most powerful plugins available for wordpress. It enables quick form creation with several nice data tracking features. There is also the option to reroute the form submission to a custom script. This is a very nice feature that makes it easy to control what happens after form submission. Here [...]]]></description>
			<content:encoded><![CDATA[<p>Cforms ii is one of the most powerful plugins available for wordpress. It enables quick form creation with several nice data tracking features. There is also the option to reroute the form submission to a custom script. This is a very nice feature that makes it easy to control what happens after form submission. Here is a script I wrote that saves the data collected back to the wordpress database and emails the admin and form submitter.</p>
<p>Place this script somewhere in a folder under your Wordpress installation, and on the cforms admin page under Redirection, Messages, Text and Button Label  set the Enable alternative form action! checkbox and then provide the URL to the script. Once a form is submitted you will still be able to track the submission via the admin tool.</p>
<p><font color="#ff0000">&lt;?php</font><br />
<font color="#00ff00">//Make sure the user got here by way of form submission<br />
// replace sendbutton2 with the name of your forms send button.</font><br />
if (isset($_POST['sendbutton2'])) {<br />
<font color="#ff0000">?&gt;</font><br />
&lt;h3&gt;Thanks for your submission.&lt;/h3&gt;<br />
&lt;div&gt;Some other detailed html message if you like&#8230;&lt;/div&gt;</p>
<p><font color="#ff0000">&lt;?php</font></p>
<p>require(&#8221;wp-includes/class-phpmailer.php&#8221;);</p>
<p><font color="#00ff00">////////////////////////////////</font><br />
<font color="#00ff00"> // Notification Email Recipients</font><br />
$mailto = array();</p>
<p><font color="#00ff00">//These addresses are for notification when the form is submitted.</font><br />
$mailto[] = array(&#8221;address&#8221; =&gt; &#8220;someaddress1@somewhere.net&#8221;, &#8220;name&#8221; =&gt; &#8220;some person1&#8243;);<br />
$mailto[] = array(&#8221;address&#8221; =&gt; &#8220;someaddress2@somewhere.net&#8221;, &#8220;name&#8221; =&gt; &#8220;some person2&#8243;);<br />
$mailto[] = array(&#8221;address&#8221; =&gt; &#8220;someaddress3@somewhere.net&#8221;, &#8220;name&#8221; =&gt; &#8220;some person3&#8243;);</p>
<p>$mailfromaddress     = &#8216;from@address.net&#8217;;<br />
$mailfromname         = &#8216;from name&#8217;;</p>
<p>$mailnotificationsubject = &#8216;Notification Subject&#8217;;<br />
$mailconfirmationsubject = &#8216;Confirmation Subject&#8217;;<br />
<font color="#00ff00"> //////////////////////////////////////////////////////////////////</p>
<p>//Set the variables<br />
//These come directly from cforms. You can use firebug to so see the field names, or just use the<br />
//given form number. Example, the second field in form 2 will have ID cf2_field_2<br />
// Of course you should customize this to your specific form.</font><br />
$first = $_POST['cf2_field_2'];<br />
$last = $_POST['cf2_field_3'];<br />
$email = $_POST['cf2_field_4'];<br />
$address = $_POST['cf2_field_5'];<br />
$city = $_POST['cf2_field_6'];<br />
$state = $_POST['cf2_field_7'];<br />
$zip = $_POST['cf2_field_9'];<br />
<font color="#00ff00">//etc etc etc</font></p>
<p>$link = mysql_connect(&#8217;DB-name usually localhost&#8217;, &#8216;DB-user&#8217;, &#8216;DB-password&#8217;);<br />
if (!$link) {<br />
die(&#8217;Could not connect: &#8216; . mysql_error());<br />
}<br />
<font color="#00ff00">//Your wordpress schema name</font><br />
mysql_select_db(&#8221;DB-schema-name&#8221;, $link);</p>
<p>mysql_query(&#8221;INSERT INTO wp_cformssubmissions (form_id, sub_date, email, ip) VALUES (&#8217;$formID&#8217;, NOW(), &#8216;$email&#8217;, &#8216;$_SERVER[REMOTE_ADDR]&#8216;)&#8221;);</p>
<p>$id = mysql_insert_id();</p>
<p><font color="#00ff00">//Insert the information block.</font><br />
mysql_query(&#8221;INSERT INTO wp_cformsdata (sub_id, field_name, field_val) VALUES (&#8217;$id&#8217;, &#8216;First Name&#8217;, &#8216;$first&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO wp_cformsdata (sub_id, field_name, field_val) VALUES (&#8217;$id&#8217;, &#8216;Last Name&#8217;, &#8216;$last&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO wp_cformsdata (sub_id, field_name, field_val) VALUES (&#8217;$id&#8217;, &#8216;Email&#8217;, &#8216;$email&#8217;)&#8221;);</p>
<p>mysql_query(&#8221;INSERT INTO wp_cformsdata (sub_id, field_name, field_val) VALUES (&#8217;$id&#8217;, &#8216;Address&#8217;, &#8216;$address&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO wp_cformsdata (sub_id, field_name, field_val) VALUES (&#8217;$id&#8217;, &#8216;City&#8217;, &#8216;$city&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO wp_cformsdata (sub_id, field_name, field_val) VALUES (&#8217;$id&#8217;, &#8216;State&#8217;, &#8216;$state&#8217;)&#8221;);<br />
mysql_query(&#8221;INSERT INTO wp_cformsdata (sub_id, field_name, field_val) VALUES (&#8217;$id&#8217;, &#8216;Zip Code&#8217;, &#8216;$zip&#8217;)&#8221;);</p>
<p>mysql_close($link);</p>
<p><font color="#00ff00">//Mail to all persons who should be notified.</font><br />
$mail = new PHPMailer();</p>
<p>foreach($mailto as $to) {<br />
$mail-&gt;AddAddress($to["address"], $to["name"]);<br />
}</p>
<p>$mail-&gt;IsSMTP();  // telling the class to use SMTP<br />
$mail-&gt;Host = &#8220;smtp.someserver.net&#8221;; // Your SMTP server  here</p>
<p>$mail-&gt;From = $mailfromaddress;<br />
$mail-&gt;FromName = $mailfromname;</p>
<p>$mail-&gt;Subject = $mailnotificationsubject;<br />
$mail-&gt;Body = &lt;&lt;&lt;EOT<br />
Hello Admin,&lt;br/&gt;&lt;br/&gt;A new form submission has been completed &#8230;. &lt;br/&gt;&lt;br/&gt;<br />
&lt;b&gt;Details:&lt;/b&gt;&lt;br/&gt;<br />
$first $last &lt;br/&gt;<br />
$email &lt;br/&gt;<br />
Login to http://yourwordpressinstance.org to review further registration information.<br />
EOT;</p>
<p>$mail-&gt;AltBody = &#8220;&lt;&lt;&lt;EOT<br />
Hello Admin,<br />
A new form submission has been completed &#8230;.<br />
Details<br />
$first $last<br />
$email<br />
$orderNum<br />
Login to http://yourwordpressinstance.org to review further registration information.<br />
EOT;&#8221;;<br />
$mail-&gt;Send();</p>
<p><font color="#00ff00"><br />
//Mail to form submitter</font><br />
$mail = new PHPMailer();<br />
$mail-&gt;AddAddress($email, $first.&#8217; &#8216;.$last);<br />
$mail-&gt;IsSMTP();  // telling the class to use SMTP<br />
$mail-&gt;Host = &#8220;smtp.someserver.net&#8221;; // Your SMTP server  here</p>
<p>$mail-&gt;From = $mailfromaddress;<br />
$mail-&gt;FromName = $mailfromname;<br />
$mail-&gt;Subject = $mailconfirmationsubject;<br />
$mail-&gt;Body = &lt;&lt;&lt;EOT<br />
Hello $first,&lt;br/&gt;&lt;br/&gt;Message to submitter&lt;br/&gt;&lt;br/&gt;<br />
&lt;b&gt;Details:&lt;/b&gt;&lt;br/&gt;<br />
$first $last &lt;br/&gt;<br />
$email &lt;br/&gt;<br />
EOT;</p>
<p>$mail-&gt;AltBody = &lt;&lt;&lt;EOT<br />
Hello $first,<br />
Message to submitter<br />
Details:<br />
$first $last<br />
$email<br />
EOT;</p>
<p>$mail-&gt;Send();</p>
<p>}<font color="#00ff00"><br />
//Did not get here via form post,  output an error.</font><br />
else<br />
echo &#8220;PAGE ERROR: You have tried to access this page from invalid context&#8230;&#8221;;<br />
<font color="#ff0000">?&gt;</font></p>
]]></content:encoded>
			<wfw:commentRss>http://dreamwagon.com/blog/?feed=rss2&amp;p=21</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

