Intermediate

warning: Creating default object from empty value in /home/hplus/enchantedage.com/modules/taxonomy/taxonomy.pages.inc on line 33.
You've been doing it for a few years.
jwatte's picture

Drawing silhouetted characters behind smoke particle systems

A question came up on the XNA forums: "how do I draw the silhouettes of objects in red when they are covered by smoke?"

Here is my proposal on how to use destination alpha to do it:

0) When setting up the back buffer, make sure you get destination alpha:
  graphics.PreferredBackBufferFormat = SurfaceFormat.Color; // has alpha

jwatte's picture

Triggers in XNA games using C#

"So," you may ask yourself, "what if I figure out a way to detect that the player has hit a button, or stepped on a landmine, or entered a goal zone?

jwatte's picture

Rigid Body Physics in C#

Let's assume you're trying to simulate a car driving on an uneven terrain (perhaps some sort of heightmap). Let's assume you know how to measure the distance from the car's chassis to the heightmap ground at any position (typically, measure the height of the heightmap, and subtract the height of the car at that point in the XZ plane).

jwatte's picture

Profiling an XNA game on Xbox

This code file implements a simple profiler for XNA games that run on the Xbox.
It allows you to measure the amount of time spent in different parts of your code,
and bins the different durations into statistics bins (so you can see if it's
"spiky" or even).

jwatte's picture

HTTP-GET source code download

If you've ever wanted to read web pages into your C or C++ program, then this code is for you. It's the smallest possible code that will let you read arbitrary web URLs into your own program. It does NOT have any kind of interesting features, and is not coded to be fully standards compliant, but:

  • it comes with source
  • it's very small
  • it works
jwatte's picture

Myths and realities related to high-quality digital audio formats

On competent recordings of normal program material, with excellent equipment, nobody has shown that they can consistently tell the difference between redbook (regular CD audio, at 44.1 kHz sampling rate and 16 bit word depth) and higher-rate/wider audio formats.

jwatte's picture

How to re-construct messages on the receiving side

Once you've gotten your message buffer sent to a receiving end (through a file or network interface), you can inflate and re-construct the same data structure using the MsgIn class. Note that the current marshalling code does not compensate for varying byte order across networks, but because all computers you'll be running this code on are little-endian, that probably doesn't matter to you.

jwatte's picture

How to use the generated code: MsgBase.h

The generated code makes use of the pre-defined visitors in MsgBase.h and MsgBase.cpp. It also needs you to generate a source file for your packets file, using perl -MSource Packets.pl. The generated source code is simple:

/*
 * This file was auto-generated on 2008-11-15 11:16:13
 */
 
#include "Packets.h"

jwatte's picture

The output: templates that describe your packets

If you run the perl script, passing in the "Headers" module, it will print the declaration of your data structures to the console output. The included rules file lets you do this automatically as part of a Microsoft Visual Studio project, but for now, try doing it on the command line. If you don't have perl installed, get it either as part of Cygwin, or from ActiveState.

jwatte's picture

The approach: writing a high-level description of each data unit

The idea is to describe your various data structures using a basic high-level language, and then generate the necessary code machinations to go between that description and byte streams automatically. This example uses a custom Perl script, although there are various standardized tools that can do the same thing (such as the ASN.1 standards suite).

Syndicate content