Iterative version of Ramer-Douglas-Peucker line-simplification algorithm

In one of our games we needed to beautify user mouse or touch input. Actually it isn’t simple task since there can be found many criteria due to point reduce. I have tried several solutions like discovering big angle change between segments (built of last given input points), big distance discovering, Catmul-Rom curve approximation and even joining all of those methods.

Later on I have found Ramer-Douglas-Peucker algorithm which helped to reduce unneeded points in a more visually proper way. In the end I’ve been reducing points by small distance and little angle between segments to put less points into the algorithm. Since it had to be done in realtime that wasn’t enough of optimizations. Next optimization was to make the iterative version of Douglas-Peucker algorithm.

→ Continue reading

“Just” implement tutorial into the game

Today many games need tutorial. Tutorial is a hot topic for discussion in indie games community. Anyhow, for programmer-non-designer tutorial implementation is just a job which comes with unwanted problems. Most of them appear because it tends to be made in the end of project. And worst situation is when tutorial is being done incrementally.

I will not discuss topic of tutorial design. Instead I’d like to present some notes about coding a tutorial in online game which are derived from my experience and observations. In the end I’ll give my advices for coding tutorials.

→ Continue reading

Quick implementation of Network for existing Game

There are 2 common choices of architecture for game network implementation:

  1. client-server
  2. peer-to-peer

What I did was some kind of hybrid of those two. I used Remote Procedure Calls (RPCs). In this post I will describe this technique giving some basic examples showing the role of server and actually giving it some tools to do it’s role as a server.

→ Continue reading

Unity – is this point within a box?

I am currently using Unity for two weeks and I have started to implement logic and graphical tweaks into mechanics. It happened that I needed a little math to correct some calculation failures based on user mouse or touch input. A simple check was needed – is a given 3D point contained within a box?

I was pretty disappointed that Unity does not have such functions already made. And even more disappointed I couldn’t find ready solution for Unity-specific library code. Actually many folks use Physics.Raycast() instead which is ugly. The sad fact is that many creators do not have any idea what they are doing by using Raycast.

Below you can see the code for such point-box check. If you need it, figure it out yourself how it works.

Adobe AIR trick: Faster file loading on development machine

I had pretty weak company computer in my recent job and also pretty old rubbish Windows installation. Because of that, duration of loading our Adobe AIR game was about 14 seconds. Colleagues had better times, like 11 seconds. I was curious if I could make it faster.

Every change in code made whole application recompile, restart and load again. I disliked it more and more, then a simple idea came to my mind:

if you don’t want to waste time on loading every time, then load it once!

Actually, why not. Easier said than done, right? Load whole data into RAM in another application and then send it through sockets to the application.

So I wrote simple application in C# which reads all files (graphics, sounds, etc.). I have also added new option of loading data to the game – through sockets. Result – came down from 14 seconds to 7 seconds! I could have done it earlier.

Swype language on Milestone 2

Motorola Milestone 2 showed up with built-in Swype app. It’s handy but for those whose mostly used language is installed in it. My language wasn’t there so what can I do to use Swype? The only way was to uninstall old version and install the newer one.

→ Continue reading

Visual Studio 2010 also may be messy

My C: partition on Windows is too small so sometimes I have problems with space. I have made a recent discovery that not only Windows itself but also Visual Studio 2010 is an out-of-space-situation helper.

C:\ProgramData\Microsoft Visual Studio\10.0\TraceDebugging

This is where you may find lots of files which will not be probably needed anymore. I’ve just deleted 2.5GB from there. I’ve got shocked it would be that much.

I recommend WinDirStat. It’s a cool and simple application that helped me to find the path given above.