<?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>Jawad.pk &#187; game development</title>
	<atom:link href="http://jawad.pk/blog/tag/game-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://jawad.pk/blog</link>
	<description>WEB 2.0 / RIAs Expert.</description>
	<lastBuildDate>Tue, 06 Sep 2011 12:43:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Game development using Flash.</title>
		<link>http://jawad.pk/blog/2008/06/29/game-development-using-flash/</link>
		<comments>http://jawad.pk/blog/2008/06/29/game-development-using-flash/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 18:12:21 +0000</pubDate>
		<dc:creator>Jawad Khan</dc:creator>
				<category><![CDATA[Flash Actionscript]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flash games]]></category>
		<category><![CDATA[flash tutorial]]></category>
		<category><![CDATA[game development]]></category>

		<guid isPermaLink="false">http://itsjawad.wordpress.com/?p=5</guid>
		<description><![CDATA[Game development using Flash. hi readers, am writing this blog entry for those flash developers who want to get their hands into flash game development. I will use AS2.0 syntax for the examples. When I have to learn something then code snippets really help. So I will keep writing those sample codes, you can copy [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Game development using Flash.</strong></p>
<p>hi readers, am writing this blog entry for those flash developers who want to get their hands into flash game development. I will use AS2.0 syntax for the examples. When I have to learn something then code snippets really help. So I will keep writing those sample codes, you can copy / paste those in your Flash IDE and instantly experiment on them.<br />
<strong>Basic Maths</strong><br />
First of all, we need to learn basic Maths, I will not go deep into mathematics, so here is the guideline for basic maths<br />
-&gt; Learning basic geometry and basic coordinate system.<br />
-&gt; Learning basic trignometry,Learning sines, cosines and tangents and learning how to apply them.<br />
for instance, if you are given two points (x1, y1) and (x2,y2) on the plane, you should be able to findout the angle forming b/w those points w.r.t normal.</p>
<p><strong>Differences b/w Flash and cartesian coordinate system:</strong><br />
we need to clear out few differences between standard rules and flash rules. We are aware of Cartesian coordinate system, in which x represents horizontal axis and y represents vertical axis and the center point is (x=0,y=0). But in flash the point (0,0) lies at the top left corner of the stage and contrary to cartesian coordinate system the value of y increases as we go down.<br />
<strong>Getting position of the object:</strong><br />
We can retrieve and set the x and y values for any movieclip using movieclip&#8217;s class properties _x and _y.<br />
for instance:<br />
I can create a movieclip using createEmptyMovieClip method<br />
var container:MovieClip = this.createEmptyMovieClip(&#8220;container&#8221;, this.getNextHighestDepth());<br />
// then I create a textfield inside t he newly created movieclip.<br />
var label:TextField = container.createTextField(&#8220;label&#8221;, 1, 0, 0, 150, 20);<br />
label.text = &#8220;Hi boy&#8221;;</p>
<p>Now a movieclip &#8216;container&#8217; has been created on the stage and now we can get its x and y values. By default it&#8217;s x and y values are 0,0. You can confirm this using famous trace command.<br />
trace(container._x);<br />
trace(container._y);<br />
<strong>object movement and user interactivity</strong><br />
If you execute this code, you will see &#8220;hi boy&#8221; written at top left of the stage.<br />
Now you can easily change these values as well. Moreover if u want your movieclip &#8220;hi boy&#8221; to constantly change its position, you can use event &#8220;enterframe&#8221; like following:<br />
this.onEnterFrame=function()<br />
{<br />
container._x++;<br />
if(container._x &gt; 500)<br />
{<br />
container._x = 0;<br />
}<br />
}</p>
<p>This will keep movieclip container in a motion at x-axis. I put a condition cz it was neccessary otherwise container movieclip would have disappeared and left the stage for ever.<br />
Now instead putting textfield in the container object you can draw any shape or object and move it.<br />
In games, user interaction is must. You put user interactivity using various keyboard and mouse events. A simple key event can be used as follows:<br />
if (Key.isDown(Key.RIGHT)) {<br />
container._x++;<br />
}<br />
In the above example instead moving the object constantly, we are moving it whenever user presses &#8216;right&#8217; arrow key.<br />
Now it was the very basics of flash coordinates, object movements and user interactivity. stay tunned for the next releases.</p>
]]></content:encoded>
			<wfw:commentRss>http://jawad.pk/blog/2008/06/29/game-development-using-flash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

