Recent posts by JWBSoftware on Kongregate

Flag Post

Topic: Game Programming / Generate this kind of 2d burst or pulse algorithm?

Not used Cocos2d, but in Starling you would create a mesh of triangles. Easy to set up with a few lines of code and some math, with the inner, outer radii and the number of segments/triangle pairs as parameters. If triangle meshes are not available quads will work just as well.

 
Flag Post

Topic: Game Programming / Experiences with cross-platform 3D Flash games?

In theory Flash is just as capable of doing 3D as Unity. The problem is the 3D APIs are still relatively new and unsupported. Unlike on the 2D side where there are lots of tools from Adobe and others for making content, there is very little for 3D. Flash’s advantage has always been the 2D tools.

It is free though. Download Apache Flex and the Adobe AIR SDK and you can make apps for iOS, Android, Web and Mac/PC desktop from the same codebase. No need to pay, ever.

 
Flag Post

Topic: Technical Support / negative number of posts

In the game programming forum a topic with three posts is listed as having -12 in the topic listing. The direct link to the post is:

http://www.kongregate.com/forums/4-game-programming/topics/619988-error-2037-as3

 
Flag Post

Topic: Game Programming / Error #2037 AS3

At a guess you are calling stop() on a sound that has not started. You need to check this: Flash has only a finite number of sound channels and if you try and play too many sounds at once some will not play. You need to notice this and deal with it accordingly. Or plan ahead so you never try and play too many sounds at once (I think the limit is 32).

 
Flag Post

Topic: Game Programming / How are most games made right now?

Adobe Air. Or at least according to one poll:
http://www.opinionstage.com/polls/2191420/poll

It is the one that delivers the most installs with one codebase for Android, iOS, web and desktop. Any other platform you either need to do a lot of work with custom platform specific code or ask users to install a plugin/runtime that most don’t have.

 
Flag Post

Topic: Game Programming / How to make Flash games

Originally posted by thdarkblue:

How do to get/ make images to use in your game?

Most people use a graphics program, or graphics programs. You can use anything from professional apps like Photoshop, Illustrator ($$$) through cheaper apps like Acorn, Pixelmator (my choice, $) to free apps like Inkscape.

 
Flag Post

Topic: Game Programming / Best software for making 2D Apple or Android games?

Originally posted by pugzy:

It’s required that you give credit towards software you use when you create video games. This isn’t something that’s any different than any other copyright materials. You use a movie that uses a song? You give credit. You borrow someone’s code/software, you give them credit. You’re sounding like an ass by not giving credit.

Nonsense. There is no blanket requirement. In fact the vast majority of tools have no special requirements. You make your art with Photoshop, or your sounds with Audacity? No need to mention it. And programming tools are the same. Almost all of them want to get out of the way and let you make the best possible app or game. They don’t need to advertise to users if it would detract from the quality of the app.

In Unity’s case their splash screen mostly appears on more amateurish games so is not a very good advert. Anyone professionally making games will be able to justify paying the fee to remove it. It acts as a nag screen, to encourage developers who can afford it to pay for a licence, not an advert. Tools instead sell themselves by being good, being recommended by developers and being used in at least some high quality apps.

 
Flag Post

Topic: Game Programming / Best software for making 2D Apple or Android games?

You are wrong. All games are built from something; they all use tools, libraries, algorithms, art, sounds. Some may be created in house but many are made by other people. They can’t all be given a five second movie at the start, and there is no reason why the tools you used are most important. Often they are least important as the thing that could be most easily replaced; tools are often a personal preference more than anything.

How many games have you played recently that include a movie for the engine at the start? None that I have, primarily on mobile. So if it’s ethically and legally required many games are breaking the law. Except they are not. Ethically they may feel obliged to mention everything they used but this is often in the credits, or on a web site, sometimes many months later in a post-mortem.

It’s different if the licence you have requires you to mention the tools, such as Unity’s Personal Edition. But that’s a choice you make, to “pay” by including an advert for Unity, rather than paying for a Professional Edition license.

 
Flag Post

Topic: Game Programming / Best software for making 2D Apple or Android games?

I would rather have my own branding, and/or that of the sponsor or publisher. The problem is users’ attention spans are only so long, and if you include one too many splash screen they may go off your game. Without the Unity splash you can include another that actually benefits you. Disabling it would not be a feature of the paid version if it were not preferable or necessary, and many developers pay to be able to remove it.

 
Flag Post

Topic: Game Programming / Best software for making 2D Apple or Android games?

You need to pay for Unity to remove their splash screen, which you’ll want to do if you ship a game with your own or a sponsor’s branding. You can play around with it as much as you like though, putting off paying until you feel you have something worth selling.

 
Flag Post

Topic: Game Programming / Best software for making 2D Apple or Android games?

Yes, Angry Birds was made using Starling, which gives you some idea of its capabilities. Flash has always been able to do 2D, and Starling is essentially Flash’s 2D interface but accelerated so it uses you graphics card on your PC, the GPU in your phone and so is fast.

It is though mostly attractive to people used to Flash, ActionScript and Flash tools. If not you may find another language is more to your liking. Unity is also cross platform and targets more platforms than Starling but costs money if you want to do anything serious with it.

 
Flag Post

Topic: Game Programming / Best software for making 2D Apple or Android games?

Starling. It provides a 2D interface to Stage3D, the hardware accelerated 3D rendering system added to Flash in Flash 11. It works not just in Flash on the desktop but on mobile, so both iOS and Android. It’s free and open source.

http://gamua.com/starling/

There is no easy way in the sense of doing the work for you. You still need to do all the programming, so learn the language, the API, and then build your game on top of it.

 
Flag Post

Topic: Game Programming / Question about the Starling

Starling is better suited for games written entirely in code. These normally consist of a main class, usually a Sprite or MovieClip, which serves as the base layer for all graphical objects. Starling replaces/supplements this with its own main class, and provides methods and classes that closely mirror traditional Flash ones such as Bitmap, Sprite, BitmapData, using 3D rather than 2D graphics APIs for the performance boost/to access graphics hardware.

It would be harder to fit it into timeline. Probably it would need to exist as an entirely different layer, sitting on top of and so hiding much of the timeline stuff. It would almost certainly be easier to rewrite it all in code, using events for the timeline stuff.

 
Flag Post

Topic: Game Programming / Enemy Health AS@

(_root.live = 0)

should probably be

(_root.live == 0)

 
Flag Post

Topic: Game Programming / Help!: int. can't be null

Try changing
if(xtimes.length = 0) {
to
if(xtimes.length == 0) {

 
Flag Post

Topic: Game Programming / How to store bunch of objects?

A new Vector of 2000 objects does not use (2000 * object size) memory, just (2000 * reference size), so a few kb. Really nothing to worry about. If your IDs went up to a million maybe, but 2000 is not a problem.

As you populate the Vector with objects the memory is allocated for each object as it’s created, the same as when you have an Array of them, so the main memory cost is your objects. Though even with 2000 chances are they use less memory than a single graphics object or sound.

Vectors only do things differently for primitive types – int, Number, uint, Boolean – when they allocate memory all at once, which is far more efficient than a separate allocation for every number which an Array has to do.

 
Flag Post

Topic: Game Programming / [AS3] Pass by value

Make the function yourself: there is no clone() method as there is for BitmapData, and I think there’s a good reason for it: not only would it be little needed but you can probably do far better copying the object yourself, knowing what data needs to be copied, what needs to be modified when copied, which if any referenced properties also need cloning, what can be ignored or will be initialised by the default constructor and doesn’t need reinitialising, and so on.

 
Flag Post

Topic: Game Programming / shader filters - yes, but they work incorrectly sometimes

There are at least four ways you can use to embed shaders. The two I’ve used, both starting with .pbj files created in the Pixel Bender Toolkit, are

  • Flex’s embed syntax. E.g. Here’s code from my current app:
[Embed("../Shaders/wave.pbj", mimeType="application/octet-stream")]
private var filterWaveClass:Class;
gWaveShader = new Shader(new filterWaveClass() as ByteArray);
gWaveShader.precisionHint = ShaderPrecision.FAST;
gWaveData = gWaveShader.data;
gWaveFilter = new ShaderFilter(gWaveShader);
// and then when needed:
gWaveData.fAmplitude.value = [fFilterAmp];
gBoard.filters = [gWaveFilter];
  • Embed them as text, which I used on Wonderfl where you can’t embed assets. Here’s an example which you can see working

http://wonderfl.net/c/oHVd

The shader code is in a comment at the end. The shader is embedded as a Base64, which is done using the (unix/OS X) command

openssl base64 -in Life.pbj -out Life.b64

(The other two methods are loading the shader from a URL and including the assembly in a string which gets compiled by Flash. I’ve not tried either of those)

 
Flag Post

Topic: Game Programming / shader filters - yes, but they work incorrectly sometimes

I’ve had no problems running shaders without it hitting the frame rate. There is a performance cost as for everything but it’s no worse than many BitmapData functions, and is often much better. If you’re seeing a 0.5s redraw it suggests you’re doing something wrong, or at least that there’s significant room for optimisation.

 
Flag Post

Topic: Game Programming / shader filters - yes, but they work incorrectly sometimes

I’ve been using Pixel Bender in my latest project, and posting samples on my blog and on Wonderfl

http://johnblackburne.blogspot.com/search/label/Shaders

Once you get used to it it’s a powerful tool, with which you can quickly and easily generate effects that are slow and very difficult to do in ActionScript.

 
Flag Post

Topic: Game Programming / Finding the centre of gravity of a 2D object

Originally posted by jasonjie88:

What about calculating a centre of gravity by weighting the vertices based on their y-values? For example, if one point is higher than another, it weighs more.

No. One way to think about it is “what if I added a vertex?” E.g. add a vertex between two others. Move it slightly if you want so it’s no longer on a straight line between them, though that’s not needed. Then ask “what difference does that make?”.

If you’re just summing and averaging vertices then adding one more will tip your sum towards that vertex. And as one can be added so can ten or 100 on one side, without changing the shape at all.

If it’s triangles then adding a vertex creates a new triangle, or splits an existing one in two, but they are smaller and add up in size to the large one. So they contribute the same to the COG calculation. In fact adding vertices to create triangles can be part of triangulation to do the calculation.

 
Flag Post

Topic: Game Programming / Finding the centre of gravity of a 2D object

Average of the vertex positions won’t work. The image above is an example; it has far more vertices on the left side, so an average would be to the left of the actual centre.

I would do it by triangulating the object, if the shape is polygonal. The centre of each of those is 1/3 from each face, and the total COG can be found by doing a weighted average, weighted by each triangle area (as if the shape is uniform the mass and area are proportional).

 
Flag Post

Topic: Game Programming / Error in AS

You don’t have to invoke a green and pointy-eared warrior to justify such an ordering. E.g, considering a lottery win one might say:

“If the winner is me I will give up work”
or
“If I am the winner I will give up work”

Of course “If the winner is I” is more grammatically correct, though people look at you funny if you speak like that. And most people would just say “If I win [the lottery] I will give up work”.

 
Flag Post

Topic: Game Programming / Error in AS

What they wrote about ‘=’ and ‘==’. If you’re using the Flex compiler it will warn you of such things as they’re easy to miss. Or get in the habit of reversing such clauses, i.e. write them like this:

if (1 == movedirection)

Then if you leave out one of the equals signs you have something that’s impossible so which won’t compile.

 
Flag Post

Topic: Game Programming / Trigonometry vs. dictionary efficiency

It’s common to use lookup tables, but they look very different to that. You prepopulate a simple table, which in Flash’s case would be a Vector.<number>, with as many values as you need. Something like every degree might be fine, you probably don’t need any more accuracy than every 1/10 of a degree (so 3600 entries for the whole circle, using only a few kB of memory).

The best thing though is avoid trig if you can; most things can be done without them by working with directions and vectors.