Image Image Image Image Image

© Copyright 2012 Your Company | RSS Email                                                                                                                                                                                                                  

Scroll to Top

To Top

ActionScript

13

Mar
2012

No Comments

In Animation

By Grant

Creating Greensock Plugins

On 13, Mar 2012 | No Comments | In Animation | By Grant

Creating a plugin for Greensock’s Tweening System is very easy. The following slides show some tips and examples how this can be done.
Read more…

Tags | , , ,

07

Dec
2011

No Comments

In Web Development

By Bradley Baysinger

Seven2 AS3 Scrollers

On 07, Dec 2011 | No Comments | In Web Development | By Bradley Baysinger

As of 2011, the Flash community has left absence of any particularly complete scrollbar solutions. Adobe’s scrollbar component is bloated, and a nightmare to customize. I’ve seen scrollbars that can be used for a fee, and some freely available, non of which are as customizable or feature-rich as they could be.

Scrollbars are a common thing for developers to fuss with, especially in the eleventh hour of a project. Everyone seems to be on a different page with them. Each developer has their own solution they’re familiar with, which gets tweaked slightly for each project. Read more…

Tags | , , ,

Pseudo 3d Collision Detection in a 2d World (AS3)

Seven2 recently completed the core engine & first level for the Kung Fu Panda game “Tales of Po” hosted by Nickelodeon:

This is an Adobe Flash/AS3 classic side-scrolling brawler game (think Double DragonCastle Crashers, etc). Executing this type of pseudo 3-dimensional game (x,y,z) in a space that in actuality is only 2-dimensional (x,y), creates two main problems:
depth sorting & collision detection. Read more…

Tags | ,

26

Oct
2011

No Comments

In Presentations

By Grant

Application Domain / Magic

On 26, Oct 2011 | No Comments | In Presentations | By Grant

I apologize for how the presentation went this morning. Here is maybe a better presentation?

Please keep in mind I never recompiled the first 5 Dot swfs.

Tags | , ,

23

Aug
2011

One Comment

In Web Development

By Kipp Ashford

Grabbing Items From an Array Based on Probability

On 23, Aug 2011 | One Comment | In Web Development | By Kipp Ashford

Ok so it’s not the snappiest title, but something that comes in extremely handy!

Part of making games more fun is introducing an element of randomness. If you’re making a dungeon crawler, you may want to specify different surprise items in a treasure chest. To make the chances equally random can be boring, because most of the time you want the chest to contain good items and only rarely do you want it to spew toxic gas.

Because this is such a common scenario I run into, I wanted to make a class to automate this process. After a lot of googling (and many false starts) I finally came up with something that looked close to what I wanted to do. The result is the WeightedRandomPool class. I’ve created ActionScript and Javascript versions of this code, so hopefully you find this useful.

How to Use:

If we were going to use the above treasure chest example, I might store different strings with the names of possible items in the chest.

var chestItems:WeightedRandomPool = new WeightedRandomPool();
chestItems.add("gold", 10);
chestItems.add("jewels", 10);
chestItems.add("poodles", 2);
chestItems.add("poison", 1);

// Gets an item from the pool.
var sRandomItem:String = chestItems.get();

So in the above example, we have “gold” and “jewels” both with a weight of 10, and “poodles” and “poison” with much lower weights. The weights are all relative to each other. All of them must be positive integers larger than 0.

In the example above, the “gold” and “jewels” are both 10 times more likely to be selected than “poison,” and 5 times more likely to be selected than “poodles.”

Let’s say that in your game you had a curse put on you, and you want to make it much more likely that “poison” will be in the chests. With one line, you can make that happen:

chestItems.changeWeight("poison", 100);

Now since the highest weight is 100, “poison” is 10 times more likely to be selected than “jewels” or “gold.” Sadly for the poodles, they would be 50 times less likely to be selected than poison.

The api for the javascript version is exactly the same. Below are both versions.

I hope this class helps you out in your Flash and JavaScript projects. Enjoy!

p.s. A special thanks goes out to ‘stephj’ of XDA-Developers forum for the code I blatantly ripped off adapted. The original post can be found here.

Tags | , ,