Parallax: A simple solution

Posted by aBethke on Friday Jun 18, 2010 Under Bag o' Tricks, Game Development

Recently when I was working on Star Fall I needed to develop a basic Parallax implementation as part of the game design. Ive done this type of implementation before but never built anything reusable. In fact, I’d love to tell you now that I did just that when developing Star Fall but that, sadly my friends, would be a lie. I have however taken the code I wrote for Star Fall and developed it into a very basic Parallax system which I offer up now to the gods of the interwebs and anyone else that might be interested.

The basic breakdown is pretty simple. You instance the SimpleParallax class and then begin adding layers to it and defining their properties via the methods I have created. The layer handling system uses a name to keep track of the layers. When you create a layer you assign its name and then reference it layer via the same name. There is no active depth sorting, simply create the layers in the order you wish them to appear.

[cc lang=”actionscript3″ line_numbers=”true” no_links=”true” width=”100%”]
package com.goldengear.core
{
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;

public class SimpleParallax extends Sprite
{
public function SimpleParallax()
{
mouseEnabled = false;
mouseChildren = false;
addEventListener(Event.ENTER_FRAME, handleEnterFrame, false, 0, true);
}
protected function handleEnterFrame(in_event:Event):void
{
var i:int;
var num:int;
var layer:DisplayObject;
var layerName:String;
var scrollSpeed:Number;
var loopX:Number;

if (!isPaused)
{
num = m_layerNames.length;
for (i=0; iSimpleParallax – Test Application

As I poke at this class more I will probably release the updated versions. Enjoy!

Tags : , , | Comments Off on Parallax: A simple solution

This is a trick I picked up recently when I was preparing some games (Mashin’ Meeces and Star Fall) for release on portal sites and saw that it would be a bit easier (and required by some) to figure out how to change my multi-SWF application into a single SWF app.

Mashin’ Meeces was originally broken into three SWFs: game code, art assets and sounds. I did this so that I could work on the game independently from the sound or art since those were being taken care of by other people. Through my previous experience developing games I had never run into a problem with having games broken into multiple SWFs before but those projects have all been for private sites and game portals like Newgrounds and Kongregate are a new experience for me. After talking with my colleagues, doing some research and poking at the code for a bit I finally got the solution of embedding the SWFs into my main application and then load them using loadBytes.

Here is the code I used to embed the two SWFs (art and sounds) into the main class of my ActionScript project.

[cc lang=”actionscript3″ line_numbers=”true” no_links=”true” width=”100%”]
[SWF(width=’800′, height=’600′, backgroundColor=’0xffffff’, frameRate=’30’)]
public class MashinMeeces extends Sprite
{
[Embed(source=”MashinMeecesAssets.swf”, mimeType=”application/octet-stream”)]
private var swfAssets:Class;
[Embed(source=”MashinMeecesSounds.swf”, mimeType=”application/octet-stream”)]
private var swfSounds:Class;

public function MashinMeeces()
{
// Rawr! I am the constructor…
}
}
[/cc]

For the loading I had just been using a standard Loader implementation and to convert the pre-existing code all I had to do was drop the URLRequest() and change load() to loadBytes().

[cc lang=”actionscript3″ line_numbers=”true” no_links=”true” width=”100%”]
protected function addedToStage(in_event:Event):void
{
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);

var assetLoader:Loader = new Loader();
addChild(assetLoader);
assetLoader.visible = false;
assetLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, assetsLoaded, false, 0, true);
assetLoader.loadBytes(new swfAssets(), loaderContext);
}
[/cc]

Tags : , , , | Comments Off on Actionscript Project Refactors: Multiple Swf to Single Swf Loading

TO Jam 5 – Development Video Blogs (Part 3 of 3)

Posted by aBethke on Wednesday May 26, 2010 Under TO Jam

In a short time the TO Jam Arcade and final judging for the People’s Choice Award will be upon us. Andrew and I have been doing some revisions on the game slowly while working on other projects. At this point Ive kicked most of the remaining work to Andrew at his request and have moved onto other Golden Gear projects.

Read More

Tags : , , , | Comments Off on TO Jam 5 – Development Video Blogs (Part 3 of 3)

Mashin’ Meeces – Countdown to launch day

Posted by aBethke on Tuesday May 4, 2010 Under Mashin Meeces

Welcome once more to the blog series leading up to the final launch of my current project Mashin’ Meeces. A couple highlights to begin:

  • – MM will be on display and playable at TCAF from 2 to 5 pm on Sunday May 9th down at the Toronto Reference Library. Event Details
  • – MM is being prepared for final release mid-May for IndieCade. Contest Details
  • – Once released, Mashin’ Meeces will be up for licensing and sponsorship/hosting so if you are interested, let me know.

Read More

Tags : , , , | Comments Off on Mashin’ Meeces – Countdown to launch day

TO Jam 5 – Development Video Blogs (Part 2 of 3)

Posted by aBethke on Tuesday May 4, 2010 Under TO Jam
Reentry - Missile Stage

Reentry - Missile Stage

*sniffle* Oh how I already long for the arrival of TO Jam 6 next year.

Andrew and I are continuing development on Reentry, which is going good for the most part. We are having a big debate between us at the moment because he really likes the point and click control system and I want to use the keyboard system I have implemented. Its a big problem because of game balance and how the game would evolve from here so we need to make a decision soon. From my play testing research most people find the mouse based system really annoying. I think the game would benefit much more by allowing the user greater control and increasing the overall game speed. We will get it sorted out soon enough though.
Read More

Tags : , , , | Comments Off on TO Jam 5 – Development Video Blogs (Part 2 of 3)

Timers can suck it

Posted by aBethke on Tuesday May 4, 2010 Under Bag o' Tricks, Game Development

Salvidor Dali PaintingI think the title of this post really sums up my entire sentiment as far as the Timer class goes in Flash. Many people have recently heard me speaking, arguably ranting, on the subject so I thought I would quickly highlight a few reasons to avoid using Timer, the one place that I have found that I had to use Timer and offer an alternative piece of code to use in the majority of cases where a timer like mechanism is needed.
Read More

Tags : , , | Comments Off on Timers can suck it