Recent posts by BigJM on Kongregate

Flag Post

Topic: Game Programming / Respecting OOP a bit better this time around...

Originally posted by Drakim:
Originally posted by BigJM:
Originally posted by Drakim:

Also, functions as objects can be incredibly useful for many purposes, however, when you treat functions as object, you have a performance penalty because the type of the function is lost, so the runtime has to do some special stuff whenever you call the function.

myEnemy.update(); //fast

var temp = myEnemy.update; //store the function in a variable

temp(); //slow

This isn’t true.

It’s very true actually: Link

It’s about 14 times slower. Ka-ching!

I knew you were going to send me a link to that site. Aside from the methodological and analytical errors underlying the test itself, he’s comparing calling properties with calling method closures (which isn’t what was suggested earlier). The speed discrepancy he found (if there even is one; it’s impossible to tell by his results due to the aforementioned errors) is likely caused by this and not because “the type of the function is lost” or “the runtime has to do some special stuff”.

 
Flag Post

Topic: Game Programming / Respecting OOP a bit better this time around...

Originally posted by Drakim:

Also, functions as objects can be incredibly useful for many purposes, however, when you treat functions as object, you have a performance penalty because the type of the function is lost, so the runtime has to do some special stuff whenever you call the function.

myEnemy.update(); //fast

var temp = myEnemy.update; //store the function in a variable

temp(); //slow

This isn’t true.

 
Flag Post

Topic: Game Programming / Respecting OOP a bit better this time around...

1) Using events would not be faster. Either way a function is being called, but consider the overhead of processing events. I can’t quantitatively say how much slower using events would be and it could be negligible in your project. That said, using an event driven system could be more “OOP-friendly” because it protects encapsulation.

2) Your custom event class can contain all of these properties.

 
Flag Post

Topic: Game Programming / Creating A Loading Screen From A Swf

It’s telling you that stage is null. Probably, the calling DisplayObject is not on the display list (ie not eventually a child of stage).

Or, less likely, MouseEvent is null.

 
Flag Post

Topic: Game Programming / Creating A Loading Screen From A Swf

There has to be at least a thousand tutorials for this on the web. Check the help files under flash.display.Loader. Here’s some basic code (written on my phone, so watch for errors):

var l:Loader = new Loader()
addChild(l)
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progress)
l.load(new URLRequest("my.swf"))
function progress(e:ProgressEvent):void {
    trace(e.bytesLoaded / e.bytesTotal)
}
 
Flag Post

Topic: Game Programming / turret rotation, click and shoot help [AS3]

Yes BUT only one is publicly accessible. The accessory classes go outside the package block.

 
Flag Post

Topic: Game Programming / turret rotation, click and shoot help [AS3]

All the tutorials you find using classes should pretty well port directly to the timeline sans the access modifiers. Code on the timeline is converted to a class like structure on compilation. Really, you are creating a class, you just don’t know it.

 
Flag Post

Topic: Game Programming / How to make a pseudorandom generator?

That’s some pretty complex math…

 
Flag Post

Topic: Game Programming / How to make a pseudorandom generator?

I assume you’re looking for something that you can seed? If you download the Tamarin VM, you can find adobe’s C++ implementation to use as an example. There’s also an AS3 implementation of some algorithm if I remember correctly but I don’t recall the package or what functionality it offers over Math.random. Try the flash.crypto package (if that exists).

 
Flag Post

Topic: Game Programming / How would you do this

Like I said, you need to modify the code so that if you come to the ‘edge’ of the vector during flood filling you decide that the area is not enclosed.

You should also have some mechanism so that you don’t recheck every tile. While flood filling, I’d change the number of the checked tiles to 3 (or something) and push the indices to a vector. That way you don’t need to check anything that’s a 3. If you find that after the flood fill is complete that you have an enclosed area, you’ll have a vector with the index of every tile in that area. You can then, if necessary, go back and change the number of them in the original vector.

 
Flag Post

Topic: Game Programming / How would you do this

What? If in the process of flood filling you come to the ‘edge’ of the vector, you know the area is not enclosed. If you’re able to complete the flood fill then you know you have an enclosed area AND you have a vector of all the enclosed tiles.

 
Flag Post

Topic: Game Programming / How would you do this

Use a flood filling algorithm.

http://www.kongregate.com/forums/4-game-programming/topics/305239-i-have-no-idea-how-to-go-about-this

Hey, that was your thread too asking the exact same question…

 
Flag Post

Topic: Game Programming / Complete Object Clone [Solved]

You could break it up over several frames or put it in an independant thread or figure out an alternate way of going what you want to do.

 
Flag Post

Topic: Game Programming / Cursor follows mouse even though told not to [Solved]

Perhaps it’s being considered as a label. Byte code will tell you (which I’d look at if I had an AS compiler handy).

 
Flag Post

Topic: Game Programming / Coding on Timeline?

It is necessarily true but notice that I said neglible. I don’t actually advocate using the timeline for a real AS project; I was mostly just stirring the pot.

 
Flag Post

Topic: Game Programming / Coding on Timeline?

Everything in the timeline gets compiled into a class called MainTineline in a namespace with the same URI as your fla. Script in a frame (other than property and method definitions) gets moved into functions (frame1, frame2, etc.) and addFrameScript is called for each, much like you have there.

The second line was sarcasm; the first wasn’t. Classes by definition create abstraction between objects. This abstraction leads to slower access.

 
Flag Post

Topic: Game Programming / Coding on Timeline?

Originally posted by BigJM:

My timeline code will almost neglibly out-perform your abstracted class system any day of the week. The timeline is where boss playas code.

I don’t doubt it.

 
Flag Post

Topic: Game Programming / Coding on Timeline?

If you’re doing that, you’re doing it wrong. The simple act of using a class doesn’t automatically make it a better system. You need to actually learn how to program in an OO sense before you gain any real benefit.

 
Flag Post

Topic: Game Programming / Coding on Timeline?

My timeline code will almost neglibly out-perform your abstracted class system any day of the week. The timeline is where boss playas code.

 
Flag Post

Topic: Game Programming / Adobe Roadmap - Goodbye Actionscript "Next" and changes to Premium/licensing

The next, tentative version of AS that I saw would have cleared out a lot of bloat and resulted in drastic performance improvements. I’m disappointed but at the same time I see where they’re coming from.

 
Flag Post

Topic: Game Programming / Adobe Dropping Support for AS2 in next Flash Pro

They use the same byte code. The major difference was the compiler which you pointed out allowed things like case insensitivity and external classes and other things.

 
Flag Post

Topic: Game Programming / Adobe Dropping Support for AS2 in next Flash Pro

AS1 and AS2 are pretty well the same thing.

 
Flag Post

Topic: Game Programming / Questions about flash concurrency

You can have more than one thread on a single core.

 
Flag Post

Topic: Game Programming / PlayerIO Question

Neat…

 
Flag Post

Topic: Game Programming / PlayerIO Question

Is it the document class?