<?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>Daniel Soltyka &#124; Game Programmer</title>
	<atom:link href="http://www.danielsoltyka.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danielsoltyka.com</link>
	<description>Video Game Programmer Portfolio and Blog</description>
	<lastBuildDate>Sun, 30 May 2010 16:21:57 +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>C++ Vector2D &amp; Rectangle classes</title>
		<link>http://www.danielsoltyka.com/index.php/2010/05/30/c-vector2d-rectangle-classes/</link>
		<comments>http://www.danielsoltyka.com/index.php/2010/05/30/c-vector2d-rectangle-classes/#comments</comments>
		<pubDate>Sun, 30 May 2010 15:49:28 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[VC++]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=733</guid>
		<description><![CDATA[I&#8217;n my current C++ class we&#8217;ve been playing with the Allegro C++ library to create some 2D games.  While Allegro is a fairly powerful library, it&#8217;s shortcomings made me miss the Microsoft XNA Framework quite a bit.  I suppose I cannot fault Allegro in this regard, but I have grown so accustomed to using Microsoft&#8217;s implementation of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;n my current C++ class we&#8217;ve been playing with the <a href="http://www.talula.demon.co.uk/allegro/" target="_blank">Allegro</a> C++ library to create some 2D games.  While Allegro is a fairly powerful library, it&#8217;s shortcomings made me miss the Microsoft XNA Framework quite a bit.  I suppose I cannot fault Allegro in this regard, but I have grown so accustomed to using Microsoft&#8217;s implementation of 2D vectors and rectangles that learning new variants seems convoluted.</p>
<p>Now, before anyone judges me for not wanting to learn a new API, consider this.  Allegro has a plethora of 2D methods, but the only vector methods I am able to find are 3D.  Fine you say, just zero the Z element and be done with it.</p>
<p>Well sure.  But would I rather use a non OOP implementation like this:</p>
<pre class="brush: cpp;">
float x = &lt;someXValue&gt;;
float y = &lt;someYValue&gt;;
float z = 0.0f;
void normalize_vector_f(float *x, float *y, float *z);
</pre>
<p>Or would I rather take an OOP approach:</p>
<pre class="brush: cpp;">
Vector2D vec( &lt;someXValue&gt;, &lt;someYValue&gt; );
vec.Normalize();
</pre>
<p>Call me crazy, but I prefer the later.  As such, I&#8217;m going to go ahead and post my Vector2D class here, as well as the Rectangle class I am using.  Normally I would cite sources I used for help in writing these classes.   However, in the case of the Vector2D class most of the methods used are fairly standard and there is nothing really out of the ordinary.</p>
<p>As for the Rectangle class, there are some cool static methods I added that Microsoft released in their RectangleExtensions class (released under the MSPL).  I ported these methods over from C# to C++,and they seem to work correctly, however I haven&#8217;t tested them thoroughly and they <strong>may</strong> have a bug or two.</p>
<p>Anyway, enough ranting.  Here&#8217;s the code.</p>
<p>Vector2D.h</p>
<pre class="brush: cpp;">
#ifndef _VECTOR2D_H
#define _VECTOR2D_H
#pragma once

#include &lt;math.h&gt;

class Vector2D
{

public:
	Vector2D(float x = 0, float y = 0);
	~Vector2D() {};

	void Rotate( const float angle );
	float Magnitude() const;
	float Normalize();
	float DotProduct( const Vector2D&amp; v2 ) const;
	float CrossProduct( const Vector2D&amp; v2 ) const;

	static Vector2D Zero();
	static float Distance( const Vector2D&amp; v1, const Vector2D&amp; v2);

	Vector2D&amp; operator= ( const Vector2D&amp; v2 );

	Vector2D&amp; operator+= ( const Vector2D&amp; v2 );
	Vector2D&amp; operator-= ( const Vector2D&amp; v2 );
	Vector2D&amp; operator*= ( const float scalar);
	Vector2D&amp; operator/= ( const float scalar);

	const Vector2D operator+( const Vector2D &amp;v2 ) const;
	const Vector2D operator-( const Vector2D &amp;v2 ) const;
	const Vector2D operator*( const float scalar ) const;
	const Vector2D operator/( const float scalar ) const;

	bool operator== ( const Vector2D&amp; v2 ) const;
	bool operator!= ( const Vector2D&amp; v2 ) const;

public:
	float x, y;
};
#endif
</pre>
<p>Vector2D.cpp</p>
<pre class="brush: cpp;">
#include &quot;Vector2D.h&quot;

//-----------------------------------------------------------------------------
// Purpose:	Constructor
//-----------------------------------------------------------------------------
Vector2D::Vector2D( float x, float y )
{
	this-&gt;x = x;
	this-&gt;y = y;
}

//-----------------------------------------------------------------------------
// Purpose:	Rotate a vector
//-----------------------------------------------------------------------------
void Vector2D::Rotate( const float angle )
{
	float xt = (x * cosf(angle)) - (y * sinf(angle));
	float yt = (y * cosf(angle)) + (x * sinf(angle));
	x = xt;
	y = yt;
}

//-----------------------------------------------------------------------------
// Purpose:	Get vector magnitude
//-----------------------------------------------------------------------------
float Vector2D::Magnitude() const
{
	return sqrtf(x * x + y * y);
}

//-----------------------------------------------------------------------------
// Purpose:	Convert vector to a unit vector and return previous magnitude
//-----------------------------------------------------------------------------
float Vector2D::Normalize()
{
	float mag = Magnitude();

	if(mag != 0.0)
	{
		x /= mag;
		y /= mag;
	}

	return mag;
}

//-----------------------------------------------------------------------------
// Purpose:	Dot Product
//-----------------------------------------------------------------------------
float Vector2D::DotProduct( const Vector2D &amp;v2 ) const
{
	return (x * v2.x) + (y * v2.y);
}

//-----------------------------------------------------------------------------
// Purpose:	Cross Product
//-----------------------------------------------------------------------------
float Vector2D::CrossProduct( const Vector2D &amp;v2 ) const
{
	return (x * v2.y) - (y * v2.x);
}

//-----------------------------------------------------------------------------
// Purpose:	Return an empty vector
//-----------------------------------------------------------------------------
Vector2D Vector2D::Zero()
{
	return Vector2D(0, 0);
}

//-----------------------------------------------------------------------------
// Purpose:	Get distance between two vectors
//-----------------------------------------------------------------------------
float Vector2D::Distance( const Vector2D&amp; v1, const Vector2D&amp; v2)
{
	return sqrtf( pow((v2.x - v1.x), 2 ) + pow((v2.y - v1.y), 2) );
}

Vector2D&amp; Vector2D::operator= ( const Vector2D&amp; v2 )
{
	if (this == &amp;v2)
		return *this;

	x = v2.x;
	y = v2.y;

	return *this;
}

Vector2D&amp; Vector2D::operator+= ( const Vector2D&amp; v2 )
{
	x += v2.x;
	y += v2.y;

	return *this;
}

Vector2D&amp; Vector2D::operator-= ( const Vector2D&amp; v2 )
{
	x -= v2.x;
	y -= v2.y;

	return *this;
}

Vector2D&amp; Vector2D::operator*= ( const float scalar )
{
	x *= scalar;
	y *= scalar;

	return *this;
}

Vector2D&amp; Vector2D::operator/= ( const float scalar )
{
	x /= scalar;
	y /= scalar;

	return *this;
}

const Vector2D Vector2D::operator+( const Vector2D &amp;v2 ) const
{
	return Vector2D(*this) += v2;
}

const Vector2D Vector2D::operator-( const Vector2D &amp;v2 ) const
{
	return Vector2D(*this) -= v2;
}

const Vector2D Vector2D::operator*( const float scalar ) const
{
	return Vector2D(*this) *= scalar;
}

const Vector2D Vector2D::operator/( const float scalar ) const
{
	return Vector2D(*this) /= scalar;
}

bool Vector2D::operator== ( const Vector2D&amp; v2 ) const
{
	return ((x == v2.x) &amp;&amp; (y == v2.y));
}

bool Vector2D::operator!= ( const Vector2D&amp; v2 ) const
{
	return !((x == v2.x) &amp;&amp; (y == v2.y));
}
</pre>
<p>Rectangle.h</p>
<pre class="brush: cpp;">
#ifndef _RECTANGLE_H
#define _RECTANGLE_H
#pragma once

#include &quot;Vector2D.h&quot;

class Rectangle
{
public:
	Rectangle( int x = 0, int y = 0, int w = 0, int h = 0 );
	~Rectangle( void ) {};

	inline int Left( void ) const { return x; }
	inline int Right( void ) const { return x + w; }
	inline int Top( void ) const { return y; }
	inline int Bottom( void ) const { return y + h; }

	bool Contains( Vector2D&amp; vVec ) const;
	bool Contains( int x, int y ) const;

	static Rectangle Empty();

	// Static methods below are derived from the RectangleExtensions class
	// written in C#, released under the MSPL
	static Vector2D GetIntersectionDepth( const Rectangle&amp; rectA, const Rectangle&amp; rectB );
	static Vector2D GetBottomCenter( const Rectangle&amp; rect );
	static Vector2D GetCenter( const Rectangle&amp; rect );
	static float GetDistance( const Rectangle&amp; rectA, const Rectangle&amp; rectB);
	static Vector2D GetDirection( const Rectangle&amp; rectA, const Rectangle&amp; rectB);

	Rectangle&amp; operator= ( const Rectangle&amp; r2 );

	bool operator== ( const Rectangle&amp; r2 ) const;
	bool operator!= ( const Rectangle&amp; r2 ) const;

public:
	int x, y, w, h;
};

#endif
</pre>
<p>Rectangle.cpp</p>
<pre class="brush: cpp;">
#include &quot;Rectangle.h&quot;
#include &lt;stdlib.h&gt;

//-----------------------------------------------------------------------------
// Purpose:	Constructor
//-----------------------------------------------------------------------------
Rectangle::Rectangle( int x, int y, int w, int h )
{
	this-&gt;x = x;
	this-&gt;y = y;
	this-&gt;w = w;
	this-&gt;h = h;
}

//-----------------------------------------------------------------------------
// Purpose:	Check if rectangle contains a 2D vector
//-----------------------------------------------------------------------------
bool Rectangle::Contains( Vector2D&amp; vVec ) const
{
	if ( ( vVec.x &gt;= x )&amp;&amp;
		 ( vVec.x &lt;= x + w ) &amp;&amp;
		 ( vVec.y &gt;= y ) &amp;&amp;
		 ( vVec.x &lt;= y + h ) )
	{
		return true;
	}
	else
		return false;
}

//-----------------------------------------------------------------------------
// Purpose:	Check if rectangle contains a set of coords
//-----------------------------------------------------------------------------
bool Rectangle::Contains( int x, int y ) const
{
	if ( ( x &gt;= this-&gt;x )&amp;&amp;
		( x &lt;= this-&gt;x + this-&gt;w ) &amp;&amp;
		( y &gt;= this-&gt;y ) &amp;&amp;
		( x &lt;= this-&gt;y + this-&gt;h ) )
	{
		return true;
	}
	else
		return false;
}

//-----------------------------------------------------------------------------
// Purpose:	Return an empty rectangle
//-----------------------------------------------------------------------------
Rectangle Rectangle::Empty()
{
	return Rectangle();
}

//-----------------------------------------------------------------------------
// Purpose:	Get intersection depth between two rectangles
//-----------------------------------------------------------------------------
Vector2D Rectangle::GetIntersectionDepth( const Rectangle&amp; rectA, const Rectangle&amp; rectB )
{
	// Calculate half sizes.
	float halfWidthA = rectA.w / 2.0f;
	float halfHeightA = rectA.h / 2.0f;
	float halfWidthB = rectB.w / 2.0f;
	float halfHeightB = rectB.h / 2.0f;

	// Calculate centers.
	Vector2D centerA(rectA.x + halfWidthA, rectA.y + halfHeightA);
	Vector2D centerB(rectB.x + halfWidthB, rectB.y + halfHeightB);

	// Calculate current and minimum-non-intersecting distances between centers.
	float distanceX = centerA.x - centerB.x;
	float distanceY = centerA.y - centerB.y;
	float minDistanceX = halfWidthA + halfWidthB;
	float minDistanceY = halfHeightA + halfHeightB;

	// If we are not intersecting at all, return (0, 0).
	if ( abs(distanceX) &gt;= minDistanceX || abs(distanceY) &gt;= minDistanceY )
		return Vector2D::Zero();

	// Calculate and return intersection depths.
	float depthX = distanceX &gt; 0 ? minDistanceX - distanceX : -minDistanceX - distanceX;
	float depthY = distanceY &gt; 0 ? minDistanceY - distanceY : -minDistanceY - distanceY;
	return Vector2D(depthX, depthY);
}

//-----------------------------------------------------------------------------
// Purpose:	Gets the position of the center of the bottom edge of the rectangle.
//-----------------------------------------------------------------------------
Vector2D Rectangle::GetBottomCenter(const Rectangle&amp; rect)
{
	return Vector2D( (float)(rect.x + rect.w / 2.0f), (float)(rect.y + rect.h) );
}

//-----------------------------------------------------------------------------
// Purpose:	Gets the position of the center point of a rectangle
//-----------------------------------------------------------------------------
Vector2D Rectangle::GetCenter(const Rectangle&amp; rect)
{
	return Vector2D( (float)(rect.x + rect.w / 2.0f), (float)(rect.y + rect.h / 2.0f) );
}

//-----------------------------------------------------------------------------
// Purpose:	Gets the floating point distance between the center point
//			of one rectangle and the center point of another.
//-----------------------------------------------------------------------------
float Rectangle::GetDistance( const Rectangle&amp; rectA, const Rectangle&amp; rectB )
{
	return Vector2D::Distance(GetCenter(rectA), GetCenter(rectB));
}

//-----------------------------------------------------------------------------
// Purpose:	Gets the unit vector from one rectangle to another
//-----------------------------------------------------------------------------
Vector2D Rectangle::GetDirection( const Rectangle&amp; rectA, const Rectangle&amp; rectB )
{
	Vector2D direction = GetCenter(rectA) - GetCenter(rectB);
	direction.Normalize();
	return direction;
}

Rectangle&amp; Rectangle::operator= ( const Rectangle&amp; r2 )
{
	if (this == &amp;r2)
		return *this;

	x = r2.x;
	y = r2.y;
	w = r2.w;
	h = r2.h;

	return *this;
}

bool Rectangle::operator== ( const Rectangle&amp; r2 ) const
{
	return ((w == r2.w) &amp;&amp; (h == r2.h));
}

bool Rectangle::operator!= ( const Rectangle&amp; r2 ) const
{
	return !((w == r2.w) &amp;&amp; (h == r2.h));
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2010/05/30/c-vector2d-rectangle-classes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Project Daedalus Update 4/10</title>
		<link>http://www.danielsoltyka.com/index.php/2010/04/10/project-daedalus-update-410-2/</link>
		<comments>http://www.danielsoltyka.com/index.php/2010/04/10/project-daedalus-update-410-2/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 16:36:50 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Daedalus (2D Platformer)]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Project Daedalus]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=638</guid>
		<description><![CDATA[It&#8217;s been some time since my last progress update, and I have sort of fallen out of the groove.  As such, this is going to be a short post to sort of get back into the swing of things. I spent a good while last night working out a good solution to adding rotating gear [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>It&#8217;s been some time since my last progress update, and I have sort of fallen out of the groove.  As such, this is going to be a short post to sort of get back into the swing of things.</p>
<p>I spent a good while last night working out a good solution to adding rotating gear platforms into the Boilerworks.  The initial idea was simple.  I was going to simply convert the gear texture into a set of vertices and load them up as a collision volume.  However, I realized this solution was not going to be viable as I have been using SAT collision, and a single gear polygon would have been a concave polygon (not supported by SAT implementation).  I decided to try Distance Grid collision instead of SAT, but the difference was noticeable and caused some big headaches.</p>
<p>It doesn&#8217;t look like the good folks at Farseer will be implementing concave polygon decomposition until Farseer 3.0 is released, so I had to take an alternate route.</p>
<p>The end result was simply generating multiple convex geometries programmatically that matched mt gear texture.  This ended up working perfectly, and as such we now have some really nice gear platforms ready to be added to levels.  A screenshot of the testbed is below.</p>
<p>Hopefully I&#8217;ll start updating this a bit more often as development continues.</p>

<a href="http://www.danielsoltyka.com/wp-content/gallery/project-daedalus/projectdaedalus-alpha5.png" title="" rel="lightbox[singlepic713]" >
	<img class="ngg-singlepic" src="http://www.danielsoltyka.com/wp-content/gallery/cache/713__384x216_projectdaedalus-alpha5.png" alt="Project Daedalus Alpha 5" title="Project Daedalus Alpha 5" />
</a>

</div>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2010/04/10/project-daedalus-update-410-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing a simple plugin architecture in C#</title>
		<link>http://www.danielsoltyka.com/index.php/2009/08/10/developing-a-simple-plugin-architecture-in-c/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/08/10/developing-a-simple-plugin-architecture-in-c/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 16:51:14 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Paradigm 2D World Builder]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Paradigm World Builder]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=324</guid>
		<description><![CDATA[Once my editor officially began being used for two different, completely unrelated games, I had a few decisions to make.  The main problem was the fact that an RPG needs very specific helper functions (NPC editing, scripting, etc) whereas a platformer would need things like event scripting.  Rather than make additional tools to handle these [...]]]></description>
			<content:encoded><![CDATA[<p>Once my editor officially began being used for two different, completely unrelated games, I had a few decisions to make.  The main problem was the fact that an RPG needs very specific helper functions (NPC editing, scripting, etc) whereas a platformer would need things like event scripting.  Rather than make additional tools to handle these functions, having them combined would be ideal.  However, I didn&#8217;t want to combine functions into an editor that would be useless for the other game.</p>
<p>The solution: a <strong>very simple</strong> plugin architecture.  By very simple, I mean that the actual Map classes would not be changed at all, in fact the XML map that the editor exported would not be changed in the slightest.  The plugin would not so much be given access to the Map in any way, but more so it would be given a place to run.  Essentially (at this point anyway) the plugin would be aesthetic.  It would allow level designers to use additional functionality within the level editor, which would already be running on the system.</p>
<p>But enough about that, the reason for this post is that I wanted to share a bit of code that let this happen.  After doing some research, I came across an old post by Shawn Walcheske called &#8220;Implementing a Plug-In Architecture in C#&#8221; (located here: <a href="http://www.ddj.com/cpp/184403942" target="_blank">http://www.ddj.com/cpp/184403942</a>).  My implementation is, basically, identical, <del>however the source download on that page is down, and he doesn&#8217;t really explain the System.Activator class which leaves the reader hanging</del>. <b>Update from a reader.  Apparently the source is still available here: <a href="ftp://ftp.cuj.com/sourcecode/cuj/2003/cujjan2003.zip">ftp://ftp.cuj.com/sourcecode/cuj/2003/cujjan2003.zip</a>.  Thanks!</b></p>
<p>So with that, I thought I&#8217;d show how I went about doing things, and basically explain the few loose ends that Shawn leaves out.  I think it goes without saying that if you really want to understand this entire concept, read his article as well.</p>
<p>The first thing we need to do is create a simple interface for our plugin.  This interface needs to be in it&#8217;s own assembly, for example I created ParadigmCommon.dll for plugins to reference in order to have access to this interface.  As the plugin system I am developing is very simple, the interface only provides an ActivatePlugin() method, as all we want to do is be able to launch new plugins from the main editor.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">interface</span> IParadigmPlugin
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Activates the plugin, showing it's main form</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF;">void</span> ActivatePlugin<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

<p>Next we need to define some custom attributes.  These attributes will hold some metadata for our class, this way our main application can reference that data.  We are, for this example, going to create a custom DisplayName attribute, and a custom Description attribute.  They are fairly self explanatory.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// This class defines the custom attribute for plugin display names</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #000000;">&#91;</span>AttributeUsage<span style="color: #000000;">&#40;</span>AttributeTargets.<span style="color: #FF0000;">Class</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> ParadigmPluginDisplayNameAttribute <span style="color: #008000;">:</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Attribute</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> displayName<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> ParadigmPluginDisplayNameAttribute<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> displayName<span style="color: #000000;">&#41;</span>
            <span style="color: #008000;">:</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">displayName</span> <span style="color: #008000;">=</span> displayName<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span> ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> displayName<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// This class defines the custom attribute for plugin descriptions</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #000000;">&#91;</span>AttributeUsage<span style="color: #000000;">&#40;</span>AttributeTargets.<span style="color: #FF0000;">Class</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> ParadigmPluginDescriptionAttribute <span style="color: #008000;">:</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Attribute</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> description<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> ParadigmPluginDescriptionAttribute<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> description<span style="color: #000000;">&#41;</span>
            <span style="color: #008000;">:</span> <span style="color: #0600FF;">base</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">description</span> <span style="color: #008000;">=</span> description<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">override</span> <span style="color: #FF0000;">string</span> ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">return</span> description<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

<p>Here we have an actual plugin.  As you can see, we need to use the ParadigmCommon namespace, as well as reference the DLL from the project.  The plugin itself merely implements the IParadigmPlugin interface and as such implements the ActivatePlugin() method, which only serves to open a new form for the plugin.  Simple enough.  Similar in implementation to the way Program.cs would launch the main form in a Windows application.  As you can see, we are also using our custom attributes.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Text</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Windows.Forms</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// referencing System.Windows.Forms is obviously needed for form usage, make sure to reference it in the project as well</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">ParadigmCommon</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// you must reference the ParadigmCommon namespace to access the needed attributes and interface</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> TestPlugin
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// This is an example of a paradigm plugin</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #000000;">&#91;</span>ParadigmPluginDisplayName<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Test Plugin&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #008080; font-style: italic;">// you must provice a display name</span>
    <span style="color: #000000;">&#91;</span>ParadigmPluginDescription<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Test Plugin&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> <span style="color: #008080; font-style: italic;">// as well as a description</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> TestPlugin <span style="color: #008000;">:</span> IParadigmPlugin  <span style="color: #008080; font-style: italic;">// Your main class must implement the IParadigmPlugin interface</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> ActivatePlugin<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008080; font-style: italic;">// by implementing the interface, you must implement an ActivatePlugin method</span>
        <span style="color: #000000;">&#123;</span>
            TestPluginMainForm mainForm <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TestPluginMainForm<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            mainForm.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            mainForm.<span style="color: #0000FF;">Activate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>In our host applciation, we need to define a few things.  First, we need a wrapper class.  This class will hold a reference to an object implementing our IParagidmPlugin interface (ie: any plugin we create), as well as the metadata for the plugin (in our case, name and description).  In this case we also implement an Activate() method that will call the actual plugin&#8217;s ActivatePlugin() method.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// This class wraps our plugins</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> ParadigmPlugin
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080;">#region Fields</span>
        <span style="color: #0600FF;">private</span> IParadigmPlugin plugin<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> name<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> description<span style="color: #008000;">;</span>
        <span style="color: #008080;">#endregion</span>
&nbsp;
        <span style="color: #008080;">#region Attributees</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Name
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> name<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Description
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> description<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #008080;">#endregion</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Constructs a plugin wrapper</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF;">public</span> ParadigmPlugin<span style="color: #000000;">&#40;</span>IParadigmPlugin plugin, <span style="color: #FF0000;">string</span> name, <span style="color: #FF0000;">string</span> description<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">plugin</span> <span style="color: #008000;">=</span> plugin<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">name</span> <span style="color: #008000;">=</span> name<span style="color: #008000;">;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">description</span> <span style="color: #008000;">=</span> description<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Activate Plugin</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Activate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            plugin.<span style="color: #0000FF;">ActivatePlugin</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>We also need to define a quick custom exception, which we will use later on.  There is really no implementation here in the example, but you can handle the exception however you wish.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">    <span style="color: #FF0000;">class</span> PluginNotValidException <span style="color: #008000;">:</span> ApplicationException
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> PluginNotValidException<span style="color: #000000;">&#40;</span>Type type, <span style="color: #FF0000;">string</span> param1<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

<p>First, we need to define a list to contain all of the plugins we load at runtime.  Next, we need a LoadPlugins() method.  This method uses reflection to handle plugin loading.  Essentially, it steps through our plugin directory looking for any file that matches the *.dll file name mask.  When it finds a DLL, it attempts to load the assembly.  If it fails, it will throw an exception and alert the user.</p>
<p>If it succeeds in loading the assembly, and looks for our IParadigmInterface.  If it finds it, it then gets our custom attributes.</p>
<p>Next, the System.Activator class comes into play.  This wasn&#8217;t mentioned in Shawn&#8217;s article as I said before.  Basically, we are going to create an object of a specific type, which in this case our type is going to be pulled from the loaded assembly, this way we create the correct type of object.</p>
<p>Next, we create an instance of our wrapper class.  Upon constructing, we are going to make sure to cast the object returned by System.Activator as IParadigmPlugin.  We will then add it to our list of loaded plugins.  Thats it.</p>
<p>The last part of this function is optional, but pretty cool and may be helpful.  Basically, we want our loaded plugins to show up dynamically on a menu strip.  So, we will iterate through our list of loaded plugins, and for each one we will add a new item to a toolstrip menu dropdown list.  We will set the name and text to the plugin display name, and the tool tip to the plugin description (see, we used the metadata for something afterall).  Then, we will set the new items Click event to be a delegate referencing the plugin&#8217;s Activate() method.  Simple right?  When this method executes, our tool strip will be dynamically populated by the plugins, and clicking them will launch them.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> List<span style="color: #008000;">&lt;</span>ParadigmPlugin<span style="color: #008000;">&gt;</span> loadedPlugins <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>ParadigmPlugin<span style="color: #008000;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> LoadPlugins<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// search plugin directory for dlls</span>
            <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> files <span style="color: #008000;">=</span> Directory.<span style="color: #0000FF;">GetFiles</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Plugins&quot;</span>, <span style="color: #666666;">&quot;*.dll&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// check each file in plugin direction</span>
            <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> file <span style="color: #0600FF;">in</span> files<span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">try</span>
                <span style="color: #000000;">&#123;</span>
                    <span style="color: #008080; font-style: italic;">// load the assembly and get types</span>
                    Assembly assembly <span style="color: #008000;">=</span> Assembly.<span style="color: #0000FF;">LoadFrom</span><span style="color: #000000;">&#40;</span>file<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> types <span style="color: #008000;">=</span> assembly.<span style="color: #0000FF;">GetTypes</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                    <span style="color: #008080; font-style: italic;">// look for our interface in the assembly</span>
                    <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span> type <span style="color: #0600FF;">in</span> types<span style="color: #000000;">&#41;</span>
                    <span style="color: #000000;">&#123;</span>
                        <span style="color: #008080; font-style: italic;">// if we found our interface, verify attributes</span>
                        <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>type.<span style="color: #0000FF;">GetInterface</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;IParadigmPlugin&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
                        <span style="color: #000000;">&#123;</span>
&nbsp;
                            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>type.<span style="color: #0000FF;">GetCustomAttributes</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>ParadigmPluginDisplayNameAttribute<span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Length</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
                                <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> PluginNotValidException<span style="color: #000000;">&#40;</span>type, <span style="color: #666666;">&quot;Plugin display name is not supported!&quot;</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>type.<span style="color: #0000FF;">GetCustomAttributes</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>ParadigmPluginDescriptionAttribute<span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Length</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
                                <span style="color: #0600FF;">throw</span> <span style="color: #008000;">new</span> PluginNotValidException<span style="color: #000000;">&#40;</span>type, <span style="color: #666666;">&quot;Plugin description is not supported&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                            <span style="color: #008080; font-style: italic;">// get custom attributes from plugin</span>
                            <span style="color: #FF0000;">string</span> name <span style="color: #008000;">=</span> type.<span style="color: #0000FF;">GetCustomAttributes</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>ParadigmPluginDisplayNameAttribute<span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                            <span style="color: #FF0000;">string</span> description <span style="color: #008000;">=</span> type.<span style="color: #0000FF;">GetCustomAttributes</span><span style="color: #000000;">&#40;</span><span style="color: #008000;">typeof</span><span style="color: #000000;">&#40;</span>ParadigmPluginDescriptionAttribute<span style="color: #000000;">&#41;</span>, <span style="color: #0600FF;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                            <span style="color: #008080; font-style: italic;">// create the plugin using reflection</span>
                            <span style="color: #FF0000;">Object</span> o <span style="color: #008000;">=</span> Activator.<span style="color: #0000FF;">CreateInstance</span><span style="color: #000000;">&#40;</span>type<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                            ParadigmPlugin plugin <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ParadigmPlugin<span style="color: #000000;">&#40;</span>o <span style="color: #0600FF;">as</span> IParadigmPlugin, name, description<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>                                                               
&nbsp;
                            loadedPlugins.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>plugin<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                        <span style="color: #000000;">&#125;</span>
                    <span style="color: #000000;">&#125;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>Exception e<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Message</span>, <span style="color: #666666;">&quot;Plugin Error&quot;</span>, MessageBoxButtons.<span style="color: #0000FF;">OK</span>, MessageBoxIcon.<span style="color: #0000FF;">Error</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// iterate through list and add them to our form control</span>
            <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> loadedPlugins.<span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                ParadigmPlugin plugin <span style="color: #008000;">=</span> loadedPlugins<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
                pluginsToolStripMenuItem.<span style="color: #0000FF;">DropDownItems</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>plugin.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                pluginsToolStripMenuItem.<span style="color: #0000FF;">DropDownItems</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Click</span> <span style="color: #008000;">+=</span> <span style="color: #FF0000;">delegate</span> <span style="color: #000000;">&#123;</span> plugin.<span style="color: #0000FF;">Activate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
                pluginsToolStripMenuItem.<span style="color: #0000FF;">DropDownItems</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> plugin.<span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span>
                pluginsToolStripMenuItem.<span style="color: #0000FF;">DropDownItems</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToolTipText</span> <span style="color: #008000;">=</span> plugin.<span style="color: #0000FF;">Description</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span></pre></div></div>

<p>You could easily expose much more via the interface and make some complicated plugins, but that isn&#8217;t needed in this scenario.  However, I hope this helps to illuminate the basics of plugin architecture in C#.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/08/10/developing-a-simple-plugin-architecture-in-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8216;A World Apart&#8217; Overworld Progress</title>
		<link>http://www.danielsoltyka.com/index.php/2009/08/08/a-world-apart-overworld-progress/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/08/08/a-world-apart-overworld-progress/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 18:11:49 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[A World Apart (RPG)]]></category>
		<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=321</guid>
		<description><![CDATA[Over the past two weeks I have put a good amount of time into integrating my existing tile engine with the [in development] game engine for an RPG we have been developing called &#8216;A World Apart&#8217;. As it stands now, rendering is working perfectly, along with collision, multiple layers supporting occlusion, collidable NPC&#8217;s, and NPC/Player [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past two weeks I have put a good amount of time into integrating my existing tile engine with the [in development] game engine for an RPG we have been developing called &#8216;A World Apart&#8217;.</p>
<p>As it stands now, rendering is working perfectly, along with collision, multiple layers supporting occlusion, collidable NPC&#8217;s, and NPC/Player occlusion based on world placement.</p>
<p>In the coming days / weeks I will be uploading some reports on progress, as well as some videos of development.</p>
<p>At that time a new entry will be made to my portfolio which will underline the scope of the game, as well as my actual involvement in the project.</p>
<p>Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/08/08/a-world-apart-overworld-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upcoming level editor updates</title>
		<link>http://www.danielsoltyka.com/index.php/2009/07/25/upcoming-level-editor-updates/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/07/25/upcoming-level-editor-updates/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 20:35:14 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Paradigm 2D World Builder]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Paradigm World Builder]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=307</guid>
		<description><![CDATA[After switching gears and looking at my editor from an RPG standpoint instead of a sidescrolling standpoint, I&#8217;ve noticed a few shortcomings in my editor and engine design. As such, a few changes are planned. Shadow mapping.  I have a few different ideas on to how create shadows with a decent degree of alpha transparency.  [...]]]></description>
			<content:encoded><![CDATA[<p>After switching gears and looking at my editor from an RPG standpoint instead of a sidescrolling standpoint, I&#8217;ve noticed a few shortcomings in my editor and engine design.</p>
<p>As such, a few changes are planned.</p>
<ol>
<li>Shadow mapping.  I have a few different ideas on to how create shadows with a decent degree of alpha transparency.  More than likely I will go with a separate B&amp;W image that stores that shadow textures and have the engine draw them as needed with alpha transparency.</li>
<li>Layers, layers, LAYERS.  Three layers, simply, is not enough.  As such, I&#8217;m going to transition from the current 3 layer system to an unlimited layer system.</li>
<li>Zooming.  RPG maps are going to be somewhat large.  I think zooming in and out of the editor will be a very helpful addition.</li>
<li>Advanced entity spawning system.  I&#8217;m on the fence with this one.  I may or may not implement this in the editor.  Part of me thinks creating an NPC editor would be smarter.  We&#8217;ll see how this pans out though.</li>
</ol>
<p>That is all for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/07/25/upcoming-level-editor-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tile Based Level Editor Progress</title>
		<link>http://www.danielsoltyka.com/index.php/2009/07/20/tile-based-level-editor-progress/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/07/20/tile-based-level-editor-progress/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 15:55:26 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Paradigm 2D World Builder]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Paradigm World Builder]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=288</guid>
		<description><![CDATA[Well it’s about time isn’t it?  I finally got around to writing this blog post regarding my tile editor.  I recently joined a team to produce an RPG in C# using XNA Studio 3.1, so I figured now would be a good time to put some more work into the tile engine / editor and [...]]]></description>
			<content:encoded><![CDATA[<p>Well it’s about time isn’t it?  I finally got around to writing this blog post regarding my tile editor.  I recently joined a team to produce an RPG in C# using XNA Studio 3.1, so I figured now would be a good time to put some more work into the tile engine / editor and showcase what is working so far.</p>
<p>As it stands, the editor is pretty robust.  Currently it supports three tile layers, a rear, mid, and foreground layer.  The rear layer is self explanatory.  The mid layer renders over the rear layer to add details, and the foreground layer renders over NPCs, the player, particles, etc (as long as your engine supports it).  The foreground layer is currently tinted yellow so it can be distinguished.</p>
<p>Tiles can be drawn in as single tiles and regions.  You can also choose to fill an entire layer with a single tile if you so choose.</p>
<p>The editor supports multiple collision types such as impassible, platform, slopes, etc.  These are basically just flags that your engine needs to interpret correctly.</p>
<p>The editor also supports spawn points.  Any entity your engine supports can be dumped into a plain text file and the editor will parse it.  The spawn points can be added dynamically to the map.</p>
<p>It also supports a portal layer which allows for areas of the map to be flagged as a portal.  This allows for your engine to do a check against those regions and load a new map as needed.</p>
<p>We also support terrain effects which are regions of the map that will be processed with some sort of effect.  My demo shows this being used with a simple water shader I wrote.</p>
<p>You can set the background color of the map to any of the predefined .NET colors, as well as a custom color using the color wheel.  You can resize the map dynamically as well as specify the tile size to match your tile set.</p>
<p>The next iteration of this editor will support more layers, likely unlimited using just a list of layers.  In addition I plan to implement a sort of multilayer occlusion so that the foreground layer is more or less dynamic.  Different layers will occlude other layers, so on and so forth.  This is not really needed for a platformer, but will be pretty useful in RPG world building.</p>
<h2>Videos:</h2>
<p>(My apologies as the audio goes out of sync near the end of part 1 and into part 2, blame Camstudio.)</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="384" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Z7Zv0Kw7Or0&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="384" src="http://www.youtube.com/v/Z7Zv0Kw7Or0&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="384" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/i-prBDRkPKo&amp;hl=en&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="600" height="384" src="http://www.youtube.com/v/i-prBDRkPKo&amp;hl=en&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/07/20/tile-based-level-editor-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Level Editor Progress</title>
		<link>http://www.danielsoltyka.com/index.php/2009/06/10/xna-c-level-editor-progress/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/06/10/xna-c-level-editor-progress/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 04:15:52 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Paradigm 2D World Builder]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Paradigm World Builder]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=256</guid>
		<description><![CDATA[I&#8217;ve been hard at work on the level editor for my game engine and I figured I&#8217;d get something up here showing current progress. It is currently near completion actually. It allows for editing of 3 tile layers, background, midground, and foreground. It also allows for world hazards, spawn points, portals, and multiple collision types. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hard at work on the level editor for my game engine and I figured I&#8217;d get something up here showing current progress.  It is currently near completion actually.  It allows for editing of 3 tile layers, background, midground, and foreground.  It also allows for world hazards, spawn points, portals, and multiple collision types.  The editor renders using the XNA framework within a normal WinForms application.  Output is serialized using the XNA intermediate serializer into an XML file that can be directly loaded into the game itself.</p>
<p>Basically, pretty sweet.</p>
<p>Here is a screenshot for the time being.</p>
<div id="attachment_257" class="wp-caption alignnone" style="width: 310px"><a href="http://www.danielsoltyka.com/wp-content/uploads/2009/06/editor.jpg"><img class="size-medium wp-image-257" title="Level Editor Alpha" src="http://www.danielsoltyka.com/wp-content/uploads/2009/06/editor-300x186.jpg" alt="Level Editor Alpha" width="300" height="186" /></a><p class="wp-caption-text">Level Editor Alpha</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/06/10/xna-c-level-editor-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Added Flamethrower to Sidescroller</title>
		<link>http://www.danielsoltyka.com/index.php/2009/05/27/c-xna-added-flamethrower-to-sidescroller/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/05/27/c-xna-added-flamethrower-to-sidescroller/#comments</comments>
		<pubDate>Thu, 28 May 2009 02:42:48 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Daedalus (2D Platformer)]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Project Daedalus]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=241</guid>
		<description><![CDATA[I know I said the last update would be the last before new assets and a level, but I just finished the flamethrower weapon and it turned out really well. I figured I&#8217;d share it. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>I know I said the last update would be the last before new assets and a level, but I just finished the flamethrower weapon and it turned out really well.  I figured I&#8217;d share it.  Enjoy!</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/SlWqrB3z6ys&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/SlWqrB3z6ys&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/05/27/c-xna-added-flamethrower-to-sidescroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Final Sidescroller Pre-Alpha</title>
		<link>http://www.danielsoltyka.com/index.php/2009/05/26/c-xna-final-sidescroller-pre-alpha/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/05/26/c-xna-final-sidescroller-pre-alpha/#comments</comments>
		<pubDate>Tue, 26 May 2009 23:28:44 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Daedalus (2D Platformer)]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Project Daedalus]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=233</guid>
		<description><![CDATA[This will be the final pre-alpha entry. Sound is up and running now, collision has been improved but is still a little wonky at times. Particle bugs are worked out, and hit detection is much better. Enjoy.]]></description>
			<content:encoded><![CDATA[<p>This will be the final pre-alpha entry.  Sound is up and running now, collision has been improved but is still a little wonky at times.  Particle bugs are worked out, and hit detection is much better.  Enjoy.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/_FmzlnjMdfY&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/_FmzlnjMdfY&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/05/26/c-xna-final-sidescroller-pre-alpha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>2D Sidescroller Development Continues&#8230;</title>
		<link>http://www.danielsoltyka.com/index.php/2009/05/23/c-xna-2d-sidescroller-development-continues/</link>
		<comments>http://www.danielsoltyka.com/index.php/2009/05/23/c-xna-2d-sidescroller-development-continues/#comments</comments>
		<pubDate>Sat, 23 May 2009 14:37:03 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Game Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Daedalus (2D Platformer)]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Project Daedalus]]></category>

		<guid isPermaLink="false">http://www.danielsoltyka.com/?p=143</guid>
		<description><![CDATA[Things are coming together very well. Rudimentary AI routines are implemented, which will serve as the framework for upcoming NPC enemies. A few particle effects are working, as well as world hazards, and a parallax scrolling background. I hope to have a few enemies functional in the next few days, but this is dependent on [...]]]></description>
			<content:encoded><![CDATA[<p>Things are coming together very well.  Rudimentary AI routines are implemented, which will serve as the framework for upcoming NPC enemies.  A few particle effects are working, as well as world hazards, and a parallax scrolling background.</p>
<p>I hope to have a few enemies functional in the next few days, but this is dependent on time.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/kWEeftdA25Q&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/kWEeftdA25Q&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielsoltyka.com/index.php/2009/05/23/c-xna-2d-sidescroller-development-continues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
