Code Snippet

warning: Creating default object from empty value in /home/hplus/ on line 33.
This article contains a little code.
jwatte's picture

Alternatives to inheritance when creating game classes

There is inheritance, there is interface, and there is configuration. Inheritance (of a base class) is seldom the best or most efficient choice. Sometimes, newbies read the wrong tutorials, and start down the rabbit hole of class inheritance, but in the end, that turns out to be a dead end.

jwatte's picture

How to test for duplicate packets

If you're using UDP for your networking, you will typically mark your packets with a "packet ID." That packet ID will be used to detect the case of duplicated UDP packets, and sometimes also dropped packets.

jwatte's picture

Extracting packets from a TCP stream

When you send packets over TCP, you have to precede them with a byte count, because TCP just delivers a stream of bytes, with no particular block size. If you don't delimit your packets somehow, they will run into each other, and you won't be able to tell where one ends and the next one starts.

Managing a World of Entities in XNA

A structure that I find works very well when managing entities in games is the world/entity/component pattern. Entities in the world are nothing more than collections of components, where the components have the responsibility to "do something" with the entity.

jwatte's picture

Improved XNA Thread Pool object

This post includes a thread pool class for the XNA Framework that works better on the Xbox than the thread pool class in the Compact CLR. The main thread can choose to get notified about task completion with a callback function, or by waiting on a pre-allocated wait handle, or do fire-and-forget on the thread tasks.

jwatte's picture

Finding entities within a game world

In most games, you'll need to know where everything is.

jwatte's picture

Extracting Vertices and Triangles from an XNA Model

Here is some code that lets you extract the vertices and indices from a loaded XNA Model. You do not need to use any special processor, such as the JigLibX VertexProcessor or some derivative of the ModelProcessor -- it works straight out of the box!

jwatte's picture

A simple buffer class for network receive

When you develop socket receive code, you will soon run into the problem that TCP will send data in arbitrary blocks. Even if you send a given string in a single call to send(), that string may arrive as two separate recv() calls -- or may arrive glued together with some previous or following data. Or both.
jwatte's picture

How To Get Rid of Threads

It appears that school, tutorials, or whatever is teaching
about threads a whole lot these days, and most designs I see
from people learning the ropes involves a number of threads.
However, threads cause bugs, and cause extra synchronization
cost that's not easily visible, and not easily redeemable.

jwatte's picture

Win32 Programming Basics: A Simple Application

Todays assignment is to get a red block on the screen of a Win32 program.

Syndicate content