It’s about time I introduced my latest project! I started working on this a few weeks ago and now I’m finally able to show something to the world. I have divided the project into several “milestones” and now I have reached the first one. Each milestone is a finished part of the entire project.
So what is this project about? It is a location-based game, inspired by the classic Dope Wars game. In the game, you are a drug courier and your goal is to make money buying and selling drugs. Drugs can be obtained from dealers, farms and laboratories. Of course, the police will be on the lookout, and you can be arrested at any time! Of course, you won’t go down without a fight…
The game is location based, meaning you’ll have to get outside into the real world! The locations in the game are real world locations, placed randomly on the map. The game requires GPS, you it’s best to play it in an area without tall buildings so you have good reception.
The first project milestone consists of a map generator. When you start a new game, various locations are placed randomly on the map. You enter a name for the game, select the desired size of the playing area (1, 2 or 4 square kilometers) and when the GPS has a decent fix, the map generator can be started. The location you’re at when doing this will be your safe house, where you can store things when you don’t need them (or don’t want to get caught with).
The map generator required a bit of creativity. The locations had to be placed random in the area, but there had to be a minimum distance between them. I thought about several ways to do this, but the solution I found is quite elegant. I started by generating 1000 random locations in a certain radius around the starting location. Being completely random, they could be any distance from each other. Here’s how I made sure the points I end up using are far enough apart. I have a list of 1000 completely random points. I take the first point and start calculating the distance between this point and each of the 999 other points. If a point is, let’s say, closer than 100 meters to this point, I remove it from the list. When I’m done cycling the list, all points in a 100 meter radius around the first point have been removed. This is repeated for all other remaining points. This takes a few seconds, but the speed is acceptable.
After that I end up with a much smaller list of locations, but still more than I actually need. I then gradually increase the allowed distance between the points and repeat the process until I end up with the number of points I need, with the maximum amount of distance between them.
The final step is making sure all locations can be easily reached. Since the locations still consist of random coordinates, they might be in a place you can’t possibly reach, such as the middle of a river! Luckily, Google has a service called the geocoder. The geocoder takes coordinates and finds the nearest street address. I use the coordinates of this address and voila, I have a random location that can always be reached! There’s one disadvantage I probably won’t be able to solve, however. When you’re in an area that doesn’t have many roads, all generated locations will be placed on the available roads, and they will probably end up too close together. Playing the game in such a place would be kinda boring. The best environment for the game would be a town with a pretty dense road system, but without skyscrapers.
So what kind of locations will you visit during the game? First of all, you have a safehouse. You can hide cash, drugs and weapons in there, but remember it’s not burglar-proof! There will also be several drug dealers. They buy and sell drugs, and by keeping an eye on the prices you can make a nice profit. On medium and large maps, there are also farms and drug laboratories. From time to time, you can buy drugs there at much lower prices, so you can make lots of money. Speaking of money, if you’re running low on cash, you can visit a loan shark to borrow some, but you better pay him back quickly! There’s also a weapons dealer where you can buy guns and ammo. And finally, there are cops and competitors. You won’t see these guys on the map (they’re undercover) and can stop you at any time. The competitors, by the way, are NPC’s, it’s not a multiplayer game. The game has no time limit. You can play until you get killed. This can be in a police shootout, a loan shark you didn’t pay back in time, or a competitor.
Here are two screenshots so far. The first one is the map generator. I’m not too happy about the colors, so I’ll probably try lots of other color schemes until I find something I can live with. The second one is a map of the area surrounding the Google HQ, with random locations. The icons are the default Android icon, but I’m working on a nice icon set. This time, I’m not gonna make the mistake of waiting until all coding is done to get started on graphics!

