Recent posts by banthar on Kongregate

Flag Post

Topic: Game Programming / A flash question

JPEG doesn’t support transparency. You need to save it as something that does e.g. PNG.

 
Flag Post

Topic: Game Programming / Whats messed up with this code? [Plz, help. I need to get help with this soon cuz my internet will stop today D`: ]


if (score > 5)
{
    this.gotoAndPlay(2);
}

 
Flag Post

Topic: Game Programming / insane pixel effects - AS3

Burning effect: source swf

It’s not exactly AS3 and there are no comments, but if you have any questions just ask.

 
Flag Post

Topic: Game Programming / Dynamic Text AS3

myText.defaultTextFormat=new TextFormat(“myFont”);

myText.autoSize=TextFieldAutoSize.LEFT;

For more info go here:

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html

 
Flag Post

Topic: Game Programming / Box2d functions are weird

It’s a function that will be called for each object under that point.

function Callback(fixture:b2Fixture):Boolean
{
  trace(fixture.GetBody());
  return true;
}

function onClick(v:b2Vec2)
{
   world.QueryPoint(Callback,v);
}

 
Flag Post

Topic: Game Programming / Whats wrong with this code?

Try this:

on(release)
{

	if(people >= 20)
	{

		people -= 20;
		totalcitizen -= 20;

		money += 20;
		food += 15;

		trace("selling 20 people for 20 money and 15 food");

	}
	else
	{
		trace("not enough people, you only have "+people);
	}

}
 
Flag Post

Topic: Game Programming / AS3: Two ways of iterating through arrays. Which is better?

As expected for each was the fastest in the array because it saves a cast, but the performance with vectors is awful, why?

This is probably compiler/player issue. I’m using flex 2.5.35 and flash player 10.0.42.34 for 32bit Linux. You can try my swf

Here are my results:

for(var i:int=0;i<a.length;i++) :  211 ms
for(var i:int=a.length-1;i>=0;i--) :  153 ms
for(var i:int=0;i<len;i++) :  154 ms
for(var i:String in a) :  4085 ms
for each(var i:int in a) :  36 ms
for(var i:int=0;i<v.length;i++) using Vector :  132 ms
for(var i:int=v.length-1;i>=0;i--) using Vector :  23 ms
for each(var i:int in v) using Vector :  83 ms
 
Flag Post

Topic: Game Programming / AS3: Two ways of iterating through arrays. Which is better?

I’ve made some benchmarks and they confirm what Moonkey says.

> for(var i:int=0;i<a.length;i++) : 209 ms
> for(var i:int=a.length-1;i>=0;i—) : 154 ms
> for(var i:int=0;i<len;i++) : 157 ms
> for(var i:String in a) : 4093 ms
> for(var i:int=0;i<v.length;i++) using Vector : 136 ms
> for(var i:int=v.length-1;i>=0;i—) using Vector : 24 ms

Two last tests use Vector instead of Array.

source here