dinsdag 27 oktober 2009

Network code and Leveleditor

Hey there,

I haven't had much time to code today and yesterday, but during the remainder of the weekend I've been able to make a good start with network code:

It's not much yet, but the server listens and waits for the appropriate packet header, returning an accept packet to the client containing information such as the level filename, the server name, the player's team, etc.

I tried to implementing this in the client and realized client.c had become one giant mess of code, so I decided to clean up both the client and the server and split their functionalities in different source files. Some globals and routines are shared by both server and client, so they get used in both, but my goal is to keep any GL/Audio/Image loader dependencies out of the server code, so it can basically run on a text-only distro.

When the functions were split out I started to realize a major influence on the structure of the traffic between server and client depended on what the game mechanics and levels looked like.
I decided to start working leveleditor for a couple of reasons:
  • Designing the level editor forces me to focus on the internal representation of the level and the game, and how it will be drawn, processed and communicated.
  • Working on the editor gives me a little more time to get to know opengl/glut
  • When the drawing code is finished for the editor it can be directly fit into the client in a more basic shape.
  • With a finished level editor the basic game mechanics can be programmed and the game can be fully tested, with stub textures and icons, if needs be.

Anyway, so far the editors allows for creating a bunch of vertex points that will form a closed polygon and lets you switch between those:


A problematic discovery was that the openGL GL_POLYGON primitive only draws convex polygons correctly. (convex polygons are polygons that have no interior angles greater than 180 degr). In order to draw concave shapes correctly, they need to be split into triangles, the official term for which is 'tesselation'. I'm now trying to figure out the built-in OpenGL tesselator, which should allow all the following fancy things without problems:

(image source: The Red Book. Couldn't find any copyright information)

All this stuff is not really necessary: I could just program the editor to construct only triangles, but this would be alot les nice for the user and this approach will allow for some pretty fancy game effects later. Let's hope I don't go crazy in the process.

Geen opmerkingen:

Een reactie posten