Code Snippet

warning: Creating default object from empty value in /home/hplus/enchantedage.com/modules/taxonomy/taxonomy.pages.inc on line 33.
This article contains a little code.
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

Widgets and Scene Graph

To implement a GUI, there are a number of widgets provided in the support library (text edit box, rotary knob, slider, selector, pushbutton, checkbox, etc). Given that ItfWindowSlave interface, a plug-in can also implement custom widgets. The widgets, in turn, use the retained-mode scene graph to describe what they look like.

jwatte's picture

GUI Windows and Slaves

A plug-in can be called upon to open a GUI representation of its parameters. While the support library will provide a default GUI for a plug-in that doesn't want to customize itself, most plug-ins want to do something fancier.

jwatte's picture

Plug-in Host Interface

Plug-ins are broken into two parts: The part of being a "plug-in" (a DLL or .so that is hosted in a host process), and the part of being an "effect" (an object that can process audio or MIDI data). A single plug-in can provide multiple effects. This allows for code re-use, allows you to wrap some other API into a single plug-in for SAPS.

jwatte's picture

Basic type definitions

There are only a few basic types used in SAPS.

jwatte's picture

Version 2.0 proposal (with code listings)

Various parts of the SAPS API are described as C++ pure abstract classes. These are similar to interfaces as used in some approaches (COM, .NET) in that the define the ABI and intended functionality of different entities, but do not define anything about the implementation.

jwatte's picture

Making a sprite follow a path

A while back, I posted a simple program on the XNA forums that showed how to define a path, and then have objects follow that path. I figured I'd copy the code from there onto this site, for easy reference. The program below is a command-line C# program; you can compile it from the command line with "csc flypath.cs" and run it to test it out. Or you can copy the "follower" class from the middle, and use it in your XNA project. (The additional code, including the declaration of Vector2, is just there to make the test program work stand-alone)

jwatte's picture

Ah, yes, GCC and MSVC... Or, two compiler bugs in two hours.

Why is it that seemingly every week-end project ends up in tears and teeth gnashing over broken tools, instead of sweet progress? Why do computer companies keep cramming useless features into bloatware, instead of just making what they have, actually work?

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).

Syndicate content