<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Minalien.com &#187; Computers</title>
	<atom:link href="http://www.minalien.com/index.php/category/tech/computers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.minalien.com</link>
	<description>My brain makes things explode.</description>
	<lastBuildDate>Thu, 09 Sep 2010 03:25:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/us/</creativeCommons:license>		<item>
		<title>Head in the Clouds&#8230;</title>
		<link>http://www.minalien.com/index.php/2010/09/08/head-in-the-clouds/</link>
		<comments>http://www.minalien.com/index.php/2010/09/08/head-in-the-clouds/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 03:25:33 +0000</pubDate>
		<dc:creator>Samantha</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Thinking Out Loud]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Happiness]]></category>
		<category><![CDATA[Health]]></category>
		<category><![CDATA[Transgender]]></category>

		<guid isPermaLink="false">http://www.minalien.com/?p=336</guid>
		<description><![CDATA[For starters, allow me to restate something from my Twitter. It seems I&#8217;ve been looking down at the streets below for so long that I&#8217;d forgotten to look to the clouds above. And I&#8217;m disappointed in myself, because I&#8217;ve defiled my fervor for knowledge by holding it above others. While there are a number of]]></description>
			<content:encoded><![CDATA[<p>For starters, allow me to restate something from my Twitter. It seems I&#8217;ve been looking down at the streets below for so long that I&#8217;d forgotten to look to the clouds above. And I&#8217;m disappointed in myself, because I&#8217;ve defiled my fervor for knowledge by holding it above others. While there are a number of places where I have not shown that side of me, there are a good many where I have acted harshly, treated others negatively instead of helping them to improve, merely because they did not meet the standards that I claimed to hold myself to. I apologize to the people who have had to see this side of me, and I hope that the rest never do. I am tired of staring at the streets, where I used to be. I am disgusted that it took me making a series of incredibly simple, ridiculous mistakes this afternoon to realize that I had allowed my ego to greatly surpass what is warranted, and allowed myself to fall into this rut that has been bothering me so much. I have allowed myself to drop to the point where I have not put the whole of myself into a task, including learning, and have instead merely picked at what I thought I wanted, without knowing it &#8211; in short, I have allowed myself to become the very thing that I loathe (forgive the cliche).</p>
<p>Here is a glimpse of what is to come, however:<br />
It is time that I start running a tutorial series again. I don&#8217;t feel comfortable slipping back into the 2D game tutorial that I had run before, because much of it is inferior work, in my eyes. I want, instead, to write a series of tutorials going from the ground-up building a three-dimensional Pac-Man clone. This is something that doesn&#8217;t require any sort of amazing graphics skill, and is a great introduction to three-dimensional programming. I plan to have the tutorial use OGRE 3D for rendering purposes, and a number of other libraries &#8211; including SQLite (high score database), Squirrel (scripting for the ghosts), and OpenAL (Audio.. if you had to guess &lt;3).</p>
<p>Second, I am going to start pushing work on my LCAR project when I return from the Oceanside area. It&#8217;s time I took to a project that required my learning, and growth of my knowledge. It&#8217;s not going to be anything amazing, graphically, but perhaps I&#8217;ll be able to turn that into a selling point, if I can morph it into something unique-looking with strange graphics shaders. At the very least, perhaps I can come up with some interesting things to throw into this almost neglected blog.</p>
<p>And finally, I am starting work on a two-dimensional, console-style role-playing game for the iPhone/iPod Touch. I don&#8217;t yet have an iPod Touch (and I don&#8217;t intend to get an iPhone), I do plan to get one at some point for the sake of this project. I also intend to get iTGB, which will be used for this project. This will be the first project that I have ever actually attempted to sell, and I&#8217;m going to be working overtime to make sure that this is worth every penny I charge for it. even if I only intend to charge approximately one-hundred pennies for it. D:</p>
<p>And so, in closing, it&#8217;s time for me to start accepting my life, and holding the results of my choices dear to me, even if they may not be to my liking. Most importantly, it is time for me to start pushing toward my goals. I fully intend to go to Casual Connect 2011, for my first attempt to pass. I&#8217;m nervous now, but one of my goals is to manage to overcome said feelings of foreboding, to conquer this fear of peoples&#8217; opinions. It&#8217;s time that I allowed myself to flourish. No more hiding in the dark &#8211; I am here to stay.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.minalien.com/index.php/2010/09/08/head-in-the-clouds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finish Up Friday : LCAR Torque 3D</title>
		<link>http://www.minalien.com/index.php/2010/08/06/finish-up-friday-lcar-t3d/</link>
		<comments>http://www.minalien.com/index.php/2010/08/06/finish-up-friday-lcar-t3d/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 19:59:46 +0000</pubDate>
		<dc:creator>Samantha</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Lights, Camera, Action/RPG!]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.minalien.com/?p=329</guid>
		<description><![CDATA[I think I&#8217;m going to start participating in Finish-up Fridays, partly because I think it&#8217;ll be fun, and partly because I think having weekly goals will help make me a lot more productive when it comes to my development projects. And so with this first FuF, I&#8217;m going to work like hell to get some]]></description>
			<content:encoded><![CDATA[<p>I think I&#8217;m going to start participating in Finish-up Fridays, partly because I think it&#8217;ll be fun, and partly because I think having weekly goals will help make me a lot more productive when it comes to my development projects. And so with this first FuF, I&#8217;m going to work like hell to get some things accomplished with the Torque3D version of my <em>Lights, Camera, Action/RPG!</em> project.</p>
<p>My goals for tonight:<br />
1. Get T3D to build with PhysX in MSVC 2010<br />
2. Implement an SQLite3 Database system (based on the resources available on the TorquePowered website)<br />
3. Re-implement onMouseMove, onMouseDragged, and onRightMouseDragged within the second beta of Torque 3D 1.1<br />
4. Re-implement the isometric camera system for Torque 3D 1.1 Beta 2 (If you can&#8217;t tell, I haven&#8217;t moved anything between betas, and I plan on completely re-starting the project, as far as the Torque engine is concerned, because I was.. messy with B1)<br />
5. Begin implementing a basic Ranged combat system (in other words, I want to shoot things. n.n)</p>
<p>And I hope to do a lot of work with the following over the weekend and next week:<br />
1. Try to get, at the very least, the beginning pieces of a toon shader implemented<br />
2. Start learning to do basic 3D modelling/animaiton with 3D Studio Max and SoftImage, both with relation to the Torque engines and OGRE 3D.</p>
<p>Bye-ni~</p>
]]></content:encoded>
			<wfw:commentRss>http://www.minalien.com/index.php/2010/08/06/finish-up-friday-lcar-t3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lights, Camera, Action/RPG!</title>
		<link>http://www.minalien.com/index.php/2010/07/28/lights-camera-actionrpg/</link>
		<comments>http://www.minalien.com/index.php/2010/07/28/lights-camera-actionrpg/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 16:56:29 +0000</pubDate>
		<dc:creator>Samantha</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Lights, Camera, Action/RPG!]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.minalien.com/?p=317</guid>
		<description><![CDATA[Well, I&#8217;m back. With the return of the Internet to my computer, it is time for me to return to my development. Unfortunately, I&#8217;ve been away from writing my tutorial series for too long, and I&#8217;m not going to be continuing it. I intend to release some one-shot tutorials for a while, and I&#8217;m working]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;m back. With the return of the Internet to my computer, it is time for me to return to my development. Unfortunately, I&#8217;ve been away from writing my tutorial series for too long, and I&#8217;m not going to be continuing it. I intend to release some one-shot tutorials for a while, and I&#8217;m working on developing two 3D Point-and-Click Action/RPG prototypes &#8211; one with a custom C++ engine using OGRE 3D for rendering, the other using Torque 3D. Both prototypes are pretty much going to be the same thing &#8211; but each of them is intended for me learning/touching up on different systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.minalien.com/index.php/2010/07/28/lights-camera-actionrpg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZuneHD &#8211; Virtual D-Pad Component for XNA 3.1</title>
		<link>http://www.minalien.com/index.php/2010/05/16/zunehd-virtual-dpad-component-for-xna/</link>
		<comments>http://www.minalien.com/index.php/2010/05/16/zunehd-virtual-dpad-component-for-xna/#comments</comments>
		<pubDate>Mon, 17 May 2010 04:11:39 +0000</pubDate>
		<dc:creator>Samantha</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Zune]]></category>
		<category><![CDATA[Zune HD]]></category>

		<guid isPermaLink="false">http://www.minalien.com/?p=286</guid>
		<description><![CDATA[Just finished working on a pretty basic virtual d-pad for the Zune HD/XNA Framework 3.1. It&#8217;s really rough around the edges, and certainly isn&#8217;t optimized, but it works. Download Source DPadHD.dll (Managed Library) Description A simple, kind of messy virtual d-pad for your ZuneHD games. You can feel free to add it to your games,]]></description>
			<content:encoded><![CDATA[<div id="attachment_287" class="wp-caption alignright" style="width: 490px"><a href="http://www.minalien.com/index.php/2010/05/16/zunehd-virtual-dpad-component-for-xna/minalien-zune-2/" rel="attachment wp-att-287"><img src="http://www.minalien.com/wp-content/uploads/2010/05/Minalien-Zune-2.png" alt="" title="Zune HD Virtual D-Pad" width="480" height="272" class="size-full wp-image-287" /></a><p class="wp-caption-text">Sample use of the Virtual D-Pad Component</p></div>
<p>Just finished working on a pretty basic virtual d-pad for the Zune HD/XNA Framework 3.1. It&#8217;s really rough around the edges, and certainly isn&#8217;t optimized, but it works.</p>
<p><strong>Download</strong><br />
<a href="http://files.minalien.com/DPadHD-Src.7z">Source</a><br />
<a href="http://files.minalien.com/DPadHD-Bin.7z">DPadHD.dll</a> (Managed Library)</p>
<p><strong>Description</strong><br />
A simple, kind of messy virtual d-pad for your ZuneHD games. You can feel free to add it to your games, with or without crediting me, just don&#8217;t distribute the D-Pad or modifications of it without at least giving word that it came from me. It&#8217;ll need a fair bit of optimization and editing before it&#8217;s ready for any game that you wish to distribute, however.</p>
<p><strong>Features</strong><br />
Position can be configured<br />
Works similarly to the default XNA input systems<br />
Built as an XNA DrawableGameComponent</p>
<p><strong>Usage Sample</strong></p>
<pre class="brush: csharp;">			dPadManager = new Segfault.DPadHD.DPadManager(this);
			dPadManager.Landscape = true;
			this.Components.Add(dPadManager);</pre>
<p>Creating the system is easy. First, you create it as you would any other component. You can set whether or not you want to use it in Landscape mode (which merely rotates the inputs counter-clockwise &#8211; I assume a &#8220;back-button-to-the-right&#8221; landscape view) by setting a simple boolean value, and then you add the D-Pad Manager to the components list. It will update automatically, just as the XNA input managers do by default.</p>
<p>Its position can be set on screen with the following code:</p>
<pre class="brush: csharp;">dPadManager.Position = new Vector2(50.0f, 12.0f);</pre>
<p>And finally, the state of the D-Pad&#8217;s four cardinal direction buttons can be checked by retrieving the current game state:</p>
<pre class="brush: csharp;">if (this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Up))
				pos.X += (gameTime.ElapsedGameTime.Milliseconds);

			if (this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Down))
				pos.X -= (gameTime.ElapsedGameTime.Milliseconds);

			if(this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Left))
				pos.Y -= (gameTime.ElapsedGameTime.Milliseconds);

			if (this.dPadManager.GetState().IsButtonDown(Segfault.DPadHD.DPadButton.Right))
				pos.Y += (gameTime.ElapsedGameTime.Milliseconds);</pre>
<p>Enjoy. :D</p>
]]></content:encoded>
			<wfw:commentRss>http://www.minalien.com/index.php/2010/05/16/zunehd-virtual-dpad-component-for-xna/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++/D3D Pong Tutorial 04: Adding Keyboard Input</title>
		<link>http://www.minalien.com/index.php/2010/04/25/cd3d-pong-tutorial-04-adding-keyboard-input/</link>
		<comments>http://www.minalien.com/index.php/2010/04/25/cd3d-pong-tutorial-04-adding-keyboard-input/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 01:09:55 +0000</pubDate>
		<dc:creator>Samantha</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[Pong (C++/DirectX)]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Series]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[2D]]></category>
		<category><![CDATA[D3DPong]]></category>
		<category><![CDATA[Direct3D]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.minalien.com/?p=240</guid>
		<description><![CDATA[Tutorial Description In the last tutorial, we established a rendering engine and got scene objects working, with basic physics. In this tutorial, we are going to implement the initial Input manager, which will be focusing on the keyboard. I was planning to include mouse input, but it turns out that DirectInput only handles the mouse]]></description>
			<content:encoded><![CDATA[<p><strong>Tutorial Description</strong><br />
In the last tutorial, we established a rendering engine and got scene objects working, with basic physics. In this tutorial, we are going to implement the initial Input manager, which will be focusing on the keyboard. I was planning to include mouse input, but it turns out that DirectInput only handles the mouse in relative positioning &#8211; which is perfect for three-dimensional first-person shooter games that need to track the movement of the mouse &#8211; but it&#8217;s poor for two-dimensional casual games. For those of you that do wish to use mouse input, I will be covering it a later tutorial &#8211; the methods of getting absolute positioning will require a bit of modification to our engine.</p>
<p><strong>Downloads</strong><br />
<em>Please note that I&#8217;ve switched to using 7-zip in place of WinRAR for compression</em><br />
<a href="http://files.minalien.com/D3DPong/04/D3DPong-Bin.7z">Binary Only (20.4KB)</a><br />
<a href="http://files.minalien.com/D3DPong/04/D3DPong-Src.7z">Full VS2010 Project Dir (26.8KB)</a></p>
<p><strong>SVN Repository</strong><br />
As of this tutorial, I have created and added a Subversion repository on Assembla to store the code for the tutorial series. I will continue to upload the source for each tutorial &#8211; the SVN will merely contain the code as I write it, so you can feel free to play around with the code that I&#8217;m working on before I release a tutorial. Mostly, this is to help people play around with things if there&#8217;s a point where I&#8217;m slow to create the tutorial following the code (as was the case with this tutorial).</p>
<p>SVN URL: <a href="http://svn2.assembla.com/svn/d3dpong" title="D3DPong SVN Repository">http://svn2.assembla.com/svn/d3dpong</a></p>
<p><strong>Starting Words</strong><br />
Notice: This tutorial continues from where “<a href="http://www.minalien.com/index.php/2010/03/21/cd3d-pong-tutorial-03-scene-objects-and-sprite-rendering/" title="C++/D3D Pong Tutorial 03: Scene Objects and Sprite Rendering">C++/D3D Pong Tutorial 03</a>” article left off. Please read it if you have not already.</p>
<p><span id="more-240"></span></p>
<p><strong>Libraries</strong><br />
You will need to add a single library to the project to build with the code in this tutorial:<br />
dinput.lib</p>
<p><strong>Code Listing 1: CInputManager.h</strong></p>
<pre class="brush: cpp;">#pragma once

// Global Header Files
#include &lt;Windows.h&gt;
#include &lt;d3d9.h&gt;
#include &lt;d3dx9.h&gt;
#include &lt;dinput.h&gt;

// Local Header Files
#include &quot;CGameEngine.h&quot;
#include &quot;CKeyboardState.h&quot;

namespace D3DPong
{
	class CInputManager
	{
	private:
		/** Constructor &amp; Destructor **/
		CInputManager(void);						// ctor
		CInputManager(CInputManager const&amp;) { }		// copy ctor
		~CInputManager(void);						// dtor

		static CInputManager* _instance;

		// DirectInput Devices
		LPDIRECTINPUT8			_device;	// Core DirectInput Object
		LPDIRECTINPUTDEVICE8	_keyboard;	// Keyboard

		// Keyboard-related Variables
		CKeyboardState* _preKeyboardState;
		CKeyboardState* _curKeyboardState;

		// Device Initialization
		bool initKeyboard(void);

	public:
		/** Singleton **/
		static CInputManager* Instance(void) { return CInputManager::_instance; }

		/** Public Functions **/
		bool Init(void);
		void Update(void);

		/** Keyboard Functions **/
		bool IsKeyDown(int);
		bool IsKeyUp(int);
		bool WasKeyPressed(int);
		bool WasKeyReleased(int);

		/** Accessors &amp; Mutators **/
		LPDIRECTINPUT8 GetDevice(void) { return this-&gt;_device; }
		CKeyboardState* GetCurKeyboardState(void) { return this-&gt;_curKeyboardState; }
		CKeyboardState* GetPreKeyboardState(void) { return this-&gt;_preKeyboardState; }
	};
};</pre>
<p>Here is the framework for our Input Manager. Again, we&#8217;re back down to lower source sizes &#8211; because we&#8217;re not trying to implement the world here. As we did with our Game Engine class, we&#8217;ve turned our Input Manager into a singleton &#8211; we only want one of them to be created throughout the application.</p>
<pre class="brush: cpp;">		// DirectInput Devices
		LPDIRECTINPUT8			_device;	// Core DirectInput Object
		LPDIRECTINPUTDEVICE8	_keyboard;	// Keyboard

		// Keyboard-related Variables
		CKeyboardState* _preKeyboardState;
		CKeyboardState* _curKeyboardState;

		// Device Initialization
		bool initKeyboard(void);</pre>
<p>The first two variables are input devices &#8211; the first, as with our Direct3D object, we have an object that we will use to access the DirectInput system. The second is the actual object that we will use to access the keyboard device &#8211; when adding a Mouse or a Gamepad/Joystick, you will add another LPDIRECTINPUTDEVICE8. If you&#8217;ve noticed the 8, you&#8217;ll notice that this is something from DirectX 8 &#8211; DirectInput hasn&#8217;t changed since then. In all honesty, the use of DirectInput isn&#8217;t recommended by Microsoft, but it will suffice for our purposes. We then add two variables to store the keyboard state &#8211; the current keyboard state, which will contain the state as of the current frame, and the previous, which will (if you haven&#8217;t guessed) store the state of the last frame. We do this so that we can not only check whether a key is <em>currently</em> being pressed, but also whether it was pressed or released between the current and last frame. This makes things easier on us, in the long run, because we can wait for (for example) the escape key to be released before we end the game, and it will make managing our game menus much easier when we want to handle selection of menu options game console style. Finally, we define a private function that will initialize our keyboard. It will help keep our Init() function tidy for the future addition of controllers, mice, and other input devices.</p>
<pre class="brush: cpp;">		/** Public Functions **/
		bool Init(void);
		void Update(void);</pre>
<p>These two functions are pretty obvious in what they do. Init() will initialize all of our input devices, and update will update the current/previous states of our devices. I&#8217;ll explain them more when we actually flesh them out.</p>
<pre class="brush: cpp;">		/** Keyboard Functions **/
		bool IsKeyDown(int);
		bool IsKeyUp(int);
		bool WasKeyPressed(int);
		bool WasKeyReleased(int);</pre>
<p>Last on the list of things to look at is our key-checking functions. The first two will return whether the key is currently pressed or released, which can be useful for continuous motion checking, such as what we will be doing with our pong paddles. The latter two check if they key&#8217;s state has changed between this frame and the last (if the key has been pressed or released).</p>
<p><strong>Code Listing 2: CInputManager.cpp</strong></p>
<pre class="brush: cpp;">#include &quot;CInputManager.h&quot;
#include &quot;CKeyboardState.h&quot;

namespace D3DPong
{
	CInputManager* CInputManager::_instance = new CInputManager();

	CInputManager::CInputManager(void)
		: _device(NULL), _keyboard(NULL),
		_curKeyboardState(NULL), _preKeyboardState(NULL)
	{
	}

	CInputManager::~CInputManager(void)
	{
		if(this-&gt;_keyboard != NULL)
		{
			this-&gt;_keyboard-&gt;Unacquire();
			this-&gt;_keyboard-&gt;Release();
			this-&gt;_keyboard = NULL;
		}

		if(this-&gt;_device != NULL)
		{
			this-&gt;_device-&gt;Release();
			this-&gt;_device = NULL;
		}
	}

	bool CInputManager::Init(void)
	{
		// Initialize the DirectInput Device
		if(FAILED(DirectInput8Create(GetModuleHandle(NULL),	// Instance Handle
			DIRECTINPUT_VERSION,							// DirectInput Version
			IID_IDirectInput8, 								// Device Type
			(LPVOID*)&amp;this-&gt;_device,						// Pointer to device storage
			NULL)))
		{
			MessageBox(NULL, L&quot;Error initializing Input Manager&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		// Initialize the Keyboard
		if(!this-&gt;initKeyboard())
			return false;

		// Call update once to populate the input states
		this-&gt;Update();

		return true;
	}

	bool CInputManager::initKeyboard(void)
	{
		if(FAILED(this-&gt;_device-&gt;CreateDevice(GUID_SysKeyboard,
			&amp;this-&gt;_keyboard,
			NULL)))
		{
			MessageBox(NULL, L&quot;Error initializing Keyboard&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		if(FAILED(this-&gt;_keyboard-&gt;SetDataFormat(&amp;c_dfDIKeyboard)))
		{
			MessageBox(NULL, L&quot;Error setting keyboard data format&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		if(FAILED(this-&gt;_keyboard-&gt;SetCooperativeLevel(CGameEngine::Instance()-&gt;GetWindowHandle(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
		{
			MessageBox(NULL, L&quot;Error setting keyboard cooperative level&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		if(FAILED(this-&gt;_keyboard-&gt;Acquire()))
		{
			MessageBox(NULL, L&quot;Error acquiring keyboard device&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		// Create the keyboard states
		this-&gt;_curKeyboardState = new CKeyboardState();
		this-&gt;_preKeyboardState = new CKeyboardState();

		return true;
	}

	void CInputManager::Update(void)
	{
		// Update the keyboard
		this-&gt;_preKeyboardState-&gt;CopyKeyBuffer(this-&gt;_curKeyboardState-&gt;GetKeyStates());

		// Make sure we reacquire the keyboard if the device was lost
		if(this-&gt;_keyboard-&gt;GetDeviceState(this-&gt;_curKeyboardState-&gt;GetBufferSize(), this-&gt;_curKeyboardState-&gt;GetKeyBuffer()) == DIERR_INPUTLOST)
			this-&gt;_keyboard-&gt;Acquire();
	}

	bool CInputManager::IsKeyDown(int keyCode)
	{
		return this-&gt;_curKeyboardState-&gt;IsKeyDown(keyCode);
	}

	bool CInputManager::IsKeyUp(int keyCode)
	{
		return this-&gt;_curKeyboardState-&gt;IsKeyUp(keyCode);
	}

	bool CInputManager::WasKeyPressed(int keyCode)
	{
		if(this-&gt;_curKeyboardState-&gt;IsKeyDown(keyCode) &amp;&amp; this-&gt;_preKeyboardState-&gt;IsKeyUp(keyCode))
			return true;
		else
			return false;
	}

	bool CInputManager::WasKeyReleased(int keyCode)
	{
		if(this-&gt;_curKeyboardState-&gt;IsKeyUp(keyCode) &amp;&amp; this-&gt;_preKeyboardState-&gt;IsKeyDown(keyCode))
			return true;
		else
			return false;
	}
};</pre>
<p>Here are the guts of our system. Not everything will need covered, because it will be pretty obvious based on other parts, but here goes:</p>
<pre class="brush: cpp;">	bool CInputManager::Init(void)
	{
		// Initialize the DirectInput Device
		if(FAILED(DirectInput8Create(GetModuleHandle(NULL),	// Instance Handle
			DIRECTINPUT_VERSION,							// DirectInput Version
			IID_IDirectInput8, 								// Device Type
			(LPVOID*)&amp;this-&gt;_device,						// Pointer to device storage
			NULL)))
		{
			MessageBox(NULL, L&quot;Error initializing Input Manager&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		// Initialize the Keyboard
		if(!this-&gt;initKeyboard())
			return false;

		// Call update once to populate the input states
		this-&gt;Update();

		return true;
	}</pre>
<p>This method initializes our input management system. The first thing that we must do is initialize our DirectInput device, because it will be used to create any DirectInput-based input systems later (keyboard, mouse, and joypad, for example). We then call initKeyboard() to initialize our keyboard (when adding a Mouse or Joystick, you would also add an initMouse/initJoystick function, just to keep things clean), make sure it worked properly, then capture the current state of the input system.</p>
<pre class="brush: cpp;">	bool CInputManager::initKeyboard(void)
	{
		if(FAILED(this-&gt;_device-&gt;CreateDevice(GUID_SysKeyboard,
			&amp;this-&gt;_keyboard,
			NULL)))
		{
			MessageBox(NULL, L&quot;Error initializing Keyboard&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		if(FAILED(this-&gt;_keyboard-&gt;SetDataFormat(&amp;c_dfDIKeyboard)))
		{
			MessageBox(NULL, L&quot;Error setting keyboard data format&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		if(FAILED(this-&gt;_keyboard-&gt;SetCooperativeLevel(CGameEngine::Instance()-&gt;GetWindowHandle(), DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
		{
			MessageBox(NULL, L&quot;Error setting keyboard cooperative level&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		if(FAILED(this-&gt;_keyboard-&gt;Acquire()))
		{
			MessageBox(NULL, L&quot;Error acquiring keyboard device&quot;, L&quot;Error&quot;, MB_OK);
			return false;
		}

		// Create the keyboard states
		this-&gt;_curKeyboardState = new CKeyboardState();
		this-&gt;_preKeyboardState = new CKeyboardState();

		return true;
	}</pre>
<p>Not much to see here, in spite of the length &#8211; most of it&#8217;s error checking. First, we use the DirectInput device to create our Keyboard device, then we follow up by setting the data format and cooperative level. The cooperative level sets how our application works with the operating system and other applications running, when it comes to handling input on the device. Setting a Foreground cooperative level makes it so that our game only responds to input when the game window is our active window. This way, if the player were to open Notepad and press the escape key, it wouldn&#8217;t close our game. Setting this to background, on the other hand, allows this to happen. The second piece of our cooperative level determines whether other applications will be allowed to access the input device when the game is using them. Nonexclusive means that the input device can be shared with others, and that works best to keep our application on friendly terms with any software our players may be using. The only time you really want to use exclusive mode is when using a mouse in a three-dimensional shooter game, to prevent our mouse from slipping out the side of the window when we&#8217;re turning. Finally, we capture (acquire) our input device, and create two empty instances to store the state of the keyboard.</p>
<pre class="brush: cpp;">	void CInputManager::Update(void)
	{
		// Update the keyboard
		this-&gt;_preKeyboardState-&gt;CopyKeyBuffer(this-&gt;_curKeyboardState-&gt;GetKeyStates());

		// Make sure we reacquire the keyboard if the device was lost
		if(this-&gt;_keyboard-&gt;GetDeviceState(this-&gt;_curKeyboardState-&gt;GetBufferSize(), this-&gt;_curKeyboardState-&gt;GetKeyBuffer()) == DIERR_INPUTLOST)
			this-&gt;_keyboard-&gt;Acquire();
	}</pre>
<p>The update method updates our keyboard states. First, we use the CopyKeyBuffer (which, as you will see when we design our Keyboard State class, simply copies the key buffer array from another array). We then check to make sure that the device was not lost (for example, if the window is switched). If it is, we re-acquire it. When we use the GetDeviceState() function within the if() statement, we are also capturing the keyboard state &#8211; first, we pass the size of the buffer, then we pass a pointer to the buffer array. GetDeviceState will copy the state of our keyboard to the key buffer array.</p>
<p>Because the IsKeyUp and IsKeyDown functions directly map to functions of the same name on the current keyboard state, we&#8217;ve only one last thing to cover:</p>
<pre class="brush: cpp;">	bool CInputManager::WasKeyPressed(int keyCode)
	{
		if(this-&gt;_curKeyboardState-&gt;IsKeyDown(keyCode) &amp;&amp; this-&gt;_preKeyboardState-&gt;IsKeyUp(keyCode))
			return true;
		else
			return false;
	}</pre>
<p>This is pretty obvious, but I want to be completely clear on how we&#8217;re working this. If the state has been changed between the current frame and the last, we return true. In the case above, we are checking if the key has been pressed. We check the current state of the key against the previous state &#8211; if it was released (up) on the last frame, but is pressed (down) now, we return true &#8211; the key has been pressed between the current and last frames. Otherwise, it hasn&#8217;t, so we return false.</p>
<p><strong>Code Listing 3: CKeyboardState.h</strong></p>
<pre class="brush: cpp;">#pragma once

#include &lt;Windows.h&gt;

namespace D3DPong
{
	class CKeyboardState
	{
	private:
		char _keyStates[256];

	public:
		/** Constructor &amp; Destructor **/
		CKeyboardState(void);
		~CKeyboardState(void);

		/** Public Methods **/
		bool IsKeyDown(int);
		bool IsKeyUp(int);
		void CopyKeyBuffer(char*);

		/** Accessors &amp; Mutators **/
		char* GetKeyStates(void) { return this-&gt;_keyStates; }
		LPVOID GetKeyBuffer(void) { return (LPVOID)&amp;this-&gt;_keyStates; }
		DWORD GetBufferSize(void) { return sizeof(this-&gt;_keyStates); }
	};
};</pre>
<p>The only member variable here is our key buffer &#8211; which is a simple char array, exactly what will be set by the keyboard device&#8217;s GetDeviceState function. I&#8217;ll cover the functions below:</p>
<p><strong>Code Listing 4: CKeyboardState.cpp</strong></p>
<pre class="brush: cpp;">#include &quot;CKeyboardState.h&quot;

namespace D3DPong
{
	CKeyboardState::CKeyboardState(void)
	{
	}

	CKeyboardState::~CKeyboardState(void)
	{
	}

	bool CKeyboardState::IsKeyDown(int keyCode)
	{
		if(this-&gt;_keyStates[keyCode] &amp; 0x80)
			return true;
		else
			return false;
	}

	bool CKeyboardState::IsKeyUp(int keyCode)
	{
		return !this-&gt;IsKeyDown(keyCode);
	}

	void CKeyboardState::CopyKeyBuffer(char* buffer)
	{
		for(int i = 0; i &lt; 256; i++)
			this-&gt;_keyStates[i] = buffer[i];
	}
};</pre>
<p>Here we go!</p>
<pre class="brush: cpp;">	bool CKeyboardState::IsKeyDown(int keyCode)
	{
		if(this-&gt;_keyStates[keyCode] &amp; 0x80)
			return true;
		else
			return false;
	}</pre>
<p>To check whether or not a key is up, we simply do a BITWISE AND operation against the key state (stored in our buffer) at the keycode in our array against 0&#215;80. The keyCode integer will be a pre-defined DirectInput keycode, such as DIK_ESCAPE or DIK_HOME &#8211; you can find a list of DirectInput keycodes <a href="http://www.gamespp.com/directx/directInputKeyboardScanCodes.html" title="DirectX / DirectInput Keyboard Scan Codes - Games++:">here</a>. To find out if the key is up, we need only check if it is not down &#8211; so our IsKeyUp merely returns !IsKeyDown.</p>
<pre class="brush: cpp;">	void CKeyboardState::CopyKeyBuffer(char* buffer)
	{
		for(int i = 0; i &lt; 256; i++)
			this-&gt;_keyStates[i] = buffer[i];
	}</pre>
<p>Here, we actually copy the key buffer. There are only 256 indexes in the key buffer array, so that&#8217;s all we need to copy. In case you&#8217;re surprised, yes, arrays are simply glorified pointers with fixed sizes &#8211; and you can easily use an array as a pointer.</p>
<p><strong>Wrapping it into our engine</strong><br />
Now, we need to make some ties to bring our singleton into the application. Open up WinMain.cpp, and let&#8217;s get started.</p>
<pre class="brush: cpp;">#define InputManager D3DPong::CInputManager::Instance()</pre>
<p>Just as we did with the instance of the game engine, we are going to create a Macro to access our Input Manager singleton. Now, we can just use InputManager->WasKeyPressed instead of going out of our way to type D3DPong::CInputManager::Instance()->WasKeyPressed.</p>
<pre class="brush: cpp;">	// Initialize the Game Engine
	GEInstance-&gt;SetWindowHandle(hWnd);
	if(!GEInstance-&gt;Init(GEInstance-&gt;GetScreenWidth(), GEInstance-&gt;GetScreenHeight(), GEInstance-&gt;GetColorDepth()))
		return 0;

	if(!InputManager-&gt;Init())
		return 0;

	// Message Loop
	while(GEInstance-&gt;GetGameRunning())
	{
		while(PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);
		}

		InputManager-&gt;Update();
		GEInstance-&gt;Update();
	}</pre>
<p>The only changes here are the lines regarding the InputManager &#8211; these parts are all we need to tie the input manager into our engine. They&#8217;re quite obvious in what they do &#8211; initialize and update the input manager &#8211; so I doubt that I need to give much explanation.</p>
<p><strong>Adding input to our test game</strong><br />
I&#8217;m only going to cover checking for the escape key on this, but if you look at the tutorial files, I&#8217;ve added some simple platformer-esque input handling to our earlier rendering and physics tests.</p>
<pre class="brush: cpp;">void GameUpdate(float delta)
{
	if(InputManager-&gt;WasKeyReleased(DIK_ESCAPE))
		GEInstance-&gt;SetGameRunning(false);

	// [...] The rest of our update method
}</pre>
<p>Here, we check if the Escape key has been released &#8211; this will allow us to easily exit our window via a single keystroke. I choose to check for the release of the escape key out of personal preference, because I prefer acting on the release of most keystrokes, but you could achieve similar results by doing WasKeypressed &#8211; it would merely act when the key was pressed, instead of when it was released (&lt;/obvious&gt;).</p>
<p>And there you have it, the (long awaited?) keyboard input tutorial. If I missed something between the downloadable source and what I&#8217;ve posted, please let me know so I can fix it &#8211; I wrote the code for this ages ago, and only finally got around to writing the tutorial portion recently.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.minalien.com/index.php/2010/04/25/cd3d-pong-tutorial-04-adding-keyboard-input/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Qt4</title>
		<link>http://www.minalien.com/index.php/2010/03/29/qt4/</link>
		<comments>http://www.minalien.com/index.php/2010/03/29/qt4/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 22:37:50 +0000</pubDate>
		<dc:creator>Samantha</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Qt4]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[alienIRC]]></category>
		<category><![CDATA[application development]]></category>
		<category><![CDATA[application programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[Win]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.minalien.com/?p=236</guid>
		<description><![CDATA[As of last night, I started looking into using Qt4 for future Application development projects of mine &#8211; and damned if it doesn&#8217;t look like the best option available to me (the best alternative being writing the UI on each different platform individually). For those who don&#8217;t know, Qt4 is an immensely popular and very]]></description>
			<content:encoded><![CDATA[<p>As of last night, I started looking into using Qt4 for future Application development projects of mine &#8211; and damned if it doesn&#8217;t look like the best option available to me (the best alternative being writing the UI on each different platform individually). For those who don&#8217;t know, <a href="http://qt.nokia.com/" title="Nokia's Qt4 Website">Qt4</a> is an immensely popular and very powerful cross-platform application library that works with C++, and is supported on a large number of machines &#8211; from 64-bit Windows desktops to 32-bit embedded Linux solutions to the wonder that is Mac OS X. All without having to change the code &#8211; all that is required is a recompile (assuming you&#8217;ve set things up properly, of course). It even supports cross-platform project (.pro) files, and has a cross-platform toolset that accompanies its SDK &#8211; including a GUI designer, a set of debugging tools, and even an IDE that ties with a MinGW compiler.</p>
<p>I&#8217;ve started working again on an IRC client &#8211; now under the name alienIRC (formerly SevenIRC, which was being planned solely for Windows). I&#8217;ve also decided to make it completely open-source, and intend to license it under LGPLv3, something it shares with the Qt framework that is going to power it. I&#8217;m going to be setting up a Git repository on <a href="http://www.gitorious.org/" title="Gitorious">Gitorious</a> for the project, and will be setting up some development pages on this blog &#8211; including issue tracking, a wiki, and some other tools. Right now, my plan is to closely emulate the mIRC interface &#8211; mostly because mIRC is my favorite IRC client &#8211; and will be working to make sure it feels native on all supported platforms. I will personally be maintaining builds on Windows (32- and 64-bit), OpenSUSE 11, and Mac OS X Snow Leopard. I will primarily be using the IDE that comes with Qt, though I will work to ensure that it compiles in X-Code 3 and Visual Studio 2008/2010.</p>
<p>As far as alienIRC itself goes, I&#8217;m looking at the possibility of using WebKit for the chat windows&#8217; messages. This would make it incredibly easy to add formatting, because I could easily change messages from the mIRC color character into HTML tags before adding the text to the message box. It all depends on how it runs compared to a custom text box. I also plan to implement a number of features that are popular with mIRC, such as scripting (Lua, specifically), &#8220;address books,&#8221; nick highlighting, file sharing, et cetera. I&#8217;m currently working on some UI concept work &#8211; since it will have to be different from SevenIRC&#8217;s WPF plans and the previous OS X-only alienIRC UI concept that relied on some UI elements only found on Mac (such as Drawers).</p>
<p>If anybody is interested in contributing to this project, send me some messages &#8211; I&#8217;d be happy to hear your input, especially on features that you feel would be good to implement. Make sure you sign up for an account on Gitorious &#8211; and that you upload your SSH keys and such. If you&#8217;ve never used Git, and you&#8217;re a Windows developer, this is a very useful link for seting it up on Windows: <a href="http://www.lostechies.com/blogs/jason_meridth/archive/2009/06/01/git-for-windows-developers-git-series-part-1.aspx" title="Git for Windows Developers">Git for Windows Developers: Part 1</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.minalien.com/index.php/2010/03/29/qt4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What did I just do?</title>
		<link>http://www.minalien.com/index.php/2010/02/04/what-did-i-just-do/</link>
		<comments>http://www.minalien.com/index.php/2010/02/04/what-did-i-just-do/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 20:24:26 +0000</pubDate>
		<dc:creator>Samantha</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[iMac]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Snow Leopard]]></category>
		<category><![CDATA[Waxy's Sushi Party]]></category>

		<guid isPermaLink="false">http://www.minalien.com/?p=66</guid>
		<description><![CDATA[Well, I&#8217;m not entirely sure why, but for some reason I seem to have thought that it would be an okay idea to buy a Mac. What is wrong with me, I honestly don&#8217;t know, but I can say that it&#8217;s a pretty solid system. And I like the fact that the iMac only has]]></description>
			<content:encoded><![CDATA[<div id="attachment_109" class="wp-caption alignleft" style="width: 310px"><a href="http://www.minalien.com/?attachment_id=109"><img src="http://www.minalien.com/wp-content/uploads/2010/02/Mac_SS1-300x168.png" alt="Screenshot of my iMac" title="iMac Screenshot" width="300" height="168" class="size-medium wp-image-109" /></a><p class="wp-caption-text">Making my terminal insult Justin.</p></div>
<p>Well, I&#8217;m not entirely sure why, but for some reason I seem to have thought that it would be an okay idea to buy a Mac. What is wrong with me, I honestly don&#8217;t know, but I can say that it&#8217;s a pretty solid system. And I like the fact that the iMac only has a single cable &#8211; the power cable &#8211; while everything else (system, monitor, etc) is either built-in or (in the case of the keyboard &#038; mouse) running through Bluetooth.</p>
<p>At least now I can start working on the native builds of my Mac-based projects (Waxy&#8217;s Sushi Party among them).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.minalien.com/index.php/2010/02/04/what-did-i-just-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
