float xspeed = 0; float yspeed = 0; float xpos = 0; float ypos = 0; player.xpos += xspeed; player.ypos += yspeed; // etc.
For a start it doesn't really look very nice. It also is not reusable, and you have to make it even more convoluted to do some of the more advanced math needed in games. The better alternative is to use vectors. Using vectors we can do movement something like this:
2DVector speed; 2DVector position; player.position += player.speed;
You will probably have realised that this is going to require knowledge of overloaded operators among other things. This should be a great challenge and I look forward to seeing what people can come up with. Other functions that could be included are dot product, normalise etc.
Extra points for creating a template class so you can easily switch between ints, floats and doubles depending on how much precision you want. Use any language you want but C++ would be great Feel free to ask questions within this thread so we can all collaborate.