Recent posts by BobJanova on Kongregate

Flag Post

Topic: Game Programming / Question about alpha/transparency in general

In paint.net, there’s an option for Additive in the Blend dropdown for whatever painting tool you’re using. In Stage3D use context3D.setBlendMode. Not sure about how to do it with DisplayObjects.

 
Flag Post

Topic: Game Programming / Question about alpha/transparency in general

Pixels are overlaid, not combined. So if you put a pixel with 50% alpha on top of an existing pixel, the RGB values are summed based on the alphas of both pixels, and the alpha value is the old alpha plus the proportion of what’s left (255-old alpha) given by the new pixel.

If you use additive blend mode (SRC_ALPHA, DEST_ALPHA) you should get what you want.

 
Flag Post

Topic: Game Programming / Load .png without premultiplying alpha channel?

Hi all, I’m trying to embed a PNG image with alpha channel information. Is it possible to do that without the RGB channels being pre-multiplied by the alpha? I want to see the actual ARGB values stored in the file. (I’m using the image as a Stage3D texture and the alpha channel is for specular smoothness.)

It’s okay if I can’t use BitmapData and have to [Embed] with a different format, though ideally I just want to turn off premultiplying on BitmapData..

 
Flag Post

Topic: Game Programming / In-game Events: Storing the target as a variable or passing it each time

This depends on the association between events and characters.

If an event is associated with a single character or group of characters, the target can’t change, and it involves more than just a change to the character’s attributes (strength, resistances, speed, whatever), it should be an object which refers to the character.

If an event is just modifying attributes of the character, then characters should hold events, not vice versa.

If events are associated with an area of the map, or some other way of selecting characters which is changable between frames, then events should be given either the map or a function that lets them pick characters.

 
Flag Post

Topic: Game Programming / PlayerIO lifespan

They’re updated their price policy and integrated it with their own games channel, so I would guess they’re intending on keeping it supported for quite a long time.

 
Flag Post

Topic: Game Programming / Should I start making flash games?

If you think it will be fun, then yes, otherwise no, like any hobby ;)

Sticky threads are there for a reason, there’s lots of help in there.

I use FlashDevelop which is free and pretty good, though you have to create your art, music etc in another program.

 
Flag Post

Topic: Game Programming / Artist for hire

You might want to post this in Collabs, though I see you are quite active there already in other threads.

 
Flag Post

Topic: Game Programming / Procedural Generation

I hadn’t heard of simplex noise, thanks for the tip, I’ll be sure to look into that next time I’ve got some procedural generation to go at.

 
Flag Post

Topic: Game Programming / Procedural Generation

Perlin noise is the way a lot of procedurally generated ‘natural’ environments are built.

 
Flag Post

Topic: Game Programming / Fun with Math

You can’t have the appearance of random noise and guarantees about separation (obviously, random noise is, well, random), so you probably need to be more precise about the requirements on that front.

I would start with the peaks a periodic continuous function in X and Y (e.g. sin/cos) and then pseudo-randomly perturb it until it looks ‘random enough’.

 
Flag Post

Topic: Game Programming / Overriding the + Operator

Yeah hopefully. I have the same thing with vector and matrix classes, the C# version is really nice to use and the AS one a bit ugly, but we just have to put up with it.

 
Flag Post

Topic: Game Programming / (True === False) ???

If he’s coming from C++ he’s leading you up the garden path with regard to AS. In C and C++, the constant ‘NULL’ represents a literal 0, so true > NULL. That’s not true in object based languages with a true null, like AS – in these languages the definition of what a comparison operator should do is arbitrary.

 
Flag Post

Topic: Game Programming / (True === False) ???

It’s just the definition that AS has chosen to use. There isn’t really a deeper reason.

 
Flag Post

Topic: Game Programming / (True === False) ???

I’m glad to see an explanation for this snippet which isn’t decompiling, which is what it looked like … although I’m still suspicious, _loc_1 isn’t the kind of name that any actual person would name anything.

In terms of the actual snippet, I’d say he’s screwing with you a little. But it’s easy enough to follow the logic: true===false is self-evidently false, so it evaluates to false<null, and I think any arithmetic comparator with a null returns false (like it does with NaN).

 
Flag Post

Topic: Game Programming / Interfaces vs Inheritance

Another place that interfaces are very useful is creating a boundary between modules – this is what you are getting at with ‘make sure the other programmers know that the object extending the interface requires myMethod() to be declared’ but it’s more generally useful than just dealing with other people. Whenever you create a module where all its dependencies or external couplings are interfaces, not concrete classes, you can isolate that module and test it in isolation; also, you can easily switch out the dependencies if you want to later on.

For example let’s imagine a typical 2D game scenario where you have some objects in the game world that you want to control, either with the keyboard/mouse or by AI interactions. The temptation is to write control code directly referring to the player character and write AI movement code directly in ‘enemy’ types. But if you instead delegate it through a Controller interface, suddenly you can
- test that your player movement reacts to control events (e.g. ‘go right’) correctly, by plugging in a test implementation of the controller which sends well known control events;
- allow the player to take control of different characters by replacing their controllers with a keyboard/mouse one, for example some kind of body-switching powerup
- allow the computer to take control of the player character, for example a berserk effect;
- have the same type of character act differently depending on other circumstances (by having different controllers) – e.g. you can persuade them to fight on your side

Interfaces are very useful when you get to software engineering as opposed to hacking stuff together, because this kind of boundary between components is important for team working and for testability.

 
Flag Post

Topic: Game Programming / Custom Embed Width and Height on KONG

Build a SWF which is already scaled down and submit that. If you want different versions at different sizes you should be able to script the build process to do that, though I’m not quite sure how to do that from FD.

 
Flag Post

Topic: Game Programming / Statistics doesn't work in preview mode ?

I don’t think it does, it’s so long since I uploaded a game with stats I forget though.

 
Flag Post

Topic: Game Programming / FlashDevelop's flawed Features

I didn’t know about that, thanks. It still doesn’t autocomplete it for you like it does any OO method in scope, though.

 
Flag Post

Topic: Game Programming / Multiplayer as3

And do you have server hosting, backup of user data, load balancing and so on?

I actually agree that writing serverside code is not at all hard – it’s basically just a message serialiser and deserialiser and management of connections on the server side. But the infrastructure costs money and probably a lot more money than you pay to Player.IO or its friends.

 
Flag Post

Topic: Game Programming / FlashDevelop's flawed Features

Looking for getTimer(), for instance? just starting to type it won’t cut it, unless you’re already importing it in that class.

Yeah that’s the one thing that’s annoyed me about it (same for describeType and other static non-OO functions).

 
Flag Post

Topic: Game Programming / Find the error

Looks like this is in the property setter for the enemyBox property for the B3 class (that looks like a very bad name btw)? Post that property code.

 
Flag Post

Topic: Game Programming / Graphic Filters/Shaders

Have you looked into Stage3D? Despite the name, it’s just a graphics pipeline which drops through to accelerated hardware where available, and you can write shaders for that (look up AGAL).

 
Flag Post

Topic: Game Programming / Need easy object comparison?

Not on Kongregate I’m not … elsewhere … perhaps :P

 
Flag Post

Topic: Game Programming / Need easy object comparison?

Nice.

Does it work on arrays?

I have something similar in my unit test library but it doesn’t bother going through all the fields and properties, it relies on the fact that I set the toString to something meaningful on my custom objects.

 
Flag Post

Topic: Game Programming / Essential AS3 help again -- random "b"

Originally posted by truefire:

Worth noting: try/catch is really slow. It shouldn’t be relied on for the execution of your program. That is, try/catch should only be used to detect unknown errors, not as part of regular program flow. [etc]

I don’t fully agree with this, and it’s a matter of some debate in the wider development world – there’s no clear answer. You shouldn’t use try/catch for control flow, i.e. you shouldn’t use a try block when you expect the exception to be thrown in ordinary usage. But for exceptional cases it is fine (imo) to use exception handling to deal with inappropriate input. If you are selecting items out of an array then the normal input is requests within the valid index range, and I’d be quite happy letting an exception be thrown if the input is exceptional by being outside the range.

A good rule of thumb is that if your if statement is going to display some kind of message to indicate an error condition to the user, it’s okay to throw (or permit library code to throw) an exception there, as long as you have exception handling in place to handle it gracefully higher up.

Try/catch is slow, but not so slow that you shouldn’t use it. Actually throwing and catching an exception is slow (order of ms I guess) so you shouldn’t do it repeatedly, for example in a tight loop. But throwing exceptions in exceptional situations and handling them high up the call stack is fine to me.