Archive for the ‘technology’ Category

game mod

Sunday, September 27th, 2009

I really enjoyed the visual mayhem of the video below. What is it? I’ll let the author describe:

Game Mod was a six hour long workshop with the objective of showing the participants that it is not required to understand code to experiment and play with it.

Although they had no experience in coding, the task of each participant was to make a mod of a breakout clone built in Processing.

Frameranger

Saturday, August 22nd, 2009

I haven’t followed the demo scene in a long time but saw that the annual Assembly conference recently took place where many new demos are presented. What’s a “demo”? Typically it’s a non-interactive piece of software that displays something beautiful and/or technically impressive. The important thing to remember is that everything is running in real-time, like games do. Demos are not Pixar-like movies that are entirely pre-rendered ahead of time. You could run an executable file on your own PC to produce the same results, assuming it has hardware powerful enough.

Check out the winner, Frameranger, below. You can download the demo itself at the previous link if you’d prefer to run it on your Windows PC instead of watching it in video form. If your PC is powerful enough this is definitely recommended.

The demo is not perfect – the robot fighting animation in particular is a bit cheesy -  but overall the aesthetic is very well done. Enjoy.

Changing iPhone audio session categories

Tuesday, May 5th, 2009

For the past few hours I’ve been slamming my head against the wall trying to get these features working together: background playback of iPod audio, OpenAL playback of in-game events, and microphone recording. Microphone recording is not compatible with iPod audio and that is OK. When I enable the mic midway through program execution all I wanted to do was switch the session category and let the OS kill the music but it wasn’t working. I finally came up with a workaround and am writing this up for anyone else who runs into this issue.

Problem #1: don’t initialize OpenAL before initializing an audio session explicitly. If you do, iPod audio will be killed as OpenAL comes up. I couldn’t find any documentation on how this affects the session category.

To let the iPod continue to play you need to initialize an audio session and set the category to kAudioSessionCategory_UserInterfaceSoundEffects or kAudioSessionCategory_AmbientSound (info here). Make sure you do this first.

Problem #2: the OS will not let you change session categories if you first set your audio session – as above – and then start OpenAL. Why? I have no idea, the error code the API function returns is not a documented error.

I had to completely tear down OpenAL first and then call AudioSessionSetActive(false); to shutdown my initial audio session. Then I was able to change the category, restart the session, and finally restart OpenAL. Yes, this also means that I have to free all of my application’s sounds and reload them. This causes additional time the user has to wait for the sounds to reload. In the end it works but is not pretty.

Flash sine wave fun

Tuesday, March 3rd, 2009

Simple but periodically pleasing. Click to randomly generate a new scene.


After Pause Talk vol. 29 last night when talking with just-arrived-in-Tokyo Brian Thomas the topic of algorithmically generated art came up. I spent five minutes and cooked this up. It was definitely fun and I want to explore it more. I need to go ahead and learn the Processing language which I’ve heard is great for this kind of stuff.

Full source code is below:

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;

	public class SinDraw extends Sprite
	{
		private var sinWaveData:Array;

	    [SWF(width=500,height=300)]
		public function SinDraw()
		{
			sinWaveData = new Array(200);
			onClick(null);

			stage.addEventListener(MouseEvent.CLICK, onClick);
		}

		private function generateWave():void
		{
			var amplitude:Number = 100 * Math.random();
			var frequency:Number = 0.0174532925 * 2; // 2 degrees in radians
			var phase:Number = 100 * Math.random();

			// intentionally goofy
			var r:uint = (255 * Math.random()) << 16;
			var g:uint = (255 * Math.random()) << 8;
			var b:uint = (255 * Math.random()) << 24;
			var color:uint = 0xff00000000 + r + g + b;

			for (var i:int = 0; i < 200; i++)
			{
				sinWaveData[i] = amplitude * Math.sin((i * frequency) + phase);
			}

			for (i = 0; i < 200; i++)
			{
				var index:Number = i * (500 / 200);

				graphics.beginFill(color, 1);
				graphics.drawCircle(index, sinWaveData[i] + 170, Math.random() * 5);
				graphics.endFill();
			}
		}

		private function onClick(e:MouseEvent):void
		{
			graphics.clear();

			var matrix:Matrix = new Matrix();
			matrix.createGradientBox(500, 300, 90);
			trace(this.width);

			// intentionally goofy
			var r:uint = (255 * Math.random()) << 16;
			var g:uint = (255 * Math.random()) << 8;
			var b:uint = (255 * Math.random()) << 24;
			var color:uint = 0xff00000000 + r + g + b;

			graphics.beginGradientFill("linear", [color, (color - 0xff222222)], [1, 1], [0, 0xff], matrix);
			graphics.drawRect(0, 0, 500, 300);
			graphics.endFill();

			generateWave();
			generateWave();
			generateWave();
			generateWave();
			generateWave();
		}
	}
}

New Design

Monday, March 2nd, 2009

Anyone who has been to this website before can plainly see there has been a large revision. In addition to a new design, I’ve replaced the Blogger back end with Wordpress.

All of the old content has been migrated, including comments.

Comments and bug reports on the new design are welcome!

iPhone Development

Saturday, February 28th, 2009

Recently I’ve been working on the iPhone / iPod touch and my first title is nearly complete. I’ll announce it here soon and give some implementation details as well once it is finished.

Speaking generally about the platform, Apple has done an excellent job on the hardware as well as the API. It is easy to work with and the exceedingly low barrier to entry is why we’ve already seen countless applications released for the platform. Below is my list of the pros and cons of working with the device.

Pros:

  1. API is powerful, full featured, and well documented.
  2. The Instruments tool is very well done. Looking for performance bottlenecks, memory leaks, and analyzing general application behavior is a snap.
  3. Easy to test software in the iPhone simulator or directly on the device itself.
  4. Popularity has spawned some great open source work. I’m using cocos2d-iphone heavily in particular and have made a code contribution or two to that framework already.
  5. It is easy to get a product to market via direct distribution in the App Store.

Cons:

  1. Because of the pros listed above, especially #5, competition on the platform is insanely high. Getting an application noticed, regardless of quality, is a challenge. A lot of focus needs to be placed on getting your application noticed once it is released and everyone is fighting for that attention.
  2. Price competition has driven the average application price to $0.99. For most applications there is a very low glass ceiling on how much money it makes sense to invest in development. Selling 10,000 copies of an application you build yourself from scratch sounds great – and it is some nice exposure – but lets look at the numbers in a very rough way. At $1 a pop, Apple takes 30% (currently) leaving you with $7,000. Taxes, depending on your income and location, take perhaps another 20% of that. Now we’re at $5,600. For a professional developer working full time in the US with the skills to build an app themself, that’s around a months salary. Spending more than a month on the application then doesn’t make financial sense. But here’s the rub – most apps don’t sell anywhere near 10,000 copies. This severely limits the type of applications most developers can spend their time on.
  3. The X-Code IDE is decent but is nowhere near as nice as Microsoft’s Developer Studio. Especially when it comes to debugging.

Based on all of this my opinion on approaching the platform as an independent is the following: start small. Really small. Tiny ideas with focused, well implemented applications that target a specific niche without being too exclusive. Build up expertise and your own code library to start building applications faster and more efficiently.

Release these applications with boot-strapped marketing and PR. Put in the work to get the application’s name out there as much as you can. Track downloads and usage using tools like Pinch Media’s analytics platform. See what sticks. Once one of these small apps gains some traction, build on it. Understand why it is working well and give users more of what they want. Once you have a little cash flow and an understanding of what is working for you in the marketplace take the time to invest in and build something larger.

Finally, don’t rely on the iPhone completely for revenue. If your application is a game, ideally design it to take advantage of the platforms strengths but also work in other contexts. For example, a title that can both work in a browser under Flash as well as the iPhone gives you multiple revenue streams and more exposure. Unfortunately Flash and the iPhone do not share a common API or programming language, so it is a larger development investment, but the additional revenue and exposure opportunities for a small title are worth it in my opinion.

Finding Flash ActionScript 3 Resource Leaks

Friday, February 6th, 2009

Even though programming in ActionScript 3 in the Flash engine gives you access to a garbage collected language it is still easy to leak resources and kill the performance of your application. I’ve been looking into some issues with an application I’m working on as well as general debugging techniques and wanted to summarize them in a post.

First, the two main resource leaks that have come up for me in game development:

  1. Leaking objects in the display list.
  2. Leaking event listeners, especially ENTER_FRAME.


Leaking display list objects

This is a straightforward leak that can happen to any DisplayObject you add to a DisplayObjectContainer. Even if the object is off screen, alpha is zero, or if its visible property is set to false the object is still being updated by the Flash runtime. It is using memory and CPU cycles. Make sure you clean up your objects by removing them from the display list when they are not in use.

Here’s a small, simple code snippet for recursively walking a display list. If you suspect a DisplayObjectContainer is leaking objects, you can use this small utility function to count how many display objects exist in all children. If it doesn’t go down at all, you may be leaking objects (of course it depends on the use case of your software).

public function walkList(obj:DisplayObjectContainer):Number
{
var result:Number = 0;
if (obj == null || obj.numChildren == 0)
{
return 0;
}

result += obj.numChildren;

for (var i:int = 0; i < obj.numChildren; i++)
{
result += walkList(obj.getChildAt(i) as DisplayObjectContainer);
}

return result;
}

Leaking event listeners

This can be harder to track down than leaking display objects. Here’s the big thing that may not seem obvious to people at first – removing an object from the display list, even such that there are no more references to it, does not automatically destroy it or any of its event listeners. If you add a listener through addEventListener() you must remove it through removeEventListener().

By far the worst case of this are rogue ENTER_FRAME events that are still executing on objects you think are removed and gone.

I spent some time trying to figure out how best to track these issues down. The AS3 event model allows you to, for most events, insert an event listener in a parent object in the display hierarchy and basically monitor events as they go by. For example, if one of your child objects has a MOUSE_DOUBLECLICK event you can put the same event on your stage with the third parameter to addEventListener() set to true (capture). You can then print out what object the event is actually going to by using Event.currentTarget inside of the stage event listener.

Guess what though? You can’t capture ENTER_FRAME events in that way. You’ll have to recursively walk the display list again looking for objects that have the ENTER_FRAME event registered. If they have no parent reference then they are likely orphaned (again, depends on your software use case).

Or perhaps better yet – don’t use ENTER_FRAME at all for complex Flash software and write a traditional game update loop. That’s what I’ve done in my engine. I now only use ENTER_FRAME for hacking together prototypes.

As an addendum, here are some gotchas regarding AS3 that I learned about in my recent research:

Apparently creating static utility functions, especially math helpers used in tight loops, is significantly worse performance wise than pasting the code into the loop (aka ghetto inlining) even if complex constants would have been precomputed in the helper. Lesson: static lookup is slow.

If you can avoid it, do not call functions on class references that are typed by one of their parent classes. E.g. if you have a variable of type MyObject, try not to reference it through the global root class Object or any other parent class that may exist. This defeats the purpose of object oriented programming in many ways but for your most performance sensitive code the virtual method table lookup destroys performance.

Browser-based games

Thursday, January 29th, 2009

From an article at ICO Partners, a game consultancy, comes their list of predictions for the trends of online games in 2009. The first bullet point explains why they think most games are going to trend towards being browser-based which I agree with completely. Here’s their list:

  • Increased accessibility
    • more and more users are reticent to downloads
    • more fluid and more flexible user acquisition and viral funnel (can be propagated instantly just with a link)
  • Runs on every OS and most hardware (when laptops and netbooks are growing the fastest)
  • Runs in schools, offices, libraries, etc : more accessibility, less issues with installation of applications, and more social occasions to spread to schoolmates, colleagues, etc watching you play behind your shoulder.
  • Opportunities for around-game advertising, which has more standards and is easier to integrate than in-game advertising
  • Better opportunities for game/web integration
  • Opportunities for mobile ports (iPhone, Android, etc)
  • Less bandwidth costs to download huge clients, no need to send users to Fileplanet, hosting sites, etc…
  • Generally cheaper to develop and test, allowing for better ROI and easier to recoup.
  • More and more general applications are browser-based (Google Docs, YouTube, Hulu, emails, etc) and web habits taken now will influence game playing patterns in the future.
  • For the same reason, as a very large part of kids’ game playing already happens on web-based games, there is little evidence that they will return to client based games in the future.

Those are pretty much all the same reasons I’ve recently been investing a good deal of my own time into Flash based technology. I’m excited and curious about monetizing small online games and what kind of market/audience it takes to have building a larger title make financial sense.

Secret Project Teaser #2

Thursday, December 18th, 2008


Hamada-san draws her work in acrylics on paper, scans them in, and then does some touch-ups in Photoshop. Everything she does looks great with a distinctive style. The first teaser is here.

The bird above is fully animated and moves about the scene. As the project’s animator (gasp!) I have been forced to learn a lot about animation to take the illustrations of Hamada-san and make something that looks halfway decent.

I got some great advice from my talented animator friend Leo Martinez on a squirrel animation I was working on. You can see a test below. The sequence is animated from only two illustrations (a stand and a jump pose). I had no idea it was possible to create so much motion with Flash’s free transform tool. I don’t think I have a knack for animation but I am having a lot of fun working with it.

The significance of Linger in Shadows

Tuesday, December 16th, 2008
Linger In Shadows Robot Wallpaper

“Linger in Shadows” – the recent PlayStation Network release – is yet another part of the long history of the crossover of the demoscene and the game industry. For a nominal fee the user is greeted with what is largely a traditional demo. It has all the classic elements: lots of procedural content, mix of 2D paintings and 3D imagery, “greets” to other scene groups, and a soundtrack that matches the visuals. It is looks impressive, doing well to showcase the talents of the programmers and artists of the development team at Plastic.

Linger In Shadows Cat Wallpaper
The two significant and unusual things about Linger in Shadows are first, that the group was funded and published by Sony, and that second there are a number of interactive elements in the demo.

Why would Sony fund a small group of developers to create a non-game for their platform? Was it an extension of Ken Kutaragi’s original vision that the PS3 was to be more than a games console? Personally, I’m impressed that they would invest in such a project. I would be surprised if Linger in Shadows is profitable. I believe it could be used as a marketing tool in technology circles to show Sony’s interest in art projects or to promote the abilities of its platform. This is the kind of project that could attract the attention of artists outside of the mainstream game industry. With the current economy though and Sony’s recent sales struggles I doubt another similar project will get greenlit. I hope to be proven wrong.

The other attention grabbing part of the demo is that unlike a traditional PC based demo there are a number of interactive components. At various times while watching the demo, the user can spin the controller to move objects or light sources in the scene, for example. Other times they can scrub the movie’s time line forward and backward. Using the camera to look around can find hidden objects and greets that unlock PSN Trophies. It is certainly no game but the addition of these elements gives the demo an extra layer to peel back.

Linger in Shadows may go unappreciated by the gaming populace and in some ways it isn’t surprising. As a game developer a lot of the appeal of the demoscene is not just in watching something beautiful and admiring the creativity of the human race but in inspiration in both technology and artistry. Users without that specific interest may not find Linger in Shadows or any other demo particularly interesting and so be it. That said, games like Max Payne are widely appreciated by gamers. That game’s developer, Remedy Entertainment, was born out of the demoscene group Future Crew. I’m certain there are countless other members of the game industry who either came from the demoscene or were inspired by it.

Linger In Shadows Scenery
Finally, I’m happy to report that Plastic has generously released some of the tools used to create the demo. The content looks like it was developed largely inside of Maya with a custom plug-in that acts as a WYSIWYG real-time renderer. It reminds me of working with the Unreal Engine or Crytek. The ability to edit something and then be immediately able to preview it as it would look in game is very powerful. Below is a video of their tools, more information can be found on Plastic’s main site.