Interactive Crap

Flash Game Programming and some other random crap

Thursday, February 26, 2009

4k Flash Game Competition

Its ON! The 4k competition put by Urban Squall and Gaming Your Way, has been getting a lot of positive press around the net and a rousing response from the Flash game development community. Personally, I have completed my entry and plan on turning it in around the deadline time of March 9th. It was a lot of fun to make and only took me a few hours to complete, but then, of course, I had to tweak it with graphics, extras and optimization.

It’s good to keep your skills sharp with these types of contests and to have a face in the Flash game development community. Lots of my personal close friends (in real life) are doing the competition as well. Minnesota represent! If you would like to learn more about the contest check it out here.

posted by nate at 4:03 pm  

Saturday, February 21, 2009

Ginger: Using it for uniform sprite sheet rendering

Panayoti over at Urban Squall runs a fantastic blog called Game Poetry, there he posts great advice on all things for Flash gaming. One of his posts found here is about improving performance with animated bitmaps. In a nutshell it describes a code project that he has started up to create and manage bitmap animations from a sprite sheet. At the end of the post he sent out a call to developers to help him out with specification for external data for creating animations. I helped out and came up with my own, however it is now dated. ;-)

Despite that I am encouraging you to check out the blog post and the project to whom ever wants a simple and clean implementation of managing animated bitmaps in your games or apps. You can check out my implementation here.

Basically all that is happening in this example project is under the trycatchgames folder is my implementation of Urban Squall’s bitmap animation framework, which has since been updated. In the Main class you can see how I am using XML to define an animation, create it using the animation builder, add it to the controller and play it. By using the unified animation controller we are able to add one to many bitmap animations and retrieve them when needed. It should also be noted that even if you don’t have rotation in your sprite sheet that you are able to add rotation if you so desire. On bitmap animation creation you are able to specify the number of degrees in your rotation.

Check out the example project and the newest one in the Urban Squall code repo found here.

posted by nate at 3:08 pm  

Tuesday, January 6, 2009

Analyzing Sound in AS3

I have been wanting to build a game that builds worlds/enemies/properties off a given music file for some time. There are some decent games out there that are making such strides, one of which is Tube Rockers. I like that game because it involves people making custom tracks to music videos found on You Tube. Pretty cool.

However, with Flash 10 we have the ability, with the users permission, to read and write to their hard drive. Finally. I know I can say this for every Flash/Flex developer out there that we have been waiting for this since… well… Flash was created really. And now without round tripping to the server! Yay!

Analyzing sound in Flash has been around since SoundMixer.computeSpectrum() was introduced in Flash 8. Using this, along with the read capabilities of Flash 10 we can bring in any mp3 a user would like to play in a game. This is where the idea stems from. Try Catch Games (www.trycatchgames.com) my casual game company is currently concepting such a music game, more on that to come.

Now to talk about sound. Here are some stats:

Human Hearing: 20 to 20,000 Hz

Bass: 20 Hz - 250 Hz Mids: 250 Hz - 6 kHz Highs: 5 kHz - 20 kHz

Bass Drum: 50 Hz - 5.5 kHz Thump: 50 Hz - 100 Hz Punch/Slap: 2.5 kHz - 5 kHz

Cymbals: 300 Hz - 17 kHz Presence: 10 kHz - 14 kHz

Snare: 100 Hz - 12 kHz Center: 1 kHz Tight: 5 kHz - 6 kHz Crack: 8 kHz - 10 kHz

Toms: 4 kHz - 5.5 kHz and 9 kHz - 10 kHz

***

I am going to assume that readers of this blog know a thing or two about sound. If not, check out a wiki and come back.

A lot of you are probably asking “What does this guy know about Flash that I don’t to analyze sound?”. Really the answer is, nothing. I just want to give out some information that I have found out to further your journey into building better Flash games or apps. Let’s jump in.

Checking out the computeSpectrum method in the SoundMixer object you will find a few params:
computeSpectrum(outputArray:ByteArray, FFTMode:Boolean = false, stretchFactor:int = 0)

The params I am going to focus on are the last two and what to do with that data. First, for the data that I want I set FFTMode to true because I am interested in the frequency spectrum instead of the raw sound wave. With this frequency data I want to filter out (as best as possible) values that tell me when something is happening. This “something” would be a beat, vocals or guitar. Now I have to say from the onset that my filtering isn’t really that great…yet. But I believe with the capabilities of extracting raw sound data from an MP3 and computeSpectrum (or one or the other) will help me accomplish my goal more accurately. For now, I am analyzing on-the-fly and averaging values based on what I think a beat is.

The next param is the stretchFactor. I believe this to be important to be tweaked as we can drill down to the frequencies that are interesting to us. In my experiment I am using the values of 3 and 5, which give us a stretch to the frequencies of 5512 and 1378 respectively. Now I obviously use the 1378 frequency stretch for testing for sound data in the lower spectrum (which covers a lot of sound actually) which is mostly beats, bass guitar and some voice depending on the music. The higher one, 5512, would be used for higher frequencies like violin and female voice.

For some simple formulas in finding these frequency ranges I have hard coded x and y point values. This can be found by the frequency max limit, which for the lower one would be 1378, then divide that by 512, as this is the number of channels. You will find that each “slice” will be about 2.69. This means that within each of these slices it will cover a particular frequency range. In the case of covering 0Hz - 100Hz you would divide 100 by 2.69 to find how many slices it occupies. In my experiment I would sometimes give or take a few slices in some cases.

I know none of this is ground breaking, but I did my fair share of searching and no one has talked about it. My experiment that I did off of this research is a simple on-the-fly averaging music program that does a little filtering and displays a square when the grouped slices go over the average. Currently, I am not going to share the source code as its a work in progress but if you would like to check it out contact me directly: nate |at| pacyga |dot| com

If you would like to check out my experiment do so here.

posted by nate at 3:07 pm  

Monday, December 15, 2008

Implementing the Kongregate High Scores API

I consider myself an “alright” programmer. So when something that is supposed to be simple in programming frustrates me, I feel like a complete moron. Enter the Kongregate API, chances are if you are reading this post you have dealt with it in some fashion. Now if the documentation was all over the place and split up (and done in an actual OOP example) it might actually make some since. Hence the reason for this post. I hope to clear things up a bit.

First, to check out the documentation here. Nice huh? Well hopefully I don’t screw it up more. You will notice that there are few options to which you can implement said API. I recommend the SWC since you can have code hinting and its right there at your disposal. Or you can go with downloading it remotely (this post does not deal with the component). If you decide to download it at runtime check out this guys post. If you do go with that dude’s way make sure you listen to the KongregateEvent.COMPLETE event. (this is what threw me off completely)

Ok, so this is going to be short and sweet. When you use the SWC way I recommend having a reference to it that you can access from anywhere. Let’s not argue about OOP practices and evil singletons, just roll with it. I like to throw a reference to it in my “Model” which I have access to anywhere, this could be said about any class that you are storing persistent data through out your game. Then in your “Main” or Document class make a new KongregateAPI (NOT getInstance() like the docs say and then listen for the KongregateEvent.COMPLETE event. Those two things completely threw me off because I heard different stories from different sources… as dumb as that makes me look. Then finally where you want submit a score do so in your “Results” class. (Imports NOT included in code, I assume you are just putting those in)

In your “Model”:
public var kongregate:KongregateAPI;

In your “Main” or Document Class:
Security.allowDomain('http://www.kongregate.com');
_model = Model.getInstance();
_model.kongregate = new KongregateAPI();
_model.kongregate.addEventListener(KongregateEvent.COMPLETE, kongInit);
stage.addChild(_model.kongregate);

private function kongInit(event:Event):void {
_model.kongregate.services.connect();
}

In your “Results” Class:
_model = Model.getInstance();
_model.kongregate.scores.submit(_score);

posted by nate at 9:43 pm  

Sunday, December 7, 2008

Hey Hey Shooter: Classic Released!

Even though I programmed this some time ago, I finally released Hey Hey Shooter: Classic. I hope you guys enjoy it! (Damn, I need to blog more…)
http://www.kongregate.com/games/TryCatchGames/hey-hey-shooter-classic

posted by nate at 10:37 pm  

Tuesday, September 23, 2008

Klok

Keeping track of time is always a bitch on a given project. Of course you could always just keep a notebook handy (which I have done a lot) and jot down hours, but its so much better to have a program do it for you. Klok is just that. Its a simple, clean, straight up app available here. It’s been pretty cool for me so far in the week or two that I have been using it and I recommend it for a FREE time tracking tool.

posted by nate at 3:28 pm  

Sunday, April 13, 2008

Game Object Base Class

In a previous post I talked about having world objects be described in numbers and bitmap data. Then if this object (in memory) is within a viewable rectangle render it to the screen. The code of this post is a simple example of such a class. Also, when building such a class for your game make sure you adhere to an interface.

Check out the example

posted by nate at 12:09 am  

Sunday, April 13, 2008

Game Object Management

Having a simple way to keep track of world objects in a game is paramount. I have a simple system that I often use in my games that I presented on at MN.swf camp this last week. It’s by no means a standard and it can be added on to at great lengths. I just dig it because its simple and easy to use.

The idea behind this example is to use the Dictionary object with an a generic object. Reason being is that we can then use the actual game objects as keys and values. Then if we set the weak reference to true we can get rid of this world object all the easier. Also, you will notice that I used a try catch in the GameObjectManager. Reason being is that I found that when I removed an object, within that same frame I would be iterating over the collection and garage collection had not yet deleted that reference. I don’t know if I am doing something wrong or if this is a bug with the Flash player; if someone has an answer please leave a comment or drop me an email.

Check out the example

posted by nate at 12:04 am  

Saturday, April 12, 2008

Blitting within a Rectangle

Often in game programming you will have a large world but you only want to render a certain viewable area of it. By doing a simple check of where an object is in the world you can render only the objects wanted to the screen. This will help out performance dramatically. The next idea behind this is to cut down game objects only to numbers and bitmap data, instead of display objects.

Check out the example

posted by nate at 11:58 pm  

Saturday, April 12, 2008

Blitting in Flash

Next is simple example of blitting to a bitmap in Flash. The idea is to have one bitmap used for the screen and lock and unlock it every frame and draw any objects wanted to the bitmap. But don’t forget to fill the bitmap first else you will have pixels leftover from the last frame resulting in an unwanted ghosting effect.

Check out the example
**Note: Thanks to Electrotank in this whole series for the FPS counter.

posted by nate at 11:52 pm  
Next Page »
  • order viagra
  • synthroid pills
  • buy cialis generic
  • viagra in uk
  • levitra online
  • cheap lasix
  • compare cialis prices
  • find viagra no prescription required
  • buying generic cialis
  • viagra for sale
  • soma prescription
  • order cialis online
  • buying generic viagra
  • buy propecia online
  • cialis discount
  • levitra sale
  • viagra tablets
  • discount viagra online
  • cialis in us
  • soma discount
  • viagra pill
  • compare viagra prices online
  • cialis side effects
  • cialis approved
  • cheap cialis in uk
  • cialis drug
  • acomplia online stores
  • viagra medication
  • lasix prices
  • lowest price soma
  • price of viagra
  • viagra bangkok
  • generic lasix
  • synthroid online
  • low cost cialis
  • cialis pills
  • order no rx viagra
  • cheap lasix online
  • accutane
  • order discount cialis
  • price of soma
  • buy cialis online cheap
  • discount synthroid
  • buy cheap propecia online
  • generic acomplia
  • cheapest zithromax
  • buy lasix online
  • synthroid cheap
  • online cialis
  • lowest price zithromax
  • zithromax online cheap
  • viagra cheap drug
  • viagra us
  • discount lasix
  • cialis canada
  • cialis online without prescription
  • buying cialis online
  • cheap soma online
  • cheap synthroid tablets
  • accutane no prescription
  • cheap clomid tablets
  • cialis india
  • generic viagra
  • acomplia for sale
  • where to buy accutane
  • lasix for sale
  • clomid no prescription
  • tablet viagra
  • fda approved viagra
  • cialis free sample
  • cost viagra
  • cialis online review
  • zithromax sale
  • Powered by WordPress