<?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>Phillip Napieralski &#187; Flixel</title>
	<atom:link href="http://blog.pnapieralski.com/category/flixel/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pnapieralski.com</link>
	<description>Programmer, Engineer, Researcher.</description>
	<lastBuildDate>Tue, 20 Dec 2011 16:41:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to make a scrolling star field background with Flixel</title>
		<link>http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/</link>
		<comments>http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 07:01:23 +0000</pubDate>
		<dc:creator>Phillip Napieralski</dc:creator>
				<category><![CDATA[Flixel]]></category>
		<category><![CDATA[flixel]]></category>
		<category><![CDATA[shooter]]></category>

		<guid isPermaLink="false">http://blog.pnapieralski.com/?p=58</guid>
		<description><![CDATA[I won't waste your time, here's the source code...]]></description>
			<content:encoded><![CDATA[<p>Here is what it does:</p>
<p><embed src='http://blog.pnapieralski.com/wp-content/uploads/2010/07/Starfielddriver.swf' width=640 height=480></embed></p>
<h2>The Code</h2>
<p>I won&#8217;t waste your time, here&#8217;s the source code.</p>
<pre class="brush: plain; title: ; notranslate">
package {
	import org.flixel.*;

	public class StarField extends FlxObject {
		public static const NUM_STARS:Number = 75;
		private var _stars:FlxGroup;

		/**
		 * @param	ang This is the angle that the starField will be rotating (in degrees)
		 * @param	speedMultiplier
		 */
		override public function StarField(ang:Number = 90, speedMultiplier:Number = 4):void {
			angle = ang;
			_stars = new FlxGroup();

			var radang:Number = angle * Math.PI / 180;
			var cosang:Number = Math.cos(radang);
			var sinang:Number = Math.sin(radang);

			for ( var i:int = 0; i &lt; StarField.NUM_STARS; i++ ) {
				var str:FlxSprite = new FlxSprite(Math.random() * FlxG.width, Math.random() * FlxG.height);
				var vel:Number = Math.random() * -16 * speedMultiplier;

				// change the transparency of the star based on it's velocity
				var transp:uint = (Math.round(16 * (-vel / speedMultiplier) - 1) &lt;&lt; 24);

				str.createGraphic(2, 2, 0x00ffffff | transp);
				str.velocity.x = cosang * vel;
				str.velocity.y = sinang * vel;
				_stars.add(str);
			}
		}

		/**
		 * Rotate the starField
		 * @param	howMuch Input the amount of rotation in degrees
		 */
		public function rotate(howMuch:Number = 1):void {
			angle += howMuch;

			var radang:Number = angle * Math.PI / 180;
			var cosang:Number = Math.cos(radang);
			var sinang:Number = Math.sin(radang);

			for ( var i:int = 0; i &lt; StarField.NUM_STARS; i++ ) {
				var str:FlxSprite = _stars.members[i] as FlxSprite;

				FlxU.rotatePoint(str.velocity.x, str.velocity.y, 0, 0, howMuch, str.velocity);
			}
		}

		override public function update():void {
			_stars.update();

			for (var i:int = 0; i &lt; _stars.members.length; i++) {
				var star:FlxSprite = _stars.members[i] as FlxSprite;
				if (star.x &gt; FlxG.width) {
					star.x = 0;
				} else if (star.x &lt; 0) {
					star.x = FlxG.width;
				}
				if (star.y &gt; FlxG.height) {
					star.y = 0;
				} else if (star.y &lt; 0) {
					star.y = FlxG.height;
				}

			}
		}

		override public function render():void {
			_stars.render();
		}
	}

}
</pre>
<p>Now to use it, simply add the following in one of your states:</p>
<pre class="brush: plain; title: ; notranslate">
private var sf:StarField = new StarField();

// state constructor
override public function StarState():void {
     this.add(sf);
}
</pre>
<p><a href='http://blog.pnapieralski.com/wp-content/uploads/2010/07/src.zip'>Get the star field demo source code</a></p>
<p>I also used this star field class in my FIRST ever flash game. <a href='http://www.kongregate.com/games/pnapieralski/face-defender'>Face Defender</a>.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=How+to+make+a+scrolling+star+field+background+with+Flixel&amp;link=http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/&amp;notes=I%20won%27t%20waste%20your%20time%2C%20here%27s%20the%20source%20code...&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%2524%257Btitle%257D%2B-%2B%2524%257Bshort_link%257D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-digg">
			<a href="http://www.shareaholic.com/api/share/?title=How+to+make+a+scrolling+star+field+background+with+Flixel&amp;link=http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/&amp;notes=I%20won%27t%20waste%20your%20time%2C%20here%27s%20the%20source%20code...&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=3&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=How+to+make+a+scrolling+star+field+background+with+Flixel&amp;link=http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/&amp;notes=I%20won%27t%20waste%20your%20time%2C%20here%27s%20the%20source%20code...&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://www.shareaholic.com/api/share/?title=How+to+make+a+scrolling+star+field+background+with+Flixel&amp;link=http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/&amp;notes=I%20won%27t%20waste%20your%20time%2C%20here%27s%20the%20source%20code...&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=10&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=How+to+make+a+scrolling+star+field+background+with+Flixel&amp;link=http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/&amp;notes=I%20won%27t%20waste%20your%20time%2C%20here%27s%20the%20source%20code...&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=How+to+make+a+scrolling+star+field+background+with+Flixel&amp;link=http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/&amp;notes=I%20won%27t%20waste%20your%20time%2C%20here%27s%20the%20source%20code...&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.pnapieralski.com/flixel/how-to-make-a-scrolling-star-field-background-with-flixel/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Flixel 2.0 Project Template for FlashDevelop</title>
		<link>http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/</link>
		<comments>http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 17:17:09 +0000</pubDate>
		<dc:creator>Phillip Napieralski</dc:creator>
				<category><![CDATA[Flixel]]></category>

		<guid isPermaLink="false">http://blog.pnapieralski.com/?p=45</guid>
		<description><![CDATA[I've been doing a bit of <a href="http://flixel.org/">Flixel</a> (flash game library) programming lately, and to speed up the creation of games I created a Project Template for <a href="http://www.flashdevelop.org/">FlashDevelop</a> that includes a MenuState, PlayState and Preloader. <b><a href='http://blog.pnapieralski.com/wp-content/uploads/2010/06/Flixel2ProjectTemplate.zip'>Download the template</a></b>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a bit of <a href="http://flixel.org/">Flixel</a> (flash game library) programming lately, and to speed up the creation of games I created a Project Template for <a href="http://www.flashdevelop.org/">FlashDevelop</a> that includes a MenuState, PlayState and Preloader. <b><a href='http://blog.pnapieralski.com/wp-content/uploads/2010/06/Flixel2ProjectTemplate.zip'>Download the template</a></b></p>
<h2>How to use it</h2>
<p>I will assume that you already have the Flex 4 SDK already setup for FlashDevelop.</p>
<p>To use the template, simply copy it into the &#8220;projects&#8221; folder in your FlashDevelop installation directory. For me, it was &#8220;C:\Program Files (x86)\FlashDevelop\Projects.&#8221; Then, in FlashDevelop, simply go to Project -> in the toolbar.<a href="http://blog.pnapieralski.com/wp-content/uploads/2010/06/post1.png" rel="shadowbox[sbpost-45];player=img;"></p>
<p><img src="http://blog.pnapieralski.com/wp-content/uploads/2010/06/post1-300x113.png" alt="Project, New Project" title="Project, New Project" width="300" height="113" class="alignnone size-medium wp-image-47" /></a> </p>
<p>Then, there should be an option to create a new Flixel 2.0 project. </p>
<p><a href="http://blog.pnapieralski.com/wp-content/uploads/2010/06/post2-e1275844773290.png" rel="shadowbox[sbpost-45];player=img;"><img src="http://blog.pnapieralski.com/wp-content/uploads/2010/06/post2-e1275844773290.png" alt="New Flixel 2.0 Project" title="New Flixel 2.0 Project" width="300" height="200" class="alignnone size-medium wp-image-48" /></a></p>
<p>That&#8217;s it! The new project will include 4 basic files on top of the flixel library (the current stable release as of today).</p>
<p><a href="http://blog.pnapieralski.com/wp-content/uploads/2010/06/post3.png" rel="shadowbox[sbpost-45];player=img;"><img src="http://blog.pnapieralski.com/wp-content/uploads/2010/06/post3-300x186.png" alt="" title="4 files" width="300" height="186" class="alignnone size-medium wp-image-49" /></a></p>
<h2>Update Flixel version in the template</h2>
<p>To update the version of flixel in the template, go to where you extracted the template originally (mine was in C:\Program Files (x86)\FlashDevelop\Projects\410 Flixel 2.0 Project\). Then, in the &#8220;src&#8221; folder, you will see another folder called &#8220;org.&#8221; Simply overwrite the org folder with the org folder from the latest Flixel distribution. That&#8217;s it!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Flixel+2.0+Project+Template+for+FlashDevelop&amp;link=http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/&amp;notes=I%27ve%20been%20doing%20a%20bit%20of%20Flixel%20%28flash%20game%20library%29%20programming%20lately%2C%20and%20to%20speed%20up%20the%20creation%20of%20games%20I%20created%20a%20Project%20Template%20for%20FlashDevelop%20that%20includes%20a%20MenuState%2C%20PlayState%20and%20Preloader.%20Download%20the%20template&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%2524%257Btitle%257D%2B-%2B%2524%257Bshort_link%257D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-digg">
			<a href="http://www.shareaholic.com/api/share/?title=Flixel+2.0+Project+Template+for+FlashDevelop&amp;link=http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/&amp;notes=I%27ve%20been%20doing%20a%20bit%20of%20Flixel%20%28flash%20game%20library%29%20programming%20lately%2C%20and%20to%20speed%20up%20the%20creation%20of%20games%20I%20created%20a%20Project%20Template%20for%20FlashDevelop%20that%20includes%20a%20MenuState%2C%20PlayState%20and%20Preloader.%20Download%20the%20template&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=3&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Flixel+2.0+Project+Template+for+FlashDevelop&amp;link=http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/&amp;notes=I%27ve%20been%20doing%20a%20bit%20of%20Flixel%20%28flash%20game%20library%29%20programming%20lately%2C%20and%20to%20speed%20up%20the%20creation%20of%20games%20I%20created%20a%20Project%20Template%20for%20FlashDevelop%20that%20includes%20a%20MenuState%2C%20PlayState%20and%20Preloader.%20Download%20the%20template&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://www.shareaholic.com/api/share/?title=Flixel+2.0+Project+Template+for+FlashDevelop&amp;link=http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/&amp;notes=I%27ve%20been%20doing%20a%20bit%20of%20Flixel%20%28flash%20game%20library%29%20programming%20lately%2C%20and%20to%20speed%20up%20the%20creation%20of%20games%20I%20created%20a%20Project%20Template%20for%20FlashDevelop%20that%20includes%20a%20MenuState%2C%20PlayState%20and%20Preloader.%20Download%20the%20template&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=10&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Flixel+2.0+Project+Template+for+FlashDevelop&amp;link=http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/&amp;notes=I%27ve%20been%20doing%20a%20bit%20of%20Flixel%20%28flash%20game%20library%29%20programming%20lately%2C%20and%20to%20speed%20up%20the%20creation%20of%20games%20I%20created%20a%20Project%20Template%20for%20FlashDevelop%20that%20includes%20a%20MenuState%2C%20PlayState%20and%20Preloader.%20Download%20the%20template&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.shareaholic.com/api/share/?title=Flixel+2.0+Project+Template+for+FlashDevelop&amp;link=http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/&amp;notes=I%27ve%20been%20doing%20a%20bit%20of%20Flixel%20%28flash%20game%20library%29%20programming%20lately%2C%20and%20to%20speed%20up%20the%20creation%20of%20games%20I%20created%20a%20Project%20Template%20for%20FlashDevelop%20that%20includes%20a%20MenuState%2C%20PlayState%20and%20Preloader.%20Download%20the%20template&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=38&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.pnapieralski.com/flixel/flixel-2-0-project-template-for-flashdevelop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

