Sourcecode

This game is released under the GPL 3 license. It is free software and I encourage you to take what you find good in it and put it to use.

You are not required to do so by the license, but I as the originator would appreciate an email of what you found useful, and for what purpose.

All source code can be found in the git repositories for the client and the server

Where are the interesting parts

Stalker contains three concepts that goes beyound basic Android programming.

  • Geodesy calculations
  • Persistent background processes
  • Server - Client communication
The structure of the source would benefit from some harsh refactoring to make it more structured. But I will point out where the goodies are.

Geodesy

This is the part of maths that deal with measurements and representations of the earth. As such they are very important in a GPS based game.

They are done on two places, both serverside and clientside. The server side calculations is used to minimize the ammount of data that needs to be sent over the network.

Client side they are in the class GameInteraction.java which contains a java implementation of the haversine formula to calculate distances between two GPS locations.

An emplementation of the haversine formula in SQL can be found in the small server .

Persitent background processes

The application updates the users location to the server with an interval once per minute when in standby mode. While the game gets in to stalking/stalked mode the location is updated every two seconds.

This is handeled by the class SetLocation.java which is fired by the LoaddActivity.java and then calls the UpdaterActivity.java whenever it is time for a position update.

Server - client communication

Much of the game data is sent to and from the server. One architectural idea was that once the game was on between two players it should use a p2p connection. That has not been implemented yet. All of the communication to and from the server is handeled by the class GameServer.java The libray used is Apaches http for Android

All of the messages sent is expected to be valid JSON. A closer definition of the format is in the wiki.