<?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>Yuan Works Development Blog &#187; Little Ninja</title>
	<atom:link href="http://dev.yuanworks.com/category/little-ninja/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.yuanworks.com</link>
	<description>Video game development, tutorials, design, and news</description>
	<lastBuildDate>Mon, 01 Mar 2010 05:55:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Terrains and Tilesets!</title>
		<link>http://dev.yuanworks.com/2009/03/09/terrains-and-tilesets/</link>
		<comments>http://dev.yuanworks.com/2009/03/09/terrains-and-tilesets/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 02:04:59 +0000</pubDate>
		<dc:creator>Yuan-Hsi</dc:creator>
				<category><![CDATA[Little Ninja]]></category>
		<category><![CDATA[Sprite]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=106</guid>
		<description><![CDATA[Now that we understand how tiles work basically, I’ll start working on some tilesets. Just because a game is tile-based doesn’t mean it has to look blocky or repetitive. It is possible to achieve a natural and always fresh appearance by mastering some of the tiles’ features.

In the last post I started some of the [...]]]></description>
			<content:encoded><![CDATA[<p>Now that we understand how tiles work basically, I’ll start working on some tilesets. Just because a game is tile-based doesn’t mean it has to look blocky or repetitive. It is possible to achieve a natural and always fresh appearance by mastering some of the tiles’ features.</p>
<p><img class="aligncenter" title="Little Ninja Sprite grass terrain" src="http://www.wind-water.net/images/blog/littleninja/20090306_grass_terrain.jpg" alt="" width="192" height="138" /></p>
<p>In the last post I started some of the rocky terrain that will be found in the game. The following tileset is a rather traditional approach to drawing a rocky “square” landscape in a stage:</p>
<p><img class="aligncenter" title="Rock tiles" src="http://www.wind-water.net/images/blog/littleninja/20090306_tiles.jpg" alt="" width="190" height="150" /></p>
<p><img class="aligncenter" title="Repeated tiles" src="http://www.wind-water.net/images/blog/littleninja/20090306_repeated_tiles.jpg" alt="" width="190" height="150" /></p>
<p>If you look closely, you will notice that some of the tiles repeat themselves periodically. This helps the game save memory and at the same time creates a very comfortable “tile loop”. As you can see, those two lines of tiles are exactly the same.</p>
<p><img class="aligncenter" title="Rock terrain tileset" src="http://www.wind-water.net/images/blog/littleninja/20090306_rock_terrain.jpg" alt="" width="196" height="178" /></p>
<p>The trick is making them connect smoothly. To give even further variety, many tiles can be replaced with different looping tiles which serve as matching pieces. They can also be combined differently to avoid a constant look! For instance, we can edit some of the tiles to make a secret entrance more obvious to an observing player without compromising the look of the game.</p>
<p><img class="aligncenter" title="Tile edits" src="http://www.wind-water.net/images/blog/littleninja/20090306_tile_editing.jpg" alt="" width="400" height="150" /></p>
<p>By making nice-looking and flexible tilesets with many unique features, we can make terrain that obeys all the classic video game rules and limitations, but still manages to breathe life to the different locales of the game.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2009/03/09/terrains-and-tilesets/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Working with tiles!</title>
		<link>http://dev.yuanworks.com/2009/01/19/working-with-tiles/</link>
		<comments>http://dev.yuanworks.com/2009/01/19/working-with-tiles/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 19:10:56 +0000</pubDate>
		<dc:creator>Yuan-Hsi</dc:creator>
				<category><![CDATA[Little Ninja]]></category>
		<category><![CDATA[Sprite]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=72</guid>
		<description><![CDATA[Happy New Year, everyone! Today I’ll work with on a looping tileset.
The screen in a traditional 2D video game is generally divided into smaller pieces called tiles. These tiles are often 16&#215;16 pixels, although other sizes also exist. Here’s an example:

Familiar, isn’t it? Many Famicom/NES games looked like that. In this image the tiles are [...]]]></description>
			<content:encoded><![CDATA[<p>Happy New Year, everyone! Today I’ll work with on a looping tileset.</p>
<p>The screen in a traditional 2D video game is generally divided into smaller pieces called tiles. These tiles are often 16&#215;16 pixels, although other sizes also exist. Here’s an example:</p>
<p><img class="aligncenter" title="Simple Traditional 2D Tiles platform game" src="http://www.wind-water.net/images/blog/littleninja/20090106_tiles.jpg" alt="" width="192" height="128" /></p>
<p>Familiar, isn’t it? Many Famicom/NES games looked like that. In this image the tiles are pretty obvious, but there are several tricks to make them less apparent. One of them is creating fluid loops where it is hard to tell where the tiles join. Consider the following rock tileset I made for the game:</p>
<p><img class="aligncenter" title="Rock tileset spriteart" src="http://www.wind-water.net/images/blog/littleninja/20090106_tiles_separated.jpg" alt="" width="134" height="66" /></p>
<p><img class="aligncenter" title="Rock tileset sprite art" src="http://www.wind-water.net/images/blog/littleninja/20090106_tiles_joint.jpg" alt="" width="128" height="64" /></p>
<p>When I join them together it is very difficult to tell that they are tiles, and not a continuous drawing:</p>
<p style="text-align: center;"><img class="aligncenter" title="Mozaic tileset sprite art" src="http://www.wind-water.net/images/blog/littleninja/20090106_tilesets_joint.jpg" alt="" width="256" height="64" /></p>
<p>See? This makes the individual tiles much harder for the eye to spot. It also gives a natural feel to the game, instead of a blocky checkered look. You can even make a nice cycle with just one tile. Practice and a little experimentation is all you need.</p>
<p>Something that also helps camouflage the tile-look is giving a little depth to the tiles. For instance, I can draw the top of the rock to make it look like it isn’t absolutely flat:</p>
<p><img class="aligncenter" title="Tiles top rock" src="http://www.wind-water.net/images/blog/littleninja/20090106_tiles_separated_top.jpg" alt="" width="134" height="32" /></p>
<p><img class="aligncenter" title="Tiles top rock" src="http://www.wind-water.net/images/blog/littleninja/20090106_tiles_joint_top.jpg" alt="" width="128" height="96" /></p>
<p>Of course, these tiles are for cosmetic purposes only. Ryuuhi cannot walk on top of them. They only serve give the illusion of depth. This way we respect the engine but cheat a little bit visually.</p>
<p><img class="aligncenter" title="Ryuuhi Little Ninja Rock tiles sprite art" src="http://www.wind-water.net/images/blog/littleninja/20090106_tiles_composite.jpg" alt="" width="256" height="144" /></p>
<p>As a result, we get a flexible, natural looking tileset that matches the style of the game without compromising the elemental engine and saving memory. It is also a good idea to take on or two tiles and make some kind of landmark, or special feature that will not only make a certain part of the map unique, it will also help a player recognize where they are. But more on that later!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2009/01/19/working-with-tiles/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Little Ninja Platform Engine: Running and sliding</title>
		<link>http://dev.yuanworks.com/2009/01/06/little-ninja-platform-engine-running-and-sliding/</link>
		<comments>http://dev.yuanworks.com/2009/01/06/little-ninja-platform-engine-running-and-sliding/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 02:42:49 +0000</pubDate>
		<dc:creator>Yuan-Hao</dc:creator>
				<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Little Ninja]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=60</guid>
		<description><![CDATA[Hellollo! Happy New Year everyone!
If you remember in our previous posts, I first defined the different actions states that the Ninja would have. First Little Ninja , and later he . So, what&#8217;s left?
Running
Running is crucial in most fast-pased action games, and fairly easy to program. Basically, when the users taps the same direction twice [...]]]></description>
			<content:encoded><![CDATA[<p>Hellollo! Happy New Year everyone!</p>
<p>If you remember in our previous posts, I first defined the different actions states that the Ninja would have. First Little Ninja <a href="http://dev.yuanworks.com/2008/11/30/into-the-platform-game-engine/">walked and jumped</a>, and later he <a href="http://dev.yuanworks.com/2008/12/11/into-the-platform-game-engine-part-2/">double-jumped, hanged on walls, and walked on cliffs</a>. So, what&#8217;s left?</p>
<h2>Running</h2>
<p>Running is crucial in most fast-pased action games, and fairly easy to program. Basically, when the users taps the same direction twice and holds the button, the character will go from <strong>WALK -&gt; RUN</strong>, which is essentially the same as walking except it&#8217;s a different animation, and the <em>moves faster</em> (x * 2, or twice is fast in our case):</p>
<p style="text-align: center;"><img class="aligncenter" src="http://www.wind-water.net/images/blog/littleninja/20090106_run.gif" alt="Little Ninja running" width="320" height="240" /></p>
<p>If you watch carefully, jumping while running allows the Ninja to jump farther (again, twice as far as opposed to the normal jump), and if you hold the same direction he will keep on running after jumping. Another detail is that, if the Ninja runs for a little while and stops, instead of going from <strong>RUN -&gt; WALK</strong>, his transition will be<strong> RUN -&gt; BREAK -&gt; WALK</strong>. Did you notice it? This small details polish the platform engine and will allow the Ninja to move swifter and smoother. He&#8217;s a stealth Ninja after all!</p>
<h2>Ducking and sliding</h2>
<p>Before thinking about sliding (dashing), for the last 30 years, most 2D platform games slide by holding the <strong>JUMP </strong>key while you&#8217;re holding <strong>DOWN</strong> — or ducking. Ducking was one of the states that I should have programmed firsthand, but since it had no particular use until now, I decided not to do it. You reap what you sow they say!</p>
<p>Anyway, life lesson aside, ducking is fairly simple: the character will start the <strong>DUCK </strong>animation and reach the <strong>DUCK </strong>state while you&#8217;re holding the <strong>DOWN </strong>key, but if you release it will start to un-<strong>DUCK </strong><em>(aka: stand up) </em>and reach the <strong>IDLE</strong> animation.</p>
<p>Anyway, while Ninja·kun is ducking, pressing the <strong>JUMP</strong> key will allow him to <strong>SLIDE,</strong> useful for sneaking in small places, squishing wild frogs, etc. Take a look:</p>
<p><img class="aligncenter" src="http://www.wind-water.net/images/blog/littleninja/20090106_dash.gif" alt="" width="320" height="240" /></p>
<p>As you can see, Yuan decided that a simple Megaman 3 sliding &#8220;animation&#8221; was not enough, and decided to create a very funny animation that I thought would never work. Worked like a charm to my surprise. Anyway, eventually the Ninja will be able to slide while running and do some other fancy moves, but for now, enjoy the new video with all the new Ninja features:</p>
<p><object type="application/x-shockwave-flash" width="320" height="258">
<param name="movie" value="http://www.wind-water.net/images/blog/littleninja/20090106_run_slide.swf" />
<embed type="application/x-shockwave-flash" width="320" height="258" src="http://www.wind-water.net/images/blog/littleninja/20090106_run_slide.swf" >
</object>
</p>
<p>That&#8217;s it for today, hope you enjoy it and don&#8217;t forget to <a href="http://feeds.feedburner.com/YuanWorks">subscribe</a> to our content and follow our progress closely!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2009/01/06/little-ninja-platform-engine-running-and-sliding/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Making the stage art!</title>
		<link>http://dev.yuanworks.com/2008/12/22/making-the-stage-art/</link>
		<comments>http://dev.yuanworks.com/2008/12/22/making-the-stage-art/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 02:47:40 +0000</pubDate>
		<dc:creator>Yuan-Hsi</dc:creator>
				<category><![CDATA[Little Ninja]]></category>
		<category><![CDATA[Sprite]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=55</guid>
		<description><![CDATA[In a normal traditional platform game, we’ll need some pretty tiles that cycle without giving too much hint that they are tiles. This game however, aims to capture the natural organic feel of the environment, so it will have many unique tilesets (that is, there will be many tiles which are only used once). Games [...]]]></description>
			<content:encoded><![CDATA[<p>In a normal traditional platform game, we’ll need some pretty tiles that cycle without giving too much hint that they are tiles. This game however, aims to capture the natural organic feel of the environment, so it will have many unique tilesets (that is, there will be many tiles which are only used once). Games that feature this kind of tilesets include the Metal Slug series, as well as the arenas for most modern fighters.</p>
<p><img class="aligncenter" title="Little Ninja scenery" src="http://www.wind-water.net/images/blog/20081222_example_screenshot.jpg" alt="" width="250" height="178" /></p>
<p>Unfortunately, this approach requires a lot of observation and time to draw. For instance, this tree branch was “constructed” very much like a real branch. It has detailed individual leaves and is irregular and full of accidents. This gives it a much more organic feel.</p>
<p style="text-align: center;"><img class="aligncenter" title="Little Ninja trees and branch pixel art" src="http://www.wind-water.net/images/blog/20081222_branch_construction.jpg" alt="" width="666" height="102" /></p>
<p>Notice how it almost looks like the branch actually grows in the construction. The same is applied to the rock patterns that I’ve been drawing for the game. In nature, they don’t shape up chaotically, but rather in very complex ways, and you’d need advanced mathematics to calculate them. This actually means you have a lot of freedom to draw freehand and imagine the geometry any way you want because nobody will know the difference, but remember to keep the light source consistent!</p>
<p><img class="aligncenter" title="Little Ninja rock pixel art" src="http://www.wind-water.net/images/blog/20081222_rock_construction.jpg" alt="" width="416" height="102" /><br />
In normal tile-based games these details are usually stylized into a generic shape, giving it a more anime look, for instance the trees in 2D Zelda games. Here’s a tree I worked on for a former project. The advantage is that it is easily recyclable and fits perfectly into any 16&#215;16 tileset, making it very comfortable to implement into map design.</p>
<p><img class="aligncenter" title="2D Zelda-like tile tree" src="http://www.wind-water.net/images/blog/20081222_stylized_tree.jpg" alt="" width="160" height="160" /><br />
This game will actually be a combination of both, but there will be many visual treats to make every single surrounding unique.<br />
Well, that’s it for today. Merry Christmas to you all!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2008/12/22/making-the-stage-art/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Into the Platform Game Engine (Part 2)</title>
		<link>http://dev.yuanworks.com/2008/12/11/into-the-platform-game-engine-part-2/</link>
		<comments>http://dev.yuanworks.com/2008/12/11/into-the-platform-game-engine-part-2/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 06:42:47 +0000</pubDate>
		<dc:creator>Yuan-Hao</dc:creator>
				<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Little Ninja]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=47</guid>
		<description><![CDATA[Hi everyone!
Last time we saw , and I promised to make him walk in slopes and hang in walls (after all, we&#8217;re talking about Little Ninja™ here). Well then it&#8217;s time to learn about Little Ninja&#8217;s new moves!
Walking on slopes (terrain angles)
The first thing I&#8217;ll solve today is having the Ninja walk on different . [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone!</p>
<p>Last time we saw <a href="http://dev.yuanworks.com/2008/11/30/into-the-platform-game-engine/">Little Ninja running and jumping</a>, and I promised to make him walk in slopes and hang in walls (after all, we&#8217;re talking about <em>Little Ninja™</em> here). Well then it&#8217;s time to learn about Little Ninja&#8217;s new moves!</p>
<h2>Walking on slopes (terrain angles)</h2>
<p>The first thing I&#8217;ll solve today is having the Ninja walk on different <a href="http://dev.yuanworks.com/2008/11/19/time-to-build-the-map-editor/">terrain angles</a>. As of now, there are three terrain types if you remember, but Mr. Ninja can only walk on two of them as for now:</p>
<p><img class="aligncenter" title="Platform game different terrain angles" src="http://www.wind-water.net/images/blog/littleninja/20081210_terrain_angles.jpg" alt="" width="468" height="148" /></p>
<p>When the Ninja walks on flat terrain, his <em>X position</em> changes (left and right). Well, what happens when he walks on slopes? His <em>Y position</em> changes, too (up and down)! In the 45° slope, for every X+1 pixel he moves Y+1 pixels, while on the ~26° slope, for every X+1 pixel, he moves Y+½, (but remember that pixels can&#8217;t be divided).</p>
<p>An important aspect is knowing when his Y position changes. For this, we have to use the sprite&#8217;s <strong>CENTER </strong>position. Whenever the Ninja jumps on a slope his Y position must be calculated too based on his X.</p>
<p><img class="aligncenter" title="Sprite center position" src="http://www.wind-water.net/images/blog/littleninja/20081210_sprite_center.jpg" alt="" width="192" height="158" /></p>
<h2>New Ninja States: Wall Hang and Double Jump (somersault flip)</h2>
<p>A Ninja that can&#8217;t hang on walls or randomly somersault in the air defying all physics laws is definitely not a skilled one!</p>
<p><img class="aligncenter" title="Little Ninja hanging on walls" src="http://www.wind-water.net/images/blog/littleninja/20081210_ninja_hang.jpg" alt="" width="422" height="178" /></p>
<p>Anyway, wall hanging was pretty simple to do: Basically, when the Ninja hits a wall and you hold the direction on the d-pad (right in that case), he&#8217;ll hang on the wall and slide.</p>
<p>As for the double-jump, after performing a normal jump, jumping again while hanging in mid-air makes Little Ninja perform what is normally called a &#8220;double jump&#8221;, allowing him to move a little higher and a little further too!</p>
<p><img class="aligncenter" title="Little Ninja double jump" src="http://www.wind-water.net/images/blog/littleninja/20081210_double_jump.jpg" alt="" width="254" height="272" /></p>
<p>Well, besides these two new states and slopes, I also added background scrolling, which I&#8217;ll try to explain more detailed later on. And as always, here&#8217;s a video (well GIF actually) of Little Ninja in action!</p>
<p><img class="aligncenter" title="Little Ninja platform wall hang and double jump" src="http://www.wind-water.net/images/blog/littleninja/20081210_doublejump_wallhang.gif" alt="" width="320" height="240" /></p>
<p>It&#8217;s starting to feel very versatile with the new moves and I&#8217;m sure that as soon as he runs and slides things are going to get even more exciting. Stay tuned for more Ninja action!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2008/12/11/into-the-platform-game-engine-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Animating the Little Ninja!</title>
		<link>http://dev.yuanworks.com/2008/12/04/animating-the-little-ninja/</link>
		<comments>http://dev.yuanworks.com/2008/12/04/animating-the-little-ninja/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 21:03:16 +0000</pubDate>
		<dc:creator>Yuan-Hsi</dc:creator>
				<category><![CDATA[Little Ninja]]></category>
		<category><![CDATA[Sprite]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=43</guid>
		<description><![CDATA[I still haven&#8217;t decided on the final look of the character, but I&#8217;ve started sketching the way he will move. Here&#8217;s one of his preliminary animations: the run cycle! Most of Ryuuhi&#8217;s ninja moves aren&#8217;t too realistic, but this particular run cycle is very traditional animation-wise, except for the extra weight put in the hammering [...]]]></description>
			<content:encoded><![CDATA[<p>I still haven&#8217;t decided on the final look of the character, but I&#8217;ve started sketching the way he will move. Here&#8217;s one of his preliminary animations: the run cycle! Most of Ryuuhi&#8217;s ninja moves aren&#8217;t too realistic, but this particular run cycle is very traditional animation-wise, except for the extra weight put in the hammering of his feet.</p>
<p><img class="aligncenter" title="Sprite run frames animation" src="http://www.wind-water.net/images/blog/littleninja/20081204_run_strip_beta.jpg" alt="" width="576" height="32" /></p>
<p>Notice the two frames marked with an arrow. They are extra ugly frames that not only look bad, they don’t let the motion flow correctly/convincingly. Not that 0.05 seconds of screen-time are particularly visible, but we want to make this look as good as possible, don’t we?</p>
<p>Also, when you’re animating something, if you detect/suspect any errors early on, it’s important to correct them right away. Otherwise they will haunt you, turn more difficult to correct later on, or in worst scenario generate even more errors.</p>
<p>I also made a slash animation:</p>
<p><img class="aligncenter" title="Ninja Slash animation frames test" src="http://www.wind-water.net/images/blog/littleninja/20081204_slash_test.jpg" alt="" width="452" height="32" /></p>
<p>This kind of motion is not found in nature or traditional animation. And the way it is animated is exclusive to pixel art. With this kind of “special effects”, you have the freedom to experiment a little, but keep in mind the timing of the movement. Remember that is has to be functional in a game!</p>
<p>I have some more animations, but they’re too long to post here!</p>
<p>But as a bonus, I corrected one of the aforementioned frames while writing this post:</p>
<p><img class="aligncenter" title="Little Ninja corrected run frames" src="http://www.wind-water.net/images/blog/littleninja/20081204_corrected_frame.jpg" alt="" width="128" height="64" /></p>
<p>Looks much better, doesn’t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2008/12/04/animating-the-little-ninja/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Into the Platform Game Engine</title>
		<link>http://dev.yuanworks.com/2008/11/30/into-the-platform-game-engine/</link>
		<comments>http://dev.yuanworks.com/2008/11/30/into-the-platform-game-engine/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 02:09:26 +0000</pubDate>
		<dc:creator>Yuan-Hao</dc:creator>
				<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Little Ninja]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=37</guid>
		<description><![CDATA[Hi everyone,
Today&#8217;s post talks will be about how to design the most basic parts of a platform game engine. On our last post, I finished a simple Map Editor, now it&#8217;s time to put Ninja Stick Figure into action!
Defining the Ninja Action States
Most of you are probably thinking about defining the most basic and generic [...]]]></description>
			<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>Today&#8217;s post talks will be about how to design the most basic parts of a platform game engine. On our last post, I finished a simple <a title="Building a Map Editor" href="http://dev.yuanworks.com/2008/11/19/time-to-build-the-map-editor/">Map Editor</a>, now it&#8217;s time to put Ninja Stick Figure into action!</p>
<h2>Defining the Ninja Action States</h2>
<p>Most of you are probably thinking about defining the most basic and generic objects (EG: the main character, enemies, bullets, items, etc.), but since this game is <em>supposed </em>to be simple, we&#8217;ll jump right into the main character, Ryuuhi, since I&#8217;m more interested in developing the platform engine. For a more complex and bigger project, this definitely wouldn&#8217;t be the best approach.</p>
<p>Anyway, the first thing I have to think about are the different states that our Ninja has:</p>
<p><img class="aligncenter" title="Ninja Action States" src="http://www.wind-water.net/images/blog/littleninja/20081130_ninja_states.jpg" alt="" width="291" height="49" /></p>
<p>Every state is self-explanatory so there&#8217;s not much to explain. Defining how states work is easy, <strong>IDLE</strong> happens when you don&#8217;t press any button, <strong>WALK </strong>when you press Left/Right, <strong>JUMP</strong> when you press the &#8220;Jump&#8221; button, and so on. For now, I won&#8217;t be using the <strong>ATTACK </strong>state since I&#8217;m only interested in how Little Ninja interacts with the terrain, not with other objects. Anyway, it&#8217;s important to associate an animation with each state, as well as a transition between states: for example, the character may go from <strong>IDLE </strong>to <strong>WALK</strong>, but can&#8217;t go directly from <strong>JUMP </strong>to <strong>WALK</strong>. Anyway, this can be done with a simple Enum:</p>
<blockquote>
<pre>enum NinjaAction
{
    NJA_Idle = 0,
    NJA_Walk = 1,
    NJA_Turn = 2,
    NJA_JumpStart = 3,
    NJA_JumpHang = 4,
    NJA_JumpEnd = 5,
}</pre>
</blockquote>
<p>Enums are very simple but work well on cases like this. This way, if I need to define another state or need to change its number for any reason, the rest of the code stays clean. For example, the <strong>IDLE </strong>animation would be <strong>ninjaAnimation[NJA_Idle]</strong>, which is easier to understand compared to <strong>ninjaAnimation[0]</strong>. As for  Jumping, three different states were defined: the part where Ryuuhi ascends (Start), the part where Ryuuhi doesn&#8217;t move and descends (Hang), and the part where he falls (End). In good theory, all states should have a generic outcome when you enter and exit a state, but as I said before, I&#8217;m more focused on game mechanics right now.</p>
<p>Note that Ryuuhi is facing to his <strong>LEFT</strong> on all the images. This means that, besides states, it is important to define the state&#8217;s direction too.</p>
<p><span id="more-37"></span></p>
<h2>Action #1: Walking</h2>
<p>Walking is fairly easy on flat terrains, since it only changes the sprite&#8217;s X coordinate while you hold Left or Right. Just as a note, when you press the opposite direction, the Ninja goes from <strong>Walking -&gt; Turn -&gt; Walking</strong> (opposite direction). It&#8217;s important now to define how he collides against walls, so we need to understand what a collision box is:</p>
<p><img class="aligncenter" title="Sprite frame and collision box" src="http://www.wind-water.net/images/blog/littleninja/20081130_sprite_frame.jpg" alt="" width="336" height="140" /></p>
<p>The <span style="color: #008000;"><strong>Sprite Frame</strong></span> is the actual image that I am drawing on screen, while the<strong> <span style="color: #0000ff;">Collision Box</span></strong> defines how the ninja interacts with the terrain. In this case, it&#8217;s important to understand how the two different boxes differ. It would look really bad if I used the sprite frame as a collision box since Little Ninja would &#8220;bump&#8221; against walls from a faraway distance, which is not what we want:</p>
<p style="text-align: center;"><img class="aligncenter" title="Sprite collision detection against walls" src="http://www.wind-water.net/images/blog/littleninja/20081130_sprite_collision.jpg" alt="" width="286" height="110" /></p>
<p>Now that&#8217;s more like it, right? Basically what we need to do is find out what tile is next to the Ninja, depending on the direction he&#8217;s facing. If said tile is a Solid wall, then it means that he cannot walk. If not, then he can walk through (if you want me to explain a little further let me know).</p>
<p>Anytime you press the Left or Right directions, he changes his state from <strong>IDLE </strong>to <strong>TURN/WALK.</strong> We then ask if he is able to walk in said direction, and if so, his X-coordinate changes.</p>
<h2>Action #2: Jumping</h2>
<p>Jumping is a trickier than walking, since jumping (in reality) is not a linear function because of physics (read: gravity). The jump starts fast, and slow downs towards it peak until is starts to fall:</p>
<p><img class="aligncenter" title="Sprite jump physics" src="http://www.wind-water.net/images/blog/littleninja/20081130_sprite_jump.jpg" alt="" width="182" height="264" /></p>
<p>Applying a real physics formula is possible, but most platform games just use a small number of linear formulas (and so does Little Ninja) since the result is more predictable and it actually looks better. Games usually have an extended hang-time, the &#8220;floating&#8221; feeling and, as you can guess, this the case of Little Ninja too.</p>
<p>Anyway, I recorded a GIF of the actual game running:</p>
<p><img class="aligncenter" title="Little Ninja platform jump and run" src="http://www.wind-water.net/images/blog/littleninja/20081130_run_jump.gif" alt="" width="320" height="240" /></p>
<p>(For those using Internet Explorer, the GIF probably runs a little slow, please use Firefox if possible!)</p>
<p>Anyway, the animation above pretty much wraps up everything I explained and more: I didn&#8217;t get to explain collisions against the floor and falling.</p>
<p>Little Ninja is finally moving and that&#8217;s it for today, next time we&#8217;ll probably see him hanging on the wall and walking on slopes. Hope you enjoy the article!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2008/11/30/into-the-platform-game-engine/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Pretty settings and animation: let’s go!</title>
		<link>http://dev.yuanworks.com/2008/11/25/pretty-settings-and-animation-let%e2%80%99s-go/</link>
		<comments>http://dev.yuanworks.com/2008/11/25/pretty-settings-and-animation-let%e2%80%99s-go/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 16:29:25 +0000</pubDate>
		<dc:creator>Yuan-Hsi</dc:creator>
				<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Little Ninja]]></category>
		<category><![CDATA[Sprite]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=32</guid>
		<description><![CDATA[Okay, this time I have drawn some more natural looking terrain to make the game easy on the eyes. This is how Little Ninja will (hopefully) look like in action!

The game will sport a very japonesque look, featuring a lot of rocks, rivers, waterfalls, exotic trees, and cerulean skies. (Which pretty much renders our “keep [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, this time I have drawn some more natural looking terrain to make the game easy on the eyes. This is how <a href="http://dev.yuanworks.com/2008/11/12/starting-a-new-project-codename-little-ninja/">Little Ninja</a> will (hopefully) look like in action!</p>
<p style="text-align: center;"><img class="alignnone" title="Little Ninja sprite art in action!" src="http://www.wind-water.net/images/blog/littleninja/20081125_screenshot_tv.jpg" alt="" width="260" height="148" /></p>
<p style="text-align: left;">The game will sport a very japonesque look, featuring a lot of rocks, rivers, waterfalls, exotic trees, and cerulean skies. (Which pretty much renders our “keep it simple” useless…)</p>
<p>As for Ryuuhi, I still haven’t fully decided on the final look he will have, but he now has several animations, all running at full 30 fps. I swore I would never animate anything at that rate again after Wind and Water. But oh, well.</p>
<p style="text-align: center;"><img class="aligncenter" title="Ryuuhi Little Ninja sprite frames" src="http://www.wind-water.net/images/blog/littleninja/20081125_ryuuhi_frames.jpg" alt="" width="400" height="80" /></p>
<p style="text-align: center;">
<p>I also made this new tileset so that the engine Hao is making will look prettier, but he hasn’t even used my old new tileset!! Anyway, here it is.</p>
<p style="text-align: center;"><img class="aligncenter" title="Platform Tileset" src="http://www.wind-water.net/images/blog/littleninja/20081125_new_tileset.jpg" alt="" width="240" height="140" /></p>
<p style="text-align: center;">
<p style="text-align: left;">Well, that’s it for today. Tomorrow I’ll keep experimenting with the animation. This project is advancing much faster that I expected, and I had a lot of fun playing with Hao’s preliminary engine!!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2008/11/25/pretty-settings-and-animation-let%e2%80%99s-go/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Time to build the Map Editor!</title>
		<link>http://dev.yuanworks.com/2008/11/19/time-to-build-the-map-editor/</link>
		<comments>http://dev.yuanworks.com/2008/11/19/time-to-build-the-map-editor/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 19:40:10 +0000</pubDate>
		<dc:creator>Yuan-Hao</dc:creator>
				<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Little Ninja]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=16</guid>
		<description><![CDATA[Hi again!
If you remember last time, we were in the process of  defining what was important for Little Ninja&#8217;s new Map Editor. If you haven&#8217;t read the last article, it&#8217;s a good idea to take a look at it since I&#8217;ll be taking off right where I left it  
Map Terrain Design (Part 2)
Last [...]]]></description>
			<content:encoded><![CDATA[<p>Hi again!</p>
<p>If you remember last time, we were in the process of  defining <a href="http://dev.yuanworks.com/2008/11/12/starting-a-new-project-codename-little-ninja/">what was important for Little Ninja&#8217;s new Map Editor</a>. If you haven&#8217;t read the <a href="http://dev.yuanworks.com/2008/11/12/starting-a-new-project-codename-little-ninja/">last article</a>, it&#8217;s a good idea to take a look at it since I&#8217;ll be taking off right where I left it <img src='http://dev.yuanworks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Map Terrain Design (Part 2)</h2>
<p>Last time we were overviewing the different <strong>terrain angles.</strong> After taking a look at my favorite platform-adventure games, I decided to keep three types of angles, remember?</p>
<p style="text-align: center"><img src="http://www.wind-water.net/images/blog/littleninja/20081114_ninja_terrain_angles.jpg" alt="Angles for map editor terrain" width="198" height="110" /></p>
<p>One may think that most platform games have a wider array of possible angles. However, in fact, I came to realize that a great number of games only use the 45° and ~26° inclination — Cave Story or Metroid, for example.</p>
<p>Now that I have chosen the three types of angles, it&#8217;s time to choose the different <strong>terrain directions.</strong> Fortunately, this is a very easy choice as tiles can only be transformed (rotated or flipped) into four different configurations, creating the following set of tiles:</p>
<p style="text-align: center"><img src="http://www.wind-water.net/images/blog/littleninja/20081114_ninja_terrain_dirs.jpg" alt="Map Editor tile transformation" width="326" height="190" /></p>
<p>Now that we have terrain type, angle, direction, we&#8217;re all set to start making our <em>Map Editor™ </em>! Before starting, let&#8217;s do a test-run on our current terrain:</p>
<p style="text-align: center"><img src="http://www.wind-water.net/images/blog/littleninja/20081114_ninja_terrain_test.jpg" alt="Mockup tile map" width="307" height="137" /></p>
<p>As you can see, the combination of tiles allows a quite versatile design, while keeping it &#8220;simple&#8221;. While our Ninja trap does not look too smooth, remember that this is our <strong>mask!</strong> Further addition of foreground tiles will do the trick, believe me (I can&#8217;t wait for Yuan to give me some tiles). Actually, <a href="http://dev.yuanworks.com/2008/11/16/little-ninja-new-sprites-and-tiles/">Yuan has already started drawing the prototype sprite art for Little Ninja</a>.</p>
<p><span id="more-16"></span></p>
<h2>Map Terrain Structure Overview</h2>
<p>So, let&#8217;s review what we have until now: each tile contains information about <strong>direction,</strong> <strong>angle,</strong> and <strong>type</strong> of terrain. From a technical side, I decided to use:</p>
<blockquote><p>2 bits for direction (2 ^ 2 = 4 combinations)<br />
5 bits for angle (2 ^ 5 = 32)<br />
5 bits for terrain type (2 ^ 5 = 32)</p></blockquote>
<p>That gives us a total of 12 bits. In order to fill <strong>2 bytes</strong> (that is, 16 bits), we have 4 bits left: we&#8217;ll use them for special cases. So, what&#8217;s a special case? I don&#8217;t know, and that&#8217;s exactly why I&#8217;m saving those 4bits.</p>
<p>For now, the only important types of terrains are <strong>empty </strong>and <strong>solid </strong>tiles (character collides against them), with all the variation of angles and directions. This is my <em>tile palette </em>for now:</p>
<p style="text-align: center"><img src="http://www.wind-water.net/images/blog/littleninja/20081114_ninja_terrain_tiles.jpg" alt="Map editor tile palette" width="302" height="102" /></p>
<p>Our transparent color is always <strong><span style="color: #ff00ff;">magenta </span></strong>(aka: ugly pink), but from now on I&#8217;m probably not gonna use it because, as the name implies, it <strong>IS </strong>ugly. Anyway, our Map Editor&#8217;s interface is quite simple: a simple editor where you choose the width and height of the map, select a tile from our tile palette, and draw tiles on the actual map! <img src='http://dev.yuanworks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Anyway, the editor is finished (for now) and here&#8217;s a video:</p>
<p><object type="application/x-shockwave-flash" width="479" height="331">
<param name="movie" value="http://www.wind-water.net/images/blog/littleninja/20081114_map_editor.swf" />
<embed type="application/x-shockwave-flash" width="479" height="331" src="http://www.wind-water.net/images/blog/littleninja/20081114_map_editor.swf" >
</object>
</p>
<p>Oh, I also added a grid as well as a <em>foreground grid</em>. Nothing complex but certainly useful. The Save and Open functions are crucial since we need to load the map on the actual game code. It&#8217;s just a simple file with information about each tile, as well as the width and height of the map. I&#8217;ll be using my test.map for the next part.</p>
<p style="text-align: center;"><img class="aligncenter" title="Test Map &amp;amp; Little Ninja" src="http://www.wind-water.net/images/blog/littleninja/20081114_ninja_test_map.jpg" alt="Little Ninja Test Map" width="320" height="224" /></p>
<p>Anyway, that&#8217;s it for today. Next time I&#8217;ll be loading the actual map on the game, and start adding the most basic player controls (walk and run). The current map editor clearly needs a lot more work, but that will come later <img src='http://dev.yuanworks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>What do you think about it? Please let me know if the post was too long or simple, etc., or if I should describe the programing-related issues more clearly. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2008/11/19/time-to-build-the-map-editor/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Little Ninja new Sprites and Tiles!</title>
		<link>http://dev.yuanworks.com/2008/11/16/little-ninja-new-sprites-and-tiles/</link>
		<comments>http://dev.yuanworks.com/2008/11/16/little-ninja-new-sprites-and-tiles/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 18:35:23 +0000</pubDate>
		<dc:creator>Yuan-Hsi</dc:creator>
				<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Little Ninja]]></category>
		<category><![CDATA[Sprite]]></category>

		<guid isPermaLink="false">http://dev.yuanworks.com/?p=21</guid>
		<description><![CDATA[Well, after the Dreamcast release of Wind and Water: Puzzle Battles we had a short two week vacation which was mostly spent playing games.
Back on the drawing board, we decided to make a &#8220;small&#8221; game project which we could handle leisurely. So we chose to expand one of our previous projects, namely &#8220;Little Ninja&#8221; or [...]]]></description>
			<content:encoded><![CDATA[<p>Well, after the Dreamcast release of Wind and Water: Puzzle Battles we had a short two week vacation which was mostly spent playing games.</p>
<p>Back on the drawing board, we decided to make a &#8220;small&#8221; game project which we could handle leisurely. So we chose to expand one of our previous projects, namely &#8220;Little Ninja&#8221; or &#8220;Shounin Ryuuhi&#8221;, a Ninja platformer.</p>
<p>First of all, I took the original main character and did an overhaul so that he would still be small (which is the idea), but versatile to animate. This is the result:</p>
<p style="text-align: center;"><img class="aligncenter" title="Little Ninja sprite art evolution" src="http://www.wind-water.net/images/blog/littleninja/20081115_ryuuhi.jpg" alt="" width="396" height="86" /></p>
<p>I haven&#8217;t decided on the final look yet, but this is probably what I will stick to.</p>
<p style="text-align: center;"><img class="aligncenter" title="Ryuuhi final sprite" src="http://www.wind-water.net/images/blog/littleninja/20081115_ryuuhi_finalish.jpg" alt="" width="84" height="68" /></p>
<p>Also, we decided to make a new &#8220;terrain interactive&#8221; engine, and we chose the following angles for tiles:</p>
<p style="text-align: center;"><img class="aligncenter" title="Better looking map terrain tiles" src="http://www.wind-water.net/images/blog/littleninja/20081115_better_looking_tiles.jpg" alt="" width="294" height="78" /></p>
<p>This is because a 45 degree angle is a perfect one-pixel diagonal line, and the other ones are perfect two-pixel diagonal lines. Any other irregular lines will need too much work to look elegant. This is a preliminary tileset to make the map editor a little easier on the eyes.Instead of just &#8220;pasting&#8221; the character on top of any terrain, we will make him really interact with it. So the little Ninja stands and acts differently depending on the inclination of the plane:</p>
<p style="text-align: center;"><img class="aligncenter" title="Little Ninja terrain interaction sprites" src="http://www.wind-water.net/images/blog/littleninja/20081115_terrain_interaction.jpg" alt="" width="222" height="140" /></p>
<p>Finally, I made this &#8220;Stick Ninja&#8221; to test the animation flow and interaction. His name is Chopsticks the Ninja™. Having so much terrain interaction means a LOT of animation on my part. So there goes our &#8220;simple&#8221; game project&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.yuanworks.com/2008/11/16/little-ninja-new-sprites-and-tiles/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
