Audio and polygons!

We have been working on an audio manager for our engine, a process which has not been entirely painless. Not only do various browsers support different types of audio formats, they handle the audio tag differently, especially when trying to retrieve the file from a server. The way we have implemented it now however seems to work pretty well. When loading an audio file, the audio manager is supplied the file name without the suffix and then it proceeds to query the server about a file that is suitable for the users current browser until it finds one. This means that for the audio to work in all browsers the server has to supply the same audio file in the formats ogg, wav and mp3.

Not everything has been pain though, a cool new feature in the physics editor that was quite fun to implement is shown in the picture above, namely the ability to draw polygons! When drawing polygons, vertices are added one at a time by clicking somewhere on the drawing area. Because the polygon has to be convex in the physics engine, every time a new vertex is added we go through the shape to make sure everything still looks OK. If any point would make the shape concave as a result of adding a new vertex, that point is removed from the shape. This makes closely fitting a physics shape to the entity much easier.

Be Sociable, Share!

1 Comment

Leave a Reply