<?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>Henry Lau&#039;s Untitled Blog &#187; C++ class</title>
	<atom:link href="http://blog.scad.edu/honlau20/category/c-class/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.scad.edu/honlau20</link>
	<description>Watch how little henry grows</description>
	<lastBuildDate>Fri, 05 Apr 2013 15:53:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>[C++] Final project: SDL application</title>
		<link>http://blog.scad.edu/honlau20/2012/11/14/c-final-project-sdl-application/</link>
		<comments>http://blog.scad.edu/honlau20/2012/11/14/c-final-project-sdl-application/#comments</comments>
		<pubDate>Wed, 14 Nov 2012 15:46:22 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=199</guid>
		<description><![CDATA[I am extending my previous study on SDL library for my final. From the tutorial page I blogged before, they are just separate utilities like input event handler, collision detection, sprite animation etc. Each of them consist of multiple functions and classes. My job is reading all the lines, extracting the essentials and stitching them [...]]]></description>
				<content:encoded><![CDATA[<p>I am extending my previous study on SDL library for my final. From the tutorial page I blogged before, they are just separate utilities like input event handler, collision detection, sprite animation etc. Each of them consist of multiple functions and classes. My job is reading all the lines, extracting the essentials and stitching them into a piece. In order to clear out my mind, I started with a diagram that tells me what are the components in a class, so that I will not miss anything when I brought them in.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/20121112_120016.jpg"><img class="alignnone size-medium wp-image-201" src="http://blog.scad.edu/honlau20/files/2012/11/20121112_120016-217x300.jpg" alt="" width="217" height="300" /></a></p>
<p>I also made use of a game idea I created last quarter as the content. It is a game that the player hit and replace obstacles on the map with good road, so that a truck can pass through to send resource to poor villages. I simplified it to a demo within a given time frame.</p>
<p>If a frame is already working, it requires courage to start changing the code. It is sad to see errors come out again. The worst case is I added many lines of codes but the program is not running in any ways and I cannot change it back. For this biggest program I have ever made in this quarter, I back up a version each time I successfully implemented a features. The process is as follow:</p>
<p>1. Tile map (last time) + Keyboard control character</p>
<p>2. Character with animation</p>
<p>3. Collision and logic &lt;- change a tile to something else when touching it</p>
<p>4. Create the sprite sheet for the tiles and walkcycle of the character</p>
<p>5. Add another class for the truck and load an image into it</p>
<p>6. Make the truck move.</p>
<p>This is how the game looks like at the moment:</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/screen01.jpg"><img class="alignnone size-medium wp-image-210" src="http://blog.scad.edu/honlau20/files/2012/11/screen01-300x236.jpg" alt="" width="300" height="236" /></a></p>
<p><span id="more-199"></span></p>
<p>However I did not reached step 6 before the deadline. But that should not be hard. I can reuse the code for collision detection from the character.</p>
<p>Knowing what is going on with the code is actually very enjoyable.</p>
<p><strong>Clipping a sprite:</strong></p>
<p>No wonder why each time I was looking for animation for sprite, it always comes in a sprite sheet. I needed to crop each of them out with photoshop in order to import into Scratch. That is because the image can only be loaded once, and reused many times in the program. If any animation is involved, only the clipping plane is being moved (or the image behind the clipping mask is being moved), instead of swapping the whole image into something else. The following code is the animation for the dot (character). It has multiple frames when it is facing left and multiple frames when it is facing right respectively. Same method is repeated for the truck and the tiles. But the tile is a bit different. It is clipped according to its type. Changing the type of the tile is actually changing the position of the image.</p>
<blockquote><p>clipsRight[ 0 ].x = 0;<br />
clipsRight[ 0 ].y = 0;<br />
clipsRight[ 0 ].w = DOT_WIDTH;<br />
clipsRight[ 0 ].h = DOT_HEIGHT;</p>
<p>clipsRight[ 1 ].x = DOT_WIDTH;<br />
clipsRight[ 1 ].y = 0;<br />
clipsRight[ 1 ].w = DOT_WIDTH;<br />
clipsRight[ 1 ].h = DOT_HEIGHT;</p>
<p>clipsRight[ 2 ].x = DOT_WIDTH * 2;<br />
clipsRight[ 2 ].y = 0;<br />
clipsRight[ 2 ].w = DOT_WIDTH;<br />
clipsRight[ 2 ].h = DOT_HEIGHT;</p>
<p>&#8230;</p>
<p>clipsLeft[ 0 ].x = 0;<br />
clipsLeft[ 0 ].y = DOT_HEIGHT;<br />
clipsLeft[ 0 ].w = DOT_WIDTH;<br />
clipsLeft[ 0 ].h = DOT_HEIGHT;</p>
<p>clipsLeft[ 1 ].x = DOT_WIDTH;<br />
clipsLeft[ 1 ].y = DOT_HEIGHT;<br />
clipsLeft[ 1 ].w = DOT_WIDTH;<br />
clipsLeft[ 1 ].h = DOT_HEIGHT;</p>
<p>&#8230;</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/dot.png"><img class="alignnone size-full wp-image-207" src="http://blog.scad.edu/honlau20/files/2012/11/dot.png" alt="" width="80" height="40" /></a> &lt;&#8211; the sprite sheet of the character</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/tiles.png"><img class="alignnone size-medium wp-image-209" src="http://blog.scad.edu/honlau20/files/2012/11/tiles-300x225.png" alt="" width="300" height="225" /></a> &lt;&#8211; sprite sheet for the tiles</p></blockquote>
<p><strong> Sprite Animation</strong></p>
<p>In each fps of the running program, the sprites are re-evaluate according to its number of frame, then move the frame by 1. In the following code, a function apply_surface is called in each frame in order to render the image with its clipping box and mask. A simple logic is applied to determine it is left or right and pass it to the function. When right or left key is pressed, the x position is added by a positive or negative velocity. Facing left or right can be determined by the direction of the velocity. And the frame of the sprite is looped. It is following the same logic as in Scratch.</p>
<blockquote><p>if( status == DOT_RIGHT )</p>
<p>{<br />
apply_surface( box.x &#8211; camera.x, box.y &#8211; camera.y, dot, screen, &amp;clipsRight[ frame ] );</p>
<p>}<br />
else if( status == DOT_LEFT )<br />
{<br />
apply_surface( box.x &#8211; camera.x, box.y &#8211; camera.y, dot, screen, &amp;clipsLeft[ frame ] );</p>
<p>}</p></blockquote>
<p><strong>Collision</strong></p>
<p>The collision checking function is surprisingly similar to the one I made for Bomberman I made for previous assignment with Scratch, like comparing the x and y of object a and b to see whether they are overlapping and at which side. But this time the logic blocks are code in the form of function. Another function touches_wall is calling the check collision function and determine what the character is actually touching and return true or false. The original calling is to stop the character by adding and deducting the speed at once when it hit a wall-type tile. I change it to changing the tile type of the tile it hit. I was trying to create a new tile to replace the old tile. But that did not work. And changing the tile type is the right way to achieve the effect I want.</p>
<blockquote><p>bool touches_wall( SDL_Rect box, Tile *tiles[] )<br />
{<br />
//Go through the tiles<br />
for( int t = 0; t &lt; TOTAL_TILES; t++ )<br />
{<br />
//If the tile is a wall type tile<br />
if( ( tiles[ t ]-&gt;get_type() &gt;= TILE_CENTER ) &amp;&amp; ( tiles[ t ]-&gt;get_type() &lt;= TILE_TOPLEFT ) )<br />
{<br />
//If the collision box touches the wall tile<br />
if( check_collision( box, tiles[ t ]-&gt;get_box() ) == true )<br />
{</p>
<p>//return true;<br />
tiles[ t ]-&gt;type = 0;</p>
<p>}<br />
}<br />
}</p>
<p>//If no wall tiles were touched<br />
return false;<br />
}</p></blockquote>
<p><strong> Load image</strong></p>
<p>loading an image is more complicated than I think. At first I simply copy all the codes for the character and replace all the variables with the truck&#8217;s one &#8212; without test running it. After I completed, it somehow did not work well. The truck image clashes the memory of the tile and everything messed up. I went back to a back up file and started up from the beginning step by step. But it already took me several hours. T_T</p>
<p>===================division======================</p>
<p>At the beginning of the quarter I started from Scratch, using ready made logic block without knowing what is within. After a quarter of learning, I can finally repeat the process with codes and library. Of course if I can do the same with a easier way, why do I need a more complicated way? But it is a learning process. I feel like I can program whatever game I need to make now!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/11/14/c-final-project-sdl-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[C++] Assignment 7: Pipe Attack</title>
		<link>http://blog.scad.edu/honlau20/2012/11/13/c-assignment-7-pipe-attack/</link>
		<comments>http://blog.scad.edu/honlau20/2012/11/13/c-assignment-7-pipe-attack/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 14:58:12 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=184</guid>
		<description><![CDATA[This is a trace back of older assignment. May be I was too tired to blog this at that time? I do not know. I intended to make this assignment a test of the logic I planed for my own other project. It is a pipe connecting game which a player can tap and rotate [...]]]></description>
				<content:encoded><![CDATA[<p>This is a trace back of older assignment. May be I was too tired to blog this at that time? I do not know.</p>
<p>I intended to make this assignment a test of the logic I planed for my own other project. It is a pipe connecting game which a player can tap and rotate a pipe tile to connect them into a complete water way. The logic is not limited by the platform, if I can test it out and make that an assignment, why not? Smart hah!</p>
<p><span id="more-184"></span>We need to start with a flow chart this time. I have that every time so no worry. I have a brief lecture from my professor and he told me I can save many work if I replace the array with a class and make use of function with the class. I should have learn that when I was learning Java and I sort of need that for Actionsript 3.0 seven years ago. But at that time this was not covered in the course and I was into something else so I terminated my progress in learning programming. I know that I need to learn that some point in my life and this is the chance.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/henryLau_assignment05_flow_ITGM315_FA12.jpg"><img class="alignnone size-medium wp-image-185" src="http://blog.scad.edu/honlau20/files/2012/11/henryLau_assignment05_flow_ITGM315_FA12-300x166.jpg" alt="" width="300" height="166" /></a></p>
<p>The product is a simplified pipe attack with just one row. I am testing out the logic so rows number does not matter. Everything is going smoothly until I am parsing a class into a function. I admit that my foundation is not good. This code simply don&#8217;t work:</p>
<p>output(a[]);</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/log05.jpg"><img class="alignnone size-medium wp-image-186" src="http://blog.scad.edu/honlau20/files/2012/11/log05-300x192.jpg" alt="" width="300" height="192" /></a></p>
<p>But at this moment I need to move on, so I went to plan B. Using switch can solve the issue. The logic still remain the same. But I am not making the process into a neat and tidy function. If I am making more rows I may have to copy and paste the logic to infinity. This is how it became:</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/log04.jpg"><img class="alignnone size-medium wp-image-187" src="http://blog.scad.edu/honlau20/files/2012/11/log04-300x279.jpg" alt="" width="300" height="279" /></a></p>
<p>The game runs like this: first input the row which the rotating tile belongs to. In here we have just one row, so A. Then the column. If they are all horizontal, you win.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/log02.jpg"><img class="alignnone size-medium wp-image-188" src="http://blog.scad.edu/honlau20/files/2012/11/log02-300x163.jpg" alt="" width="300" height="163" /></a></p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/11/log03.jpg"><img class="alignnone size-medium wp-image-189" src="http://blog.scad.edu/honlau20/files/2012/11/log03-300x184.jpg" alt="" width="300" height="184" /></a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/11/13/c-assignment-7-pipe-attack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[c++] OpenGL first attempt</title>
		<link>http://blog.scad.edu/honlau20/2012/10/31/c-opengl-first-attempt/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/31/c-opengl-first-attempt/#comments</comments>
		<pubDate>Wed, 31 Oct 2012 10:23:34 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=176</guid>
		<description><![CDATA[This is a class exercise. OpenGl is introduced and I need to get a triangle rendered following  a provided tutorial (this) Again, getting all the dll and header in place, linked correctly in the VC configuration, so on, are annoying. Different place on google search led me to various solution, including but not limited to: installing [...]]]></description>
				<content:encoded><![CDATA[<p>This is a class exercise. OpenGl is introduced and I need to get a triangle rendered following  a provided tutorial (<a href="http://www.nullterminator.net/opengl32.html" target="_blank">this</a>)</p>
<p>Again, getting all the dll and header in place, linked correctly in the VC configuration, so on, are annoying. Different place on google search led me to various solution, including but not limited to: installing the windows SDK (different version), downloading various version of openGL package from different places, ETC. Even after Kevin tell me that there is a download file of source code at the bottom of the tutorial, the errors just shifted to some other errors.</p>
<p>Alright at the time I was distracted with something else, actually it was some course registration issue I was talking to my professor, I found too lines of code I see a lot of time when I am working on xcode. I did not put too much of expectation on it because there are just 2 lines. But of coz it runs or I would not post it here!</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/opengl01.jpg"><img class="alignnone size-medium wp-image-179" src="http://blog.scad.edu/honlau20/files/2012/10/opengl01-300x198.jpg" alt="" width="300" height="198" /></a></p>
<p>&#8220;Oh what?! It runs? Okay&#8230;&#8221;</p>
<p>I am not particularly happy this time. I think I have got used to this kind of situation and it is completely normal.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/31/c-opengl-first-attempt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first RPG game with C++ and SDL is finally running</title>
		<link>http://blog.scad.edu/honlau20/2012/10/30/my-first-rpg-game-with-c-and-sdl-is-finally-running/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/30/my-first-rpg-game-with-c-and-sdl-is-finally-running/#comments</comments>
		<pubDate>Tue, 30 Oct 2012 12:48:29 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=164</guid>
		<description><![CDATA[Frankly speaking, following and understanding the tutorial is nothing difficult. Getting all dll and header files in place is thrilling. I should say, until today GUI has been so advance, there is still such thing which is totally not user friendly. I start to admire Gamesalad and Scratch. Now it is just a black dot [...]]]></description>
				<content:encoded><![CDATA[<p>Frankly speaking, following and understanding the tutorial is nothing difficult. Getting all dll and header files in place is thrilling. I should say, until today GUI has been so advance, there is still such thing which is totally not user friendly. I start to admire Gamesalad and Scratch.</p>
<p>Now it is just a black dot moving around a tiled map with keyboard control and collision detection. I can start replacing the tile with something more appealing.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/log011.jpg"><img class="alignnone size-medium wp-image-165" src="http://blog.scad.edu/honlau20/files/2012/10/log011-300x244.jpg" alt="" width="300" height="244" /></a></p>
<p><span id="more-164"></span></p>
<p>This tutorial of SDL is actually written quite practically (well at least to my experience). The tile is an external sprite sheet which I can edit with imaging software. The map is designed in an external txt file (which here is a .map file) which I can edit very easily. And all there will be loaded dynamically as the program initiates.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/log031.jpg"><img class="alignnone size-medium wp-image-169" src="http://blog.scad.edu/honlau20/files/2012/10/log031-300x180.jpg" alt="" width="300" height="180" /></a></p>
<p>the sprite looks like this:</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/tiles.png"><img class="alignnone size-medium wp-image-170" src="http://blog.scad.edu/honlau20/files/2012/10/tiles-300x225.png" alt="" width="300" height="225" /></a></p>
<p>So I will just edit and replace it will this:</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/tiles1.png"><img class="alignnone size-medium wp-image-171" src="http://blog.scad.edu/honlau20/files/2012/10/tiles1-300x225.png" alt="" width="300" height="225" /></a></p>
<p>It is always good to know how it works and when I look at how it is actually coded, the code look exactly like what is in my mind. And the point is I can understand it very quickly and I do not need to code it myself.</p>
<p>So the code will manipulate the position of the image according to what the type a tile should be. It is similar to writing code to crop the file dynamically.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/log041.jpg"><img class="alignnone size-medium wp-image-172" src="http://blog.scad.edu/honlau20/files/2012/10/log041-230x300.jpg" alt="" width="230" height="300" /></a></p>
<p>In the following function, the program import the .map file. I use a same name as the tutorial, the lazy.map, just to avoid any trouble if I change the name. The code is surprisingly simple. Just: std::ifsteam map(&#8220;lazy.map&#8221;); A bit like in flash.  A lot simpler than those I use to look at when I am dealing with iOS app.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/log05.jpg"><img class="alignnone size-medium wp-image-173" src="http://blog.scad.edu/honlau20/files/2012/10/log05-300x247.jpg" alt="" width="300" height="247" /></a></p>
<p>It looks like below when it runs again:</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/log06.jpg"><img class="alignnone size-medium wp-image-174" src="http://blog.scad.edu/honlau20/files/2012/10/log06-300x225.jpg" alt="" width="300" height="225" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/30/my-first-rpg-game-with-c-and-sdl-is-finally-running/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web-based RPG Maker</title>
		<link>http://blog.scad.edu/honlau20/2012/10/24/web-based-rpg-maker/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/24/web-based-rpg-maker/#comments</comments>
		<pubDate>Wed, 24 Oct 2012 06:37:53 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=151</guid>
		<description><![CDATA[Got something by accident, a web-based RPG maker. It works simply by placing images and naming them accordingly, changing several dat files in note pad, and running the html file with a browser on iphone/android. Looks like fun! But I will hold the testing to next week. Arh many works to do! left: a map [...]]]></description>
				<content:encoded><![CDATA[<p>Got something by accident, a web-based RPG maker. It works simply by placing images and naming them accordingly, changing several dat files in note pad, and running the html file with a browser on iphone/android. Looks like fun! But I will hold the testing to next week. Arh many works to do!</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/blog02.jpg"><img class="alignnone size-medium wp-image-152" src="http://blog.scad.edu/honlau20/files/2012/10/blog02-300x222.jpg" alt="" width="300" height="222" /></a></p>
<p>left: a map dat opened in notepad. middle: the resource images and else. right: js files.</p>
<p>BTW the tutorial is in Japanese. So lucky that I can sort of understand what it says.</p>
<p><a href="http://www.programmingmat.jp/soft_lib/m11rpg/m11rpgwj.html">http://www.programmingmat.jp/soft_lib/m11rpg/m11rpgwj.html</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/24/web-based-rpg-maker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful resource get!</title>
		<link>http://blog.scad.edu/honlau20/2012/10/24/useful-resource-get/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/24/useful-resource-get/#comments</comments>
		<pubDate>Wed, 24 Oct 2012 05:49:47 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=148</guid>
		<description><![CDATA[http://www.youtube.com/watch?v=NudiUwtz6Fg&#38;feature=related When I was checking out this video, I thought if I know how it is made, my assignment for this week is done lol. But the author did not mention anything about the process even somebody asked him in the comment. So I searched some terms and pages he mentioned in the replies. And [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.youtube.com/watch?v=NudiUwtz6Fg&amp;feature=related">http://www.youtube.com/watch?v=NudiUwtz6Fg&amp;feature=related</a></p>
<p>When I was checking out this video, I thought if I know how it is made, my assignment for this week is done lol. But the author did not mention anything about the process even somebody asked him in the comment. So I searched some terms and pages he mentioned in the replies. And I get the SDL library, the Simple Direct Media Layer.</p>
<p>This page looks very encouraging and powerful. Feels like if I go through them I can do whatever I want. Let&#8217;s go for it for a while.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/blog01.jpg"><img class="alignnone size-medium wp-image-149" src="http://blog.scad.edu/honlau20/files/2012/10/blog01-280x300.jpg" alt="" width="280" height="300" /></a></p>
<p><a href="http://lazyfoo.net/SDL_tutorials/index.php">http://lazyfoo.net/SDL_tutorials/index.php</a></p>
<p>I also found another Tiled map tutorial with some other library. I will just leave a link here.</p>
<p><a href="http://www.dreamincode.net/forums/topic/230524-c-tile-engine-from-scratch-part-1/">http://www.dreamincode.net/forums/topic/230524-c-tile-engine-from-scratch-part-1/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/24/useful-resource-get/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[c++] assignment 6: Tame-a-Little-Doggy Done! =w=..v</title>
		<link>http://blog.scad.edu/honlau20/2012/10/20/133/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/20/133/#comments</comments>
		<pubDate>Sat, 20 Oct 2012 15:49:27 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=133</guid>
		<description><![CDATA[So we are moving to GUI. Microsoft Visual C++ 2010 Express, just like every other software from Microsoft, is having an a-bit-clumsy interface. At first it took me some time to even locate the toolbox and the items I need. The &#8220;button&#8221; items in the menu only show up when &#8220;window form application&#8221; is chosen [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.scad.edu/honlau20/files/2012/10/screen01.jpg"><img class="alignnone size-full wp-image-134" src="http://blog.scad.edu/honlau20/files/2012/10/screen01.jpg" alt="" width="383" height="392" /></a></p>
<p>So we are moving to GUI. Microsoft Visual C++ 2010 Express, just like every other software from Microsoft, is having an a-bit-clumsy interface. At first it took me some time to even locate the toolbox and the items I need. The &#8220;button&#8221; items in the menu only show up when &#8220;window form application&#8221; is chosen as the document type. It is also a requirement to enable the drag-and-drop IDE. But this is not mentioned in any tutorial I have gone through. Before knowing that, I started up with a normal window application, leaving the window form application as a second step to test out. But I gave up exploring the normal window application quickly after 15 minutes I discovered no matter how hard I dig into the user preferences to find the buttons, the toolbox still remains empty!</p>
<p>I started feeling optimistic because I felt like conquering the most ridicules issue I would be facing, and the WYSIWYG editing interface is soooo easy to get along with. Programming a simple tic-tac-toe should not be that difficult. I still remember the day I was learning Netbeans IDE for Java. That was totally a flash through my mind. Programming the buttons is just like programming anywhere else but a lot simpler&#8230; Well that was Java. In window form, the language, even though still C++ as it said, does not look like the C++ we used since the beginning of this quarter. Not apparent COUT and CIN is observed, neither do &#8220;&lt;&lt;&#8221; and &#8220;&gt;&gt;&#8221;. The &#8220;-&gt;&#8221; symbol and everything else look just like alien language. C++ is much bigger than I thought.</p>
<p>Surviving form this kind of uncertainty did not take me that long. The main challenge is actually parsing values in between the classes and functions. The window form is a template or framework pre-written with classes and stitched together. It is the same as Objective-C and iOS programming I am recently investigating. But in this stranger language, even declaration and assigning a variable become nightmare. All kinds of scary errors showed up! Wrong place to place the declaration, wrong place to assign the value, wrong type to pass, wrong syntax, not allowed type&#8230; So discouraging!</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/screen021.jpg"><img class="alignnone size-medium wp-image-139" src="http://blog.scad.edu/honlau20/files/2012/10/screen021-300x178.jpg" alt="" width="300" height="178" /></a></p>
<p>After many tests, failure, tutorial has gone through, most problems are solved. I can now assign the text in a textbox with int data with a convertToString function (finally!). The variables need to be declared here (above image) in order to make them usable by the form, function and event handlers. This is quite common. However, an array cannot be declared here. It said &#8220;only static data members can be initialized inside a ref class or value type&#8221;. This means it is not supported. What?? This might be common sense to programmer, but it seems non-sense to me, and I had searched for half an hour on how to declare and array, which used to be like this: char myChar[10]; It allows me to declare it in the main of the form. But if I need to call it in a function, it is undeclared.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/screen042.jpg"><img class="alignnone size-medium wp-image-141" src="http://blog.scad.edu/honlau20/files/2012/10/screen042-300x211.jpg" alt="" width="300" height="211" /></a><a href="http://blog.scad.edu/honlau20/files/2012/10/screen051.jpg"><img class="alignnone size-medium wp-image-142" src="http://blog.scad.edu/honlau20/files/2012/10/screen051-300x60.jpg" alt="" width="300" height="60" /></a></p>
<p>This is how it looks like at the stage I am about to implement the game logic with an array. Of course I can make a tic tac toe without using any array, but repetitive work is not my favor.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/screen031.jpg"><img class="alignnone size-medium wp-image-143" src="http://blog.scad.edu/honlau20/files/2012/10/screen031-300x295.jpg" alt="" width="300" height="295" /></a></p>
<p>I started to think (because searching for solution seems like endless!). I need to make good use of tools in my hand to make a playable game with GUI. This should be the task, instead of trying to solve pointless issue I am facing in pure programming. I changed my game to Tamagochi &#8212; another flash in my mind.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/20/133/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rockman X DEMO!</title>
		<link>http://blog.scad.edu/honlau20/2012/10/12/rockman-x-demo/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/12/rockman-x-demo/#comments</comments>
		<pubDate>Fri, 12 Oct 2012 04:16:03 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=114</guid>
		<description><![CDATA[My assignment 04 is a PS1 game. I always want to challenge it to the limit you know. At first I thought of making the Tekken and demonstrate the combo system with 3D characters&#8230; Well, that may be too harsh. I decided to make this assignment as a summery of my last 3 game. A [...]]]></description>
				<content:encoded><![CDATA[<p>My assignment 04 is a PS1 game. I always want to challenge it to the limit you know. At first I thought of making the Tekken and demonstrate the combo system with 3D characters&#8230; Well, that may be too harsh. I decided to make this assignment as a summery of my last 3 game. A game which I can make use of the logic I created for previous assignment. And as I am a big fan of Rockman (aka Megaman), Rockman X is the choice for this time!</p>
<p>As usual, I was quite ambitious at first. Here is the plan:<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/20121011_210446.jpg"><img class="alignnone size-medium wp-image-115" src="http://blog.scad.edu/honlau20/files/2012/10/20121011_210446-238x300.jpg" alt="" width="238" height="300" /></a></p>
<p>I intended to skip the fancy costume of the sprites and focus on the action and mechanism of Rockman X: to defeat a boss, get the weapon, and use the new weapon to tackle the weak point of the other boss.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/01.jpg"><img class="alignnone size-medium wp-image-116" src="http://blog.scad.edu/honlau20/files/2012/10/01-300x241.jpg" alt="" width="300" height="241" /></a></p>
<p>I learned from the experience when I was working on Bomberman and Lemmings and borrowed logic from there. The character listen to the variable returned from the stage to detemine which side rockman is facing. And as this is a side scrolling game, the movement is handled also in the stage.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/00.jpg"><img class="alignnone size-medium wp-image-117" src="http://blog.scad.edu/honlau20/files/2012/10/00-170x300.jpg" alt="" width="170" height="300" /></a><br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/02.jpg"><img class="alignnone size-medium wp-image-118" src="http://blog.scad.edu/honlau20/files/2012/10/02-300x258.jpg" alt="" width="300" height="258" /></a></p>
<p>The blocks of the ground repeatedly mount themselves onto a globle stage coordinate. The keyboard input controls the coordinate. Rockman&#8217;s position is always fixed.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/03.jpg"><img class="alignnone size-medium wp-image-119" src="http://blog.scad.edu/honlau20/files/2012/10/03-300x253.jpg" alt="" width="300" height="253" /></a></p>
<p>Charging and shooting are troublesome. If Scratch needs to change or manipulate several variables at once, there will be trouble and unknown bugs, making the logic dont work somehow.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/06.jpg"><img class="alignnone size-full wp-image-124" src="http://blog.scad.edu/honlau20/files/2012/10/06.jpg" alt="" width="240" height="204" /><br />
</a><a href="http://blog.scad.edu/honlau20/files/2012/10/07.jpg"><img class="alignnone size-full wp-image-125" src="http://blog.scad.edu/honlau20/files/2012/10/07.jpg" alt="" width="205" height="142" /></a><br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/04.jpg"><img class="alignnone size-medium wp-image-120" src="http://blog.scad.edu/honlau20/files/2012/10/04-134x300.jpg" alt="" width="134" height="300" /></a><br />
The outcome is not looking bad even I skipped the animation of the character. But I did not make it to stage 2 and so on, because that may be too much for a demo.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/08.jpg"><img class="alignnone size-medium wp-image-121" src="http://blog.scad.edu/honlau20/files/2012/10/08-300x242.jpg" alt="" width="300" height="242" /></a><br />
Player can still move the cursor. But when he presses confirm, this will show up lol.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/09.jpg"><img class="alignnone size-medium wp-image-122" src="http://blog.scad.edu/honlau20/files/2012/10/09-300x239.jpg" alt="" width="300" height="239" /></a></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/12/rockman-x-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lemmings&#8217; Out!</title>
		<link>http://blog.scad.edu/honlau20/2012/10/05/lemmings-out/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/05/lemmings-out/#comments</comments>
		<pubDate>Fri, 05 Oct 2012 14:11:24 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=90</guid>
		<description><![CDATA[The functions work perfectly as planned after slight fine tuning. The sound and sprites also working great. The lemmings will fall from the gate one by one after a nice &#8220;Let&#8217;s Go!&#8221; sound. If the game is played properly: player guides the lemmings with appropriate tools, they will get into the goal with a happy [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.scad.edu/honlau20/files/2012/10/screen02.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen02.jpg" alt="" width="498" height="830" class="alignnone size-full wp-image-91" /></a><br />
The functions work perfectly as planned after slight fine tuning. The sound and sprites also working great. The lemmings will fall from the gate one by one after a nice &#8220;Let&#8217;s Go!&#8221; sound. If the game is played properly: player guides the lemmings with appropriate tools, they will get into the goal with a happy &#8220;yip-pee&#8221; sound. If everything goes fine, the block and explode function are not necessary for this demo stage, they are just for fun.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/screen03.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen03-300x277.jpg" alt="" width="300" height="277" class="alignnone size-medium wp-image-95" /></a><br />
This is how it looks like in a lemming. The left half handles the walk cycle and collision detection for walking and falling. Actually it works perfectly fine for one lemming. It can turn back when it hit a wall. But at the end after everything are done and the lemmings are duplicated, they cannot walk pass each other: they will just block each other. I know exactly what went wrong in the block. But I afraid if I attempt to change it the whole thing would not work as it should. Well&#8230; If they walk straight to the goal, it is just a minor FEATURE! lol </p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/screen07.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen07-300x234.jpg" alt="" width="300" height="234" class="alignnone size-medium wp-image-97" /></a><br />
This is how a lemming digs. The magic happens within a tiny black sprite placed in front of the selected lemming. When it touch any wall, pen is down and draw with the background color. And as it is not touching the wall any more, pen is up. With this mechanism, an organic fake tunnel is created. I believe the original game works similarly. No wonder why the background color always remains the same! Oh. But for scratch, the pen always paint at the bottom layer in front of the stage layer. If the walls are not on the stage layer but as separate sprites, the pen has no way to cover them up. It took me more than one hour to figure out why the pen should be working but did not seem like so. This restrict heavily the freedom of me creating the stage.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/screen041.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen041-260x300.jpg" alt="" width="260" height="300" class="alignnone size-medium wp-image-98" /></a></p>
<p>The stair building works similarly, but the pen down is replaced by stamp utility.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/screen08.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen08-300x240.jpg" alt="" width="300" height="240" class="alignnone size-medium wp-image-99" /></a><a href="http://blog.scad.edu/honlau20/files/2012/10/screen05.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen05-300x273.jpg" alt="" width="300" height="273" class="alignnone size-medium wp-image-100" /></a></p>
<p>For some reason sometime the countdown timer for the exploding lemming does not reset properly. Should be the clumsy execution of Scratch makes it happen.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/screen09.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen09.jpg" alt="" width="242" height="214" class="alignnone size-full wp-image-101" /></a><br />
But again this is another minor FEATURE.</p>
<p>I need to emphasize here. The graphic and sound really shape the environment and the feel of the game. But I personally do not favor this type of repetitive work in this programming class, and I think this is totally not the point for the assignment.<br />
<a href="http://blog.scad.edu/honlau20/files/2012/10/screen06.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/screen06-85x300.jpg" alt="" width="85" height="300" class="alignnone size-medium wp-image-103" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/05/lemmings-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plan and structure for Lemmings!</title>
		<link>http://blog.scad.edu/honlau20/2012/10/05/plan-and-structure-for-lemmings/</link>
		<comments>http://blog.scad.edu/honlau20/2012/10/05/plan-and-structure-for-lemmings/#comments</comments>
		<pubDate>Fri, 05 Oct 2012 12:37:41 +0000</pubDate>
		<dc:creator>Henry Lau Game Developer</dc:creator>
				<category><![CDATA[C++ class]]></category>

		<guid isPermaLink="false">http://blog.scad.edu/honlau20/?p=86</guid>
		<description><![CDATA[Thanks the test I have done earlier, I do not need much planning this time. I just need to determine how big the game gonna be &#8211; mainly time management and scope issue. For this time, I will make ten lemmings with 4 functions &#8211; enough to demonstrate the flow of a basic stage. Each [...]]]></description>
				<content:encoded><![CDATA[<p>Thanks the test I have done earlier, I do not need much planning this time. I just need to determine how big the game gonna be &#8211; mainly time management and scope issue. For this time, I will make ten lemmings with 4 functions &#8211; enough to demonstrate the flow of a basic stage. Each lemming can block (turn into a barricade), dig horizontally, build a staircase and self explode. With the sprite and music in hand, hopefully I can deliver a game plays like, looks like and sounds like Lemmings!.</p>
<p><a href="http://blog.scad.edu/honlau20/files/2012/10/plan01.jpg"><img src="http://blog.scad.edu/honlau20/files/2012/10/plan01-224x300.jpg" alt="" width="224" height="300" class="alignnone size-medium wp-image-87" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scad.edu/honlau20/2012/10/05/plan-and-structure-for-lemmings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
