# Question
Title: Platform for DS/Gameboy Dev - Managed Memory, Tools, and Unit Testing
I'm interested in dabbling in Nintendo DS, 3DS, or GBA development. I would like to know what my (legal) options for development tools and IDEs are.

In particular, I would not consider moving in this direction unless I can find:

* A programming language that has managed memory (garbage collection)
* A unit testing tool akin to JUnit, NUnit, etc. for unit tests

I would also prefer if other tools exist, like code-coverage, etc. for that platform. But the main thing is managed memory and unit testing.

What options are out there?

# Answer
GBA and DS dev is **not** open to individuals, neither the software or the hardware used in development can be acquired unless you are an employee of an established game development company.

That being said, there was a fairly good homebrew GBA dev community back in the day, and I think it has carried on into the DS somewhat.

Check out http://gbadev.org, they have a lot of good info on what it takes to make a GBA game.

Personally, my first game before getting into the industry was a homebrew GBA demo. I had about 6 months of programming experience after reading a book on C++(which I didn't finish) and I was able to make a small demo, so it's certainly doable with the rights tools.

As I recall, I used VBA, tonc's awesome tutorials and Programmer's Notepad with GCC(info at tonc) to make my little demo in C++. It was a great learning experience and really not terrible difficult for someone who's coded before.
> 3 votes

# Answer
Don't let the lack of memory management scare you off. A rudimentary smart pointer class is surprisingly easy to create on your own, and there are lots of other easy ways to simplify managing your memory:

* Use static objects for things that you need one or a fixed number of.
* Use object pools for objects you need to create and destroy dynamically and whose lifetime you don't know.
* For transient objects (things that you don't need for more than a frame) a simple per-frame allocator (similar to auto release pools in Objective-C) will work well.

If you want to code for the GBA or DS that implies to me that you *do* want to go a bit lower-level than the average Flash game, and memory management is part of that. Give it a try and you may find it's not as bad as you feared.
> 3 votes

# Answer
Your legal options? None short of getting a Nintendo dev license. And I doubt that's going to happen.

Unit testing, managed code? I seriously doubt that. AFAICS, you need to code it in assembly, or native C/C++. I feel some C++ unit testing framework will probably work though..maybe not for the DS specific bits.

For actual development, the one that came up a lot from Google was DevKitPro. Tutorials are available here. (Though the library doesn't seem well documented.)
> 1 votes

---
Tags: tools, nintendo, ide
---


# Question
Title: Disabling depth write trashes the frame buffer on some GPUs
I sometimes disable depth buffer writing via glDepthMask(GL\_FALSE) during the alpha rendering of a frame. That works perfectly fine on some GPUs (like the Motorola Droid's PowerVR), but on the HTC EVO with the Adreno GPU for example, I end up with the frame buffer being complete garbage (I see traces of the meshes I rendered somewhere, but the entire screen is mostly trashed).

If I force glDepthMask to be true the entire time, everything works fine.

I need glDepthMask to be off during parts of the alpha rendering. What can cause the framebuffer to get destroyed by turning the depth writing off?

I do clear the depth buffer initially, and the majority of the screen has pixels rendered with depth writing turned on first before I do additional drawing with it turned off.

# Answer
Having glDepthMask disabled during flip may cause the problem. Probably a driver issue; best to update the drivers (i.e, get a new ROM) at some point, but as a workaround keep it turned on as much as possible.

EDIT: actually, glDepthMask seems to affect glClear, so this may not be a driver issue after all.
> 3 votes

# Answer
Shouldn't glDisable(GL\_DEPTH\_TEST) disable writes to the depth buffer as well? Maybe that fixes it for you.
> 0 votes

---
Tags: android, opengl-es, depth-buffer
---


# Question
Title: Efficiently representing a dynamic transform hierarchy
I'm looking for a way to represent a dynamic transform hierarchy (i.e. one where nodes can be inserted and removed arbitrarily) that's a bit more efficient than using a standard tree of pointers . I saw the answers to this question ( Efficient structure for representing a transform hierarchy ), but as far as I can determine the tree-as-array approach only works for static hierarchies or dynamic ones where nodes have a fixed number of children (both deal-breakers for me). I'm probably wrong about that but could anyone point out how? If I'm not wrong are there other alternatives that work for dynamic hierarchies?

# Answer
Well.. judging from the discussion, I'd say if the changes are frequent, the tree model wins; if changes are infrequent, the array model wins (it's ok to rebuild the array if it's rare)..

In a real-world case some hybrid might be the optimal, leaving most of the hierarchy static while other parts are dynamic.

I didn't post this as an answer before though, as someone might have actual experience on the matter, instead of just pondering on it on an algorithmic level. In any case, I'd look into this only after it's found to be an issue.
> 0 votes

# Answer
One quite efficient representation is an array of matrices combined with an array of parent indices. If you keep things sorted, and updates is just a loop over the array. See Practical Examples in Data Oriented Design by the BitSquid guys. You might not need to resort that much depending of your change patterns.
> 3 votes

---
Tags: efficiency, tree
---


title: Game mechanics patterns database?

text:
# Question
Title: Game mechanics patterns database?
Do you know http://tvtropes.org ?

It's a kind of wiki/database with scenaristic tropes, patterns that you can find in tones of stories, in tv shows, games, books, etc.

Each trope/pattern have a (funny) name and there are references to where it appears, and the other way arround : each book/game/etc. have a list of tropes that it contains.

I'm looking for an equivalent but for game mechanics patterns, something like "Death is definitive", "Perfect physical control (no inertia)", "Excell table gameplay", etc.

I think it would be really useful. I can't find an equivalent for game mechanics (tvtrope is oriented to scenario, not game mechanics).

Do you know any?

# Answer
I know you disregarded tvTropes in your question, but they have a page for video games with a section for common gameplay tropes.

Videogame Tropes
> 6 votes

# Answer
Ernest Adams' No Twinkie database. It's a collection of game design anti-patterns.
> 7 votes

# Answer
Noah Falstein's 400 project is pretty much the closest I can think of:

The 400 Project @ theinspriacy.com
> 2 votes

# Answer
Giant Bomb's list of video game consepts (wiki-system, so anyone can edit) has many game mechanics listed and even lists which games have the mechanic.

Some game mechanics have a long description page like moral decisions.
> 1 votes

---
Tags: game-mechanics
---


# Question
Title: Porting Ruby/NCruses Rogue-Like to .NET and FlatRedBall
I created an awesome rogue-like game in Ruby. For the GUI, I used NCurses. Since I'm using FlatRedBall as my engine of choice for Silverlight game development, I want to port this game over.

**What is the best way to efficiently doing this, and what are the pitfalls I should expect?**

For example, Ruby is object-oriented, like C#, and I should be able to just convert (rewrite) classes one by one. However, I will run into issues like:

* NCurses API. I need to possibly create my own notions of a "Window", or else rewrite GUI code. It's one class, but it's BIG.
* Mix-Ins. These are essentially aspect-oriented development. There are a couple of solutions in .NET, like dynamic classes.

What else? Also, I should mention that I want to create a **FlatSilverBall (C#) application** out of this. That is to say, I will be using the FlatRedBall 2D engine as my foundation. I *am not interested in Curses,* or any other variation that will allow me to make a console-type game.

As much as possible, I'll dump reusable and helper code, algorithms, etc. into separate projects and generate reusable DLLs.

# Answer
As I see it, you have a few options:

1. Port to IronRuby, build your ruby code as a .NET library, then rewrite the engine links in C# or IronRuby. If your game's logic is already all in Ruby, no reason not to try and preserve it as a library and then write new code to interface with it.
2. Do a rewrite. This is probably how I would approach it. C# is not Ruby, and trying to do a direct port is likely to result in frustrations. Better to adapt what algorithms and structure you can, and then rewrite in C# so you can approach problems "the C# way" instead of trying to adapt a Ruby methodology to a different language.
> 4 votes

# Answer
While directly porting the classes, et cetera, over is possible, the biggest issue to be aware of (when discussing the problem at such as a high level as you are) is the different semantics for various operations and paradigms between two languages.

It doesn't look like you have much selection in terms of NCurses APIs for .NET (I found this, but it looked Mono-focused and thus may not meet your needs. So it sounds like you may need to rewrite that aspect of your program. System.Console has a few features that may be useful, but likely is not robust enough to replace a curses-based UI unless you were using very simple stuff.

I would be careful with porting your mix-ins. There are frameworks for aspect-oriented programming in C#, but they are generally extremely heavyweight and probably not suitable for games. Hand-rolled dynamic class generation is an option, but is still likely going to be more work than it's worth for the features and behavior you're likely getting from your mix-ins. It may be best simply to port these features as individualized objects that you aggregate inside other classes and defer to.

It's hard to provide much more direction without knowing more about specific technologies and techniques you employ in your game.
> 2 votes

# Answer
There is the absolutely great libtcod you could try. Basically, it is a console emulator/Curses type console. In more detail, it is a fully fledged rogue library (i.e. dungeon generation, FoV calculation, heightmap generation..which may be useful?). It is written in C/C++, but it has wrappers for C# (and the documentation is great for all of its supported languages).
> 1 votes

# Answer
> Mix-Ins. These are essentially aspect-oriented development. There are a couple of solutions in .NET, like dynamic classes.

Mixins are definitely *not* like AOP. You can get much of the benefit of mixins in C# using interfaces and extension methods. For example, here's a mixin and a class that includes it in your code:

```
# Defines functionality that any class that mixes it in can have:
module ValuableObject
  def effective_cost
    raw = self.cost # Implicit requirement on mixing-in class.
    if raw < 10000
      return raw
    elsif (raw >= 10000 && raw < 1000000)
      return "#{raw.to_s[0 ... -3]}k"
    else
      return "#{raw.to_s[0 ... -6]}m"
    end
  end
end

# Class that mixes it in:
class Weapon < Item
  require "classes/modules/ValuableObject"
  include ValuableObject

  attr_accessor :cost

  # More stuff...
end

```

That translates directly to C# like this:

```
// Makes mixin's requirements on host class explicit:
interface IValuable
{
    int Cost { get; }
}

// Any class that implements IValuable will mix in these methods:
public static class ValuableExtensions
{
    public static string GetEffectiveCost(this IValuable valuable)
    {
        var raw = valuable.Cost;
        if (raw < 10000) return raw;
        else if (raw >= 10000 && raw < 1000000) return (raw / 10000) + "k";
        else return (raw / 1000000) + "m";
    }
}

// Class that mixes in:
public class Weapon : Item, IValuable
{
    public int Cost { get; set; }

    // More stuff...
}

```

With that, you can then do:

```
var weapon = new Weapon();
weapon.GetEffectiveCost();

```

Don't reach for dynamism unless you're actually doing something dynamic.
> 1 votes

# Answer
Are you looking to have a text-based interface like typical roguelikes? If so, isn't the most obvious approach to store chars in a 2d array or other structure? Then you can concat each char to 1 single string (with newlines where appropriate) and draw that each frame with `SpriteBatch.DrawString()`, then when the player moves update the structure, concat the elements, and start drawing *that* string each frame? I've got a feeling your display code will end up a lot simpler (or at least more straightforward) for the same relative results.

Or if you're looking to ditch ASCII, just use a tile engine.

Either way, you essentially just need to replace the visual component of your game, right? I've got a feeling you may be able to whittle down your Window code since you'll no longer be dealing with Curses. Take this as an opportunity to cut/rewrite parts of the code, since though some techniques might make sense in Ruby may be a pain to manage in C# or vice versa.
> 0 votes

---
Tags: c#, roguelikes, ruby
---


# Question
Title: How do I inform the end user about cheat codes?
I have added an interface to input cheats, and of course the backend of this.

Current cheats include:

* unlimited health
* unlimited time
* faster movement
* no need to use keys (I have a door/key system)
* triple firing lasers (normally there is only one)
* grenades (changes your weapon to grenades)

How will I tell the user the cheat codes? Normally, cheats would be sold by the programmer, but this isn't that sort of game currently.

# Answer
> 11 votes
## Put a cheats menu in the pause menu.

Before you allow the cheats to be used, warn the user that his current game/score will be invalidated if he wants to continue and use the cheat, but only warn for the first time in a session if they are using a cheat, so if they use one they can use the others with impunity.

## Allow a user to unlock them somehow by playing through content of the game.

If you want to give them the codes you can either have the cheat code number be reviled to them if they reach a certain part of the game or reach a certain score, or unlock a certain achievement. Alternatively you can have the user just unlock it from the menu when reaches whatever criteria you set for it.

# Answer
> 8 votes
A creative way to tell the users about possible cheat-codes would be to hide them somewhere in the game content.

Examples:

* A wizard you meet in a side-quest tells you about his secret *spell of haste* which goes like this: *Right, Right, B & A*.
* Somewhere in the game you see a graffiti on the wall: *Down, Down, Up, B = No Key*.
* Hide a cheat-code in secret areas of a level.
* Unlock/show cheat-codes to the user when he achieves a special score or some other achievement that is hard to get.

It's up to you to make some of the cheat-codes really easy to find or almost impossible to discover.

As other have said: People that use a cheat-code should probably be excluded from any competition where they get an unfair advantage due to cheating (highscores?). A hint/warning next to the "cheat-input-field" should probably be good enough.

# Answer
> 3 votes
Well When I play games I absolutely hate the opportunity to cheat until I've played the whole way through. Because I'll get frustrated with one part and want to skip it, so I'll revert to cheats, but it will make the whole game horribly boring!

What I'd do is have the player run through at least once before enabling cheats. Then once you do, enable them all, because it really should open up the game, make it a sand box of sorts.

# Answer
> 0 votes
Put them in the **manual** and tell users to be careful. Unless you feature online highscores, it's absolutely the responsibility of the user not to cheat unless they have good reasons to do so (i.e. workaround a bug, played through the game 1000 times but don't want to play the first levels again each time, ...).

Many games keep cheats totally disabled by default and a INI hack is needed to enable them. That would be a useful way to protect users from themselves and their desire to cheat without thinking (assuming their is something like that ...).

---
Tags: game-design
---


# Question
Title: What kind of skills are required to work in a content pipeline department in a high level role
I'm looking more for high level role such as producer/manager of the group making the tools for a content pipeline. This would be for a large AAA studio.

Also what kinds of tools are they creating?

# Answer
> 3 votes
Production management or technical management skills, or both, depending -- and experience.

Some studios don't clearly differentiate between **production** (in this context I mean the scheduling and pipelining of tasks across each internal team, assisting in bug triage and balancing, ensuring all team dependencies are satisfied, that your schedule is accurate and that you are trending towards ship) management and **technical** management (which I mean to be more about the architecture of the in-code systems that implement the tools), and so you'll probably need both, or at least to be focusing on whichever one of those interests you more. That kind of role is almost always sourced internally, though (i.e., by promoting existing programmers or producers) so your best bet is to get an entry level position in the approximate area you're interested in and work your way up.

Studios with dedicated tools teams generally have those teams because they require tools that are unique to their product's production goals, and so they're usually not building the same thing except in very general terms -- usually tools revolve around asset/content creation, management, and tracking. Especially with large, AAA titles tracking/reporting/metrics concerning content and content production can be extremely important due to the shear volume of data.

# Answer
> 3 votes
If you have to ask what kind of tools they are creating, then you won't be able to go straight into a job like that. That's if such a group exists, of course - not everywhere has dedicated tooling departments, and even if they do, they don't necessarily have a separate manager for that department (since most of the technology will be shared with the game developers).

I would expect the typical route into such a role would be to start as a tools programmer and be promoted up to a supervisory position.

# Answer
> 1 votes
I'd expect the primary requirement would be experience, if not specifically of the role you want at least some relevant game development / management experience. Have you tried looking around for available positions and seeing what skills they say are important?

Tools could be anything from basic texture converters to complex game editors that let the designers create the game like the Unreal Editor.

---
Tags: architecture, tools, textures, pipeline
---


# Question
Title: Making game constants/tables available to game logic classes/routines in a modular manner
Suppose I have a game where there are several predefined constants and charts (a XP chart, cost of goods and so on). Those could be defined at runtime, or load from files at start-up. The question is how should those logic routines access the constants and charts?

For example, I could try using global variables, but that cause all classes relying on the variables to be tightly coupled with them.

# Answer
> 3 votes
It really depends upon what type (and quantity/size) of data you're talking about. If it is a small bit of data that can be safely kept in memory for the duration of execution, something like a static class would be my recommendation.

```
public static class Constants
{
    public static int[] Levels = { 0, 100, 200, 400, 800, 1600, 3200, 6400 }
}

```

This way, the experience required to get to Level X is `Constatns.Levels[X - 1];` and accessing other data is easy as well, if you need a collection of Items, you can add it here too, if your Items data is too large to store in memory, you can also implement caching logic within the static class.

Making it static keeps a single copy in memory, and ensures that every client of this class is getting the same data.

While this does "tightly couple" your classes together, tight coupling is not a bad thing if the design really needs it, which in the case of Item stats and XP charts, it is, IMHO, reasonable to tightly couple these. I always try to keep it simple, until something forces it to be complicated.

# Answer
> 3 votes
Create an object to represent each piece and pass that object in to functions that need it. This is no different to any other data- you pass it around.

# Answer
> 2 votes
I recommend using one globally accessible class - lets call it Dictionary (using flash terminology). The Dictionary is basically a list of name-value pairs (data, rules, constants) you want accessible throughout your application. Using the name (string) other classes will be able to retrieve the values (numbers, string, classes etc) which are interfaced into your code. So your implementation is basically IOC except the instantiation has been previously done in the Dictionary. You can also listen to changes to the Dictionary, etc.

# Answer
> 0 votes
Well if you were using Java then I would reccomend putting your data in XML files and using something like JAXB or simple-xml in order to get the data that you want in the right objects.

---
Tags: software-engineering
---


# Question
Title: Projecting onto different size screens by cropping
I am building a phone application which will display a shape on screen. The shape should look the same on different screen sizes. I Decided the best way to do this is to show more of the background on larger screen keeping the shapes proportion the same on all screens.

My problem is I am not sure how to achieve this, I can query the screen size at runtime and calculate how different it is from the six is designed for but I am not sure what to do with this value.
What kind of projection should I use for my orthographic matrix an hour will I display more on larger screens and not loose information on smaller screens?

# Answer
> 3 votes
Consider scaling your shape so that it's as large as possible while still fitting within the target viewport. In order to do this, you need to consider the ratios between the widths and the heights.

```
float width_ratio = target_width / source_width;
float height_ratio = target_height / source_height;
float scale = Math.Min(width_ratio, height_ratio);

```

Edit: Once you've scaled your shape, its coordinate system lines up with that of the screen. In order to center the shape on the screen, you need to translate it by `(target_width - source_width) / 2` or `(target_height - source_height) / 2`, depending on which dimension has extra space.

---
Tags: opengl, mathematics, matrix
---


title: Rendering Resolution Independent Text

text:
# Question
Title: Rendering Resolution Independent Text
I need a way to draw resolution independent text in my game. That is, I need to be able to zoom in on text and never see pixel artifacts.

Can anyone make any suggestions on how I could go about it?

# Answer
There's three common ways to do it. It's not really about eliminating artifacts entirely - which is impossible, unless you have unlimited memory or processor time - but rather how to minimize them in a way that fits with your existing code and target platforms.

First, just use your font rasterizer - usually FreeType - to rasterize the font at the size you want as you zoom in. This will look great in screenshots, but it is incredibly slow. You can solve the slowness by caching sizes, but then it becomes incredibly memory-hungry. It also does not look great in motion, because making glyphs look good for static display requires scaling them non-uniformly. Still, it's an option if you are on a platform with enough memory (like a PC) and your scales are bounded to some small range, like 10px to 30px. This method also does not admit a lot of eye-candy by itself.

Second, you can store your text as a mesh. Some libraries exist to do this, like GLTT, or you could write your own. Now you no longer have pixel artifacts, but you will have polygonal artifacts if you zoom in very close - just like any other mesh in a 3D game. Mesh text admits a lot of eye candy since vertex shaders can be applied and the mesh can be interleaved with any other world drawing you do. It is reasonably light on memory and CPU, and easy to measure the cost of since it's just a standard mesh. It can be a pain to integrate into a normal sprite-based 2D rendering pipeline.

Third, you can use distance fields in combination with a pixel shader. This is a relatively new technique that is currently popular, using simple shader to sample a premade texture and the "free" bilinear filtering on your video card to scale up glyphs cleanly. It uses little and easily-predictable memory compared to other methods - a 0.5MB to 1MB texture per character set per font. It fits nicely into sprite-based rendering pipelines because it is sprite-based; each glyph is still a textured quad. It does produce pixel artifacts, but very few compared to other methods that scale textures. There is also a fixed-function fallback if pixel shaders are unavailable, but the text ends up very aliased. Because the sampling is done in a pixel shader it admits some eye candy, like outlining and shadowing, for cheap.
> 7 votes

# Answer
There is also a research article from Microsoft Research by Loop and Blinn, on rendering resolution independent curves using shaders. It suggests using the presented technique to render TrueType text in a resolution independent fashion.
> 3 votes

# Answer
You'll need to build your font characters out of a combination of curves and lines, which you then convert to geometry with a suitable level of detail at runtime.

Fortunately most fonts are already built from bezier curves. To get the curve data you just need to use the standard Windows GetGlyphOutline() function to extract them.

I'm not sure if you can get that curve data from C# without PInvoke.
> 1 votes

# Answer
You might want to take a look at freetype. I've no idea if it's available on your platform or if the licence is applicable but it's a rather excellent open source library for rendering true-type and other vector fonts. I believe they had to do some clever lawyer dodging code in order to get fonts to render in an aesthetically pleasing way. The true type way involves byte codes on curves to provide hints to the renderer so that important font features (such as verticals and serifs) don't get blurred away as they would using standard naive anti-aliasing. That technique has a patent on it so the freetype people had to come up with something else that did the job and didn't invoke the terrible lawyer-beast of (I think) Apple. Anyway, pogramming legal aside aside, try looking into freetype http://freetype.sourceforge.net/index2.html
> 0 votes

---
Tags: xna, 2d, 3d, text
---


# Question
Title: What are the technical certification requirements for the Xbox 360?
I came across this document listing the technical certification requirements from March 2009, but I haven't been able to track down anything more up-to-date, nor have I been able to find the "terminology list" that the document refers to.

Is there a current version that is available to non-developers like myself?

# Answer
The official up-to-date TCR document comes with the Xbox Development Kit from Microsoft. Any licensed developer copying it online would be in violation of the license terms of the XDK.

It is possible that Microsoft has published it elsewhere, or that they have given some other developers or journalists a separate license to publish it. But I think that's unlikely. Most of the requirements, as you can see in the linked document (which was probably posted infringingly), are fairly boring.
> 10 votes

---
Tags: xbox360, microsoft
---


title: Simulating an object floating on water

text:
# Question
Title: Simulating an object floating on water
I'm working on a top down fishing game. I want to implement some physics and collision detection regarding the boat moving around the lake. I would like for be able to implement thrust from either the main motor or trolling motor, the effect of wind on the object, and the drag of the water on the object.

I've been looking at the farseer physics engine, but not having any experience using a physics engine, I am not quite sure that farseer is suitable for this type of thing(Most of the demos seem to be the application of gravity to a vertical top/down type model).

Would the farseer engine be suitable? or would a different engine be more suitable?

# Answer
> 5 votes
I'm doing this kind of thing with bullet, but the same technique could be used with any physics engine. Buoyancy is modelled by attaching imaginary floats to the body which simply apply a force acording to their depth below the surface at discrete points.

In the timestep the each float tests the water level at their position, then applies a force to the boat's rigid body at their position relative to the boat. I imagine each float as a cylinder which is always vertical, regardles of the orientation of the boat. The force is proportional to how deeply immersed they are, up to a maximum defined by their volume.

At the moment the boat has just 4 floats - bow, stern, port & starboard. I manually set their volumes to provide enough force to counteract gravity, and then adjust the positions and cylinder lengths to tweak the way the boat moves. I've got a vague idea to generate the floats by packing cylinders into the rigid body volume somehow, but that's something for the future.

A short demo of a boat sailing through waves is here on youtube.

# Answer
> 0 votes
Farseer physics supports all kinds of force and intertia application, so that wouldn't be a problem, I'm not 100% sure though if Farseer already supports fluid bodies (for the water) but if that's supported then it should be ok. (Also note that Farseer is a 2D physics engine)

---
Tags: c#, physics, collision-detection
---


title: Axis-Aligned Bounding Box- once rotated

text:
# Question
Title: Axis-Aligned Bounding Box- once rotated
Creating an AABB is simple. But, if the 3d model has become rotated, how do you update the AABB to become accurate? Or is the AABB supposed to be in local space?

# Answer
> 5 votes
Axis Aligned Bounding Box means the box itself is always on the same orientation.

**To update the AABB you will need to recreate it each time the model rotates, and move it if the models positions changes.**

The box will change shape and size depending on the rotation and the model you use.

If you want to have a rotating collision box than that matches up with the model, then that is completely different than an AABB, and you will need to look into the physics of your engine for that.

Edit:

**If you want to update the AABB quickly, but with less accuracy, just pass the points of the original bounding box instead of the entire model**.

The bounding box won't be perfectly tight, but it is guaranteed to have the entire model inside of it. Here is an article describing how to achieve this.

One thing I would like to add that is not in the article would be to create a few fully calculated bounding boxes at 10 rotations and when recalculating, use the bounding box that is closest to the current rotation, that should improve the tightness of the bounding box a lot without creating that much more overhead.

# Answer
> 3 votes
From wikipedia:

> A bounding box is a cuboid, or in 2-D a rectangle, containing the object. In dynamical simulation, bounding boxes are preferred to other shapes of bounding volume such as bounding spheres or cylinders **for objects that are roughly cuboid in shape** when the intersection test needs to be fairly accurate. The benefit is obvious, for example, for objects that rest upon other, such as a car resting on the ground: a bounding sphere would show the car as possibly intersecting with the ground, which then would need to be rejected by a more expensive test of the actual model of the car; a bounding box immediately shows the car as not intersecting with the ground, saving the more expensive test.

If your model can be at any rotation, perhaps a bounding sphere is in fact a better bounding volume to be using? Bounding spheres are typically cheaper checks and many systems use several bounding volumes in preference order e.g. always check sphere, if that passes then check AABB, if that passes then ...

---
Tags: c++, collision-detection
---


# Question
Title: Capitalizing on JavaScript's prototypal inheritance
> JavaScript has a class-free object system in which objects inherit properties directly from other objects. This is really powerful, but it is unfamiliar to classically trained programmers. If you attempt to apply classical design patterns directly to JavaScript, you will be frustrated. But if you learn to work with JavaScript's prototypal nature, your efforts will be rewarded.
> ...
> It is Lisp in C's clothing.
>
> -Douglas Crockford

What does this mean for a game developer working with canvas and HTML5? I've been looking over this question on useful design patterns in gaming, but prototypal inheritance is very different than classical inheritance, and there are surely differences in the best way to apply some of these common patterns.

For example, classical inheritance allows us to create a `moveableEntity` class, and extend that with any classes that move in our game world (`player`, `monster`, `bullet`, etc.). Sure, you can strongarm JavaScript to work that way, but in doing so, you are kind of fighting against its nature. Is there a better approach to this sort of problem when we have prototypal inheritance at our fingertips?

# Answer
> 8 votes
To get decent performance out of JavaScript with modern JS engines one needs to write code that mirrors common structural typing or duck typing patterns. Structural typing is more powerful than providing types only by inheritance but does not really change the design patterns used by games.

As an example, in C++ or Java, where one usually types by inheritance, one usually has deep type hierarchies with several interfaces / virtual classes in order to implement MVC. But games shy away from this kind of design pattern already because it doesn't really help model the kind of data games deal with.

The patterns one does find most useful in game design, like context objects, components, flyweight, or strategy, do not tend to use complicated inheritance hierarchies in the first place, even when implemented in languages like C++. Components involve a single virtual class (at most). Flyweight usually uses C++'s (awkward) structural typing via templates. Strategy often uses some form of type erasure for performance or programmer sanity.

The one exception to this is the prototype pattern itself, which is often found in some form in games, especially for designer-driven data. Using JavaScript makes this pattern trivial. But it is not a particularly difficult pattern to implement, at least poorly, in any language that supports associative data structures. Using JS would let you use it more because you can leverage the underlying engine's optimizer. But I'm not sure if that would really change the way one programs - a naive prototype pattern is already in plenty of places in plenty of games despite its often poor performance.

# Answer
> 6 votes
If you really dig into the semantics, you'll find that JavaScript is actually a bit closer to most class-based languages than a "real" prototypal language like Self. The way `new` works, you almost always create an object that contains state in its own fields and methods in the fields of its prototype. Squint your eyes and that's a class.

To really be prototypal, there'd be no `new`. You be cloning objects and doing differential inheritance.

So, don't really worry too much about JavaScript's half-prototypal nature. Just understand three pieces:

1. Most of the time, your objects will essentially be instances of a "class" where the constructor defines its fields and the functions on the constructors `prototype` define the method.
2. If you want familiar Java/C#-style single inheritance you can get that by chaining prototypes. Most JS frameworks out there (Closure, dojo, etc.) have some nice helper methods for wiring it up.
3. You can add methods to any "class" at any time. Feel free to mix in functions onto which ever prototypes need them. You don't always need to set up an inheritance chain and a complex hierarchy. If you have ten classes that need the same method, you can always imperatively add it to those ten classes.

---
Tags: javascript, html5, design-patterns
---


title: Board Game Design in Cocos2d

text:
# Question
Title: Board Game Design in Cocos2d
I am going to start a chess like board game. And for that I have reviewed a number of things available.

One is http://www.mapeditor.org/, using which you can create a grid base games.

Another option is geekgameboard for iphone available at http://mooseyard.lighthouseapp.com/projects/23201-geekgameboard

Now I want your expert opinion on what would be better to make a game in cocos2d, using the first option or the second option? Both looks promising to me and give good control over board design.

PS: Sorry for duplicates, I found about the https://gamedev.stackexchange.com/ lately after posting it on stackexchange. So I am just posting it here again as I feel this is a more relevant board.

# Answer
I wouldn't use a tile-editor for a game like chess. The board is really simple and you can easily draw it without the help of a tile-editor. These maps make much more sense if you have a large world/board with lots of different tiles.

I don't know the GeekGameBoard you linked to, but it looks like it's a framework for card and board-games, so this seems much more suited for your task. It seems like this framework provides several UI elements, so you'll probably either choose GeekGameBoard *or* Cocos2d. Mixing the two would most likely force you to rewrite/refactor a lot of the GeekGameBoard code (which might be more work than starting your game-code from scratch).
> 2 votes

---
Tags: game-design, cocos2d-iphone
---


# Question
Title: Accessing C++ class members with LuaPlus
I've implemented LuaPlus in my engine eventmanager successfully and really like the flexibility I gained. But I'm still not exactly where I want to be, because I can't link my c++ classes to a Lua class.

For example, I have a Actor class in C++, and I want to be able to create the same class in Lua and gain access to members with LuaPlus, but I can't figure how I can achieve that.

Is this actually LuaPlus built-in functionality, or do I have to write my own interface that exchanges data tables between C++ and Lua?

My current approach would be to fire an event in Lua that creates an new actor class in C++ code, and transfer its ID and the data I need to back to Lua. When I modify the data I send the modifications back to C++ code again, but I actually thought there's something in LuaPlus that exposes this functionality already.

# Answer
I don't know how to achieve this with luaplus, but I have been using luabind and the behavior that you explains is very easy to program.

http://www.rasterbar.com/products/luabind.html

In my experience, LUA has incremented the workflow efficiency, especially on things like AI and things that change a lot in development.

For example, you could reprogram the AI on the fly, with the game in execution, reload the AI and see the changes. All this without recompile or launch the game again.
> 1 votes

# Answer
tolua++ uses all the metatable features to allow a very straightforward manipulation of your c++ types in lua.

For example, this declaration :

```

// tolua_begin
class SomeCppClass
{
public:
   SomeCppClass();
   ~SomeCppClass();

   int some_field;
   void some_method();
};
// tolua_end

```

Will automatically generate the lua bindings to allow this lua scipt :

```

#!lua
-- obj1 must be deleted manually
local obj1 = SomeCppClass:new()
-- obj1 will be automatically garbage collected
local obj2 = SomeCppClass:new_local()

obj1.some_field = 3 -- direct access to "some_field"
obj2:some_method() -- direct call to "some_method"

obj1:delete()

```

The advantage of this technique is that your lua code will ve very consistent with the relying C++ code. See http://www.codenix.com/~tolua/tolua++.html
> 3 votes

---
Tags: c++, lua
---


# Question
Title: Multiplayer game with Cocos2d-Javascript and Node.js
It is possible to make a multiplayer browser based game using cocos2d-javascript + node.js? If so, is there any tutorial about that?

# Answer
> 2 votes
I'd recommend you check into http://nodejs.org/ and https://github.com/joyent/node/wiki/ for information on what you can do with node.js.

cocos2d-javascript has a tutorials section on their website: http://cocos2d-javascript.org/tutorials/ which I recommend you start with.

Without significantly more detail, there isn't much more I can recommend you look at.

---
Tags: multiplayer, javascript, cocos2d, websocket, node.js
---


# Question
Title: How effects found in "Autodesk Fluid FX" are implemented using OpenGL ES?
How this kind of effects are technically implemented using OpenGL ES? Are they performing simulation on GPU (using Shaders) or CPU while using some smart vertex positioning and texturing? Why it appears so fast (in terms of performance)?

You might check the video of that app here: http://www.youtube.com/watch?v=F4KOk6QP6kQ

**edit**

Here is the presentation for the app: http://www.futuregameon.com/FGO2010\_JosStam.pdf

# Answer
You can do that with either fragment shaders or a grid of textures. With fragment shaders you get more precision.

The basic idea is that you have some kind of transformation and then you recursively apply it to the same data - meaning you store the results of the last frame and then apply the same transformation to it again.

As an example you might divide the screen to 24x24 quads, and then jitter the vertices a few pixels. Applying this transformation to the data will cause the pixels to flow a bit.

Add a smoothing pass and voilá - fluid fx.

**edit**

Here's a quick simulation of this done in photoshop; few frames with the "waves" filter applied and re-applied:

note that it's the exact same filter applied to the previous result, not new parameters applied to the first frame.

**edit** why it appears so fast is due to this simplicity - it's just rendering the whole screen once, using the last frame as the source texture.

**edit** Browsing through the presentation, yes, it does seem it's based on "real" fluid simulation, but the result is pretty much the same - rendering the whole screen, using the previous frame as source texture, offsetting using an offset texture which contains the motion vectors. Calculating said motion vectors is another matter, but can even be done offline.
> 4 votes

# Answer
For fluids you don't need big resolution as the screen is. 2D (or 3D fluids) can be done in 1/2 without quality loss and 1/4 without significant quality loss. That is if linear interpolation is used(linear texture sampling). If cubic interpolation is implemented, you can go for even lower resolutions.

Stable fluids can be computed on the CPU in interactive rates. It is todays' fashion to put everything on the gpu (and i love it), but 2D fluids can be very nicely handled on CPU. Autodesk maya fluid solver is single threaded (as whole maya (!)) and can handle aprox. 15\*15\*15 (3375) 3D fluids at realtime on todays CPU. So i'm not afraid about performance on any mobile platform if the simulation is only 2D.

**How is this done?**
*First smoke:*
Density and speed is simulated. As you can see in slides you posted. Navier-Strokes equations can do the job. They can be quite simple or very complex (like Maya, where you can simulate density,temperature,pressure and fuel, with tons of setups). If you simulate only density and speed - you will get two 2D arrays. Speed (array of 2D vectors) and density (array of scalar). By rendering density as fullscreen texture you can get nice smoke (remember thay you can have 1/2 screen resolution without quality loss). I also suggest to use some simple "Transfer function". It mean that value from density doesn't just move with opacity, but it can lookup in the color.

*And for the floating pictures:* You will do what Jari Komppa said. Every frame has input picture texture and for every pixel you read value from `(pixelPosition - SpeedVector)`. Speed vectors can be loaded as textures (red, green = x,y). Density still has to be simulated (even if it is not displayed) to have correct speed vectors.

For fluid simulation on the gpu check this link
> 4 votes

---
Tags: opengl-es, graphic-effects
---


# Question
Title: Best way to prevent UIPanGestureRecognizer from firing when moving sprites in cocos2d
Im using UIPanGestureRecognizer in my cocos2d game to do drag and drop of sprites. I have a row of sprites and when I drag a sprite on top of another one, the sprite underneath it and any other sprites between should shift left or right out of the way to allow space to drop the currently selected sprite.

This is working ok, however, if I am too quick at dragging the sprite around the screen, this triggers another round of the UIPanGestureRecognizer's callback method, and screws up the logic, as the sprites are in-between shifting.

I need a way to freeze the callback from firing, whilst the other sprites are shifting, then once they have finished moving, re-enable the callback to fire.

Whats the best way to do this?

# Answer
You can set the enabled property to NO, which will disable that gesture recognizer, until you re-enable it. If for some reason the recognizer is disabled while in the process of firing, it'll transition to its canceled state prior to being disabled.
> 2 votes

---
Tags: cocos2d-iphone, cocos2d
---


# Question
Title: Units issue when exporting from 3DS Max to XNA
I am working on a XNA game where we have defined that 1 XNA unit equals to 1 meter. Then, I set meters as system unit in 3DS Max and set to meters the units in the FBX exporter. However, when I export my models, they are much bigger in the game. Am I missing something? What should I do to avoid problems with my units?

Investigating the FBX file, I noticed that I it has two values called UnitScaleFactor and OriginalUnitScaleFactor. They both are 100 when I export the files... And if I manually change UnitScaleFactor to 1, it works fine :S

# Answer
Looking through this page, it seems that there are a few things that might be happening. The XNA FBX importer isn't reading the units correctly and is thinking meters is centimeters. Or, the model has a scaled parent bone that is throwing things off. I don't have Max in front of me at the moment to test this.

Personally, I'd start with creating a 1m^2 square in Max, then open it up in the content pipeline to see what units are being exported. Then maybe again in game to see if the importer was messing up the units. Maybe knowing what the exact scale difference was would give some insight.
> 2 votes

# Answer
Just guessing, haven't worked with FBX and been awhile since I used 3d Max but I work with a number of autodesk products and then generally use the same concepts for unit conversions.

The UnitScaleFactor is used to translate the unit definition in the source (3D Max) file to the target (XNA) unit definition.

So when the translation happens, the original unit amount is multiplied by the UnitScaleFactor to determine the correct size in the target. I would guess it should be 1 for your application since your unit definitions are the same in the source and target.

You could, for example, define you units in 3D Max to 1 unit = 1 mm and UnitScaleFactor to 25.4 and your XNA would get the model in inches.

Again, just a guess.
> 0 votes

---
Tags: xna, 3dsmax
---


# Question
Title: GLSL Shader Effects: How to do motion blur?
I have a full 2D environment, with sprites going around as landscape, characters, etc.

To make it more state-of-art looking, I want to implement a motion blur effect, similar to modern FPS games (i.e. Crysis) blur when moving the camera quickly.

In a sidescroller, the desired effect is having this slight blur appearing to give the idea of fast movement when the camera is moving. If anyone could give me some tips on doing this, I'm assuming in a pixel shader, I'd be grateful.

# Answer
Keep a copy of the last framebuffer. Get the camera movement vector and invert it. Draw your scene as usual, then draw the last framebuffer with a slight offset (the camera delta you just calculated) and 0.75 alpha. Repeat as many times as you like to give the motion blur effect.
> 7 votes

# Answer
I would recommend using this method : Motion Blur as a Post-Processing Effect

Very simple to implement, it's the one I used in my glsl demo Ruin island \[link\]
> 21 votes

---
Tags: opengl, shaders, effects
---


# Question
Title: How can I prepare myself to become game developer
I like to become game developer.. I already work as web developer for the past year. There I used php, jQuery, mysql and some framework also. It's little boring now same thing again and again. So I start to learn Android application development.

My question is:

1. If want to become a game developer
what skills should I have (like java, c++, etc) ?
2. Where can I get good tutorials (online)?
3. Is previous knowledge will help me?

# Answer
> 8 votes
I would ask you to refer this site. It is the ultimate reference and eye opener for anyone who would like to become a game developer. Let us know if it is helpful to you.

# Answer
> 5 votes
To answer your questions, with an Android flavor:

1. Knowledge of C++ will not hurt you, my theory is the more languages you know, the better, period. To develop for Android specifically, Java is important, since even with the NDK, you must use some Java.
2. This really is dependent on what you're looking for, specifically for Android, the article here, has a lot of good getting started information.
3. Yes, good games will incorporate all kinds of knowledge. Strong math (trig,linera algebra, etc) is helpful. Your mysql experience will be useful for persiting game state to database, though Android uses SQLite.

All that said though, there are several similar type questions on this site, which are geared toward starting game development, which you should check out:

1. https://gamedev.stackexchange.com/questions/4011/getting-started-questions
2. https://gamedev.stackexchange.com/questions/41/what-are-some-good-resources-for-getting-a-beginner-started-in-developing-games
3. How do I get started making Android games?
4. What things should an indie game developer never do?
5. What are good games to "earn your wings" with?

# Answer
> 2 votes
Tank sleep. If you thought 60 hour workweeks were bad before, they'll be distant memories of the easy times pretty soon.

Also, define "game developer". The majority of any programming job is grunt work, programming the bread and butter stuff. The job "game developer" might appear glamorous to you from a distance, but it's just another programming job (you sound like a junior programmer). The only difference is that you're programming what happens to a sprite moving across a screen rather than an algorithm to calculate some business data.

---
Tags: game-industry
---


# Question
Title: Pseudo-magnet implementation with chipmunk
How should I go about implementing "natural" magnet on a certain body in chipmunk space? Context is of simple bodies lying in the space (think chessboard). When one of the figures is activated as a magnet - others should start moving towards it.

Currently I'm applying force (`cpBodyApplyForce`)to the other figures with vector calculated towards the activated figure. However this doesn't really feel "natural". Are there any known algorithms for imitating magnets?

# Answer
> 4 votes
It's been a while since I did magnets, but I believe that the equation you want is the naive model of the force between two poles.

```
def force(a, b):
    magnitude = a.magnitude * b.magnitude
    separation_sq = distance_squared(a.position, b.position)
    return (permeability * magnitude) / (4 * pi * separation_sq)

```

For your purposes, you can probably fix `permeability` at 4 * pi and tweak only the per-object magnitudes to get the feel you want, simplifying the equation:

```
def force(a, b):
    magnitude = a.magnitude * b.magnitude
    separation_sq = distance_squared(a.position, b.position)
    return magnitude / separation_sq

```

The important part is that the force varies inversely with the square of the distance between the objects.

---
Tags: physics, chipmunk
---


# Question
Title: How to teach game programming at school?
I'm in this private school right now, and apart from my progressive stoppage of anti-depressants, I'm having an hard time focusing on what the school wants me to do.

The school has a professional contract for a game we have to do with Unity. I don't really learn anything new while using unity, so I don't like using it.

We recently learned how to use DirectX, and we have to do some sort of Gradius-precursor clone (Parsec) with directX, in 3D: this annoys me, and I'm currently learning to use Ogre3D by myself by making some game.

The teacher is an engineer, and all of us won't be engineers.

How would you teach game programming ?

# Answer
> 6 votes
The big problem is that many people don't enjoy programming enough to warrant learning to use DirectX or OpenGL. Also you shouldn't (always) reinvent the wheel; even when using something like Ogre3D, you're a long way from having the basics of Unity implemented. It's easier to start with Unity and introduce them to Unity scripting, and they will have more fun with it.

I am of the opinion that something like Unity or Game Maker should be taught first. Game programming is basically segregated into several sub-categories: game scripting (possibly including AI scripting), engine programming, tools programming. The easiest and most fun of these is game scripting, which would be what you do in Unity, Game Maker, etc.

You are obviously more interested in engine programming (or just low-level game development, whatever category that fits in - all of them?) but I don't believe that's the universal way to teach game programming.

So to directly answer your question, **teach game programming by starting with game scripting in an existing engine and toolkit such as Unity, because this will appeal to the most people. Those that want to dive deeper (lower-level) can then be introduced to DirectX/OpenGL/Ogre3D.**

---
Tags: teaching
---


# Question
Title: How to protect your real time online shooter from potential bots
I'm looking to create a multiplayer top down shooter. While I've read about different topics, I can see them I've got some real challenges ahead, but I'm all up for it.

One thing I can't understand is how am I supposed to be protecting the game from people who try to create bots?

What I mean is, as far as I understand, it's impossible to protect the network traffic in a way that players won't be able to create programs that listen to what's going on and understand it.

So what worries me is that people can create bots that listen to the current location of rival players, and send communication that mimic as if the player is shooting in the exact "perfect" location to win that match.

So what kind of techniques are used to protect real time games from such bots?

Also I'd like to mention that I've tried searching for discussions (as this sounds like something many people struggle with), but couldn't find anything about it specifically, only as a part of broader questions about networking in real time games. If I should have looked harder feel free to put me in my place :)

# Answer
There are two approaches to countering bots. They are client-side protection and server-side analysis.

Client-side protection is the most obvious approach - brute force, in a sense. You make all efforts to ensure that the game client is fully legitimate, has not been tampered with, and no other programs affect it. Now this is a difficult problem, and impossible to fully solve. But many games try, and have some success with this method. I know there exist some ready-made solutions for client protection, and suggest you look for them. Implementing one yourself is a daunting task.

In addition to being less then 100% effective, client-side protection has the drawback of being extremely annoying for your players. Usually it implies things like disabling alt-tab task switching, antivirus programs, etc.

Server-side analysis is less intrusive. In this approach, you have some server code that analyses patterns in players' behavior. Most often, bots play demonstrably different. For example, human players have varying time between actions (such as shooting), and this time obeys a bell-curve distribution. Primitive bots will have constant time, or distributed evenly over some interval. Fun fact: using this method, we once caught a player with a *mechanical* bot - a clever device that pushed buttons on his physical keyboard. Needless to say, not amount of client protection can catch *that*. Still, this analysis is not perfect. More advanced bots will fool your systems, and the more checks you implement, the more advanced bots would become.

For best protection, you can combine both these methods. Client protection will make it harder to develop bots, and server analysis will stop simple bots that were developed quickly. But whatever you do, you can never stop bots entirely. Well, unless you send your representatives to players' homes, to supervise their playing and report violations. (Which is not unheard of, by the way. I've definitely read a story about online poker company sending people to a very successful player's home, to confirm he was playing legitimately. But I can't seem to find it now.)

There are two more dubious recommendations for fighting bots. One, encrypt your network traffic. I don't think this is gonna work. With your client in the hands of an enemy, traffic can be and will be decrypted... or you own client will be used for encryption. On the other hand, encryption adds lag, and that is really bad for a "real-time shooter". Second recommendation is "just design your game around this". While this seems like a sound idea, I've yet to see a single game that managed this.
> 8 votes

# Answer
I wouldn't expect any of the big players to talk about what they do to protect their games. The less people know about what they're doing, the harder it is for people to work around it. I think part of what Steam does is look for certain applications running that are on a black list.

Personally I'd try and encrypt and obfuscate communication as much as possible between communicating machines, it might be worth reading up on the way https/ssl works to get some ideas. If the hosts were to generate a random public/private keys and only send the public part out to other clients then something wouldn't easily be able to intercept and change the contents of the packages being sent, although if you have access to the client machine then nothing is completely secure.

You'll also need to ensure that the client exe isn't tampered with.
> 2 votes

# Answer
Design your game so that team work and actual intelligent decisions are more important than being able to aim perfectly. It becomes exponentially harder to make decent bots.
> 1 votes

# Answer
And ask yourself the all important question of whether it's worth the trouble. Cheaters and botters can do 2 things:

1. destroy the game for themselves. They can't play without the bot, they quickly loose interest and leave because it's no fun.
2. destroy the game for others. They become overly powerful through their bot, thus costing you customers. This is usually accompanied by a single player controlling multiple bots from the same physical computer (or uses far more computers than a single player can be expected to control manually).

The two aren't mutually exclusive of course.

Usually then the biggest problem is 3+ (as a human being can with training use 2 keyboards or other input devices at the same time, but not more as he only has 2 hands) clients from the same or closely related ip addresses (or MAC addresses) acting in direct unison, executing commands within milliseconds of each other. So if you detect say 5 clients originating from the same ip address all giving commands at an abnormally high rate and at abnormally close coordination, you likely have found your botter. Usually this'll be most damaging in pvp scenarios where this bot army can dominate an engagement against a similar number of human controlled toons due to its higher coordination and speed. In pve scenarios, typically there's limited damage to the game (except in that it allows one person to train multiple toons to high levels more quickly, a typical characteristic of powerleveller companies, a constant scourge in the mmo industry).
> 0 votes

---
Tags: networking, multiplayer, security
---


# Question
Title: What is the general strategy to pre-load game data(entities/map)
I'm new to games programming and am wondering what tactics games use to pre-load entity and map data. Will a game initialise with the fundamental map data stored in memory?

# Answer
I'd say this really depends on what type of game you're making, but some general points.

1. Only load what you absolutly know you need immediatly, or you know you'll need soon
2. Only remove things from memory when you absolutly know you wont need them again AND you need to load something that fits the constraints of #1 AND you've reached your memory limit
3. A general understanding of Paging and Virtual Memory of Operating Systems can be applied to games in terms of when to remove data from memory -- that is to say, those ideas can be applied to game systems because many games have "OS like" requirements (fast, direct access to memory, input, and network devices)
> 4 votes

---
Tags: loading, maps, data
---


title: FPS Collision detection and movement

text:
# Question
Title: FPS Collision detection and movement
How is collision detection and movement typically handled in a FPS, particularly handling slight changes in ground height such as stairs (both on incline and decline)?

# Answer
Entities typically represented by a capsule (cylinder with spheres on the ends) against world geometry (or a simplified collision mesh) for world-ent collision.

Stairs are usually either no-collide with an invisible ramp, or below a certain height you usually get a lift up as a side effect of collision resolution. (you'll get interpenetration with movement as a part of step size, and resolution will pop it out upward as the closest plane)

I think this is how Unreal 3 works, but I could be wrong. I recall seeing a bounding box hierarchy in Source, but I can't remember if that was just for combat. regardless, capsules are simple and fast
> 11 votes

# Answer
In Unity 3D, the easiest way is to have the first person controller. Usually the character has to jump up if the step height is higher than the step offset. But another way to do it is add a box collider and rotate it so that the character can skim the stairs easily, as if it were a ramp.
> 1 votes

# Answer
Brady's answer is good, but if you want a hacky way to do it, you can just cast a ray down to your grounds collision geometry, figure out what triangle it hits, and then use a weighted average of the height of the verts of triangle to figure out the ground height.
> 0 votes

---
Tags: collision-detection, first-person-shooter
---


# Question
Title: Looking for literature about graphics pipeline optimization
I am looking for some books, articles or tutorials about graphics architecture and graphics pipeline optimizations. It shouldn't be too old (2008 or newer) - the newer, the better.

I have found something in \[Optimising the Graphics Pipeline, NVIDIA, Koji Ashida\] - too old, \[Real-time rendering, Akenine Moller\], \[OpenGL Bindless Extensions, NVIDIA, Jeff Bolz\], \[Efficient multifragment effects on graphics processing units, Louis Frederic Bavoil\] and some internet discussions. But there is not too much information and I want to read more.

It should contain something about application, driver, memory and shader units communication and data transfers. About vertices and attributes. Also pre and post T&L cache (if they still exist in nowadays architectures) etc. I don't need anything about textures, frame buffers and rasterization.

It can also be about OpenGL (not about DirecX) and optimizing extensions (not old extensions like VBOs, but newer like vertex\_buffer\_unified\_memory).

# Answer
These are all free.

GPU Gems 1
GPU Gems 2
GPU Gems 3

The Graphics Programming Black Book
ShaderX

EDIT: I misread your question. I feel the most useful one here will be the Black Book, though you might find some use in the others.
> 1 votes

---
Tags: opengl, architecture, graphics, optimization, pipeline
---


title: I.T. degree for game programming?

text:
# Question
Title: I.T. degree for game programming?
I am a 19 year old who has always been interested in video & computer games. I developed the interested for game programming about three months ago and started researching on the profession. The only degrees always suggested on the internet and in books are those of computer science, physics, mathematics, & game development. BSc Information Technology has been my major for the past two years; and even though my university teaches we the I.T. students computer programming (in c++, c#, java) and offers us the opportunity to undertake some computer science courses of our choice in addition to the regular I.T. courses, I am feeling insecure about my prospects in getting into the profession. My question is: Will a game development company hire me if I exhibit good math, physics and game programming skills with an I.T. degree? If NO, will I have to obtain an MSc in a much more related course.

# Answer
> 5 votes
As stated, the short answer is yes.

The long answer: I've been in charge of hiring for game programmers, been an interviewer, etc. and can say that degree really doesn't matter. I've worked with electrical engineers, people without any degree, and plenty of computer science guys.

That being said, you're still going to have to be spectacular. Personally, when I interview, I dig into algorithmic complexity, optimization, and continually probe until I find a topic the candidate doesn't know and, at that point, have them figure it out. So, you may have some catching up to do.

Remember, it's not just about knowledge. It's about thought process, as well. You need to be able to solve problems, even when they are completely out of your realm of comfort.

Read this blog post. If you're afraid of what it's saying, challenge that fear with knowledge. You're going to need to know everything to get a solid job. You'll need to know more than this, as I'll expect you to know everything here AND as much related to games.

Write games. When I get a resume from someone who hasn't even built a side project game, I typically chuck it. I know that sounds harsh; but, I need someone who'll understand what I'm talking about when/if things are on fire. In games, there's very little time for hand holding.

Write a lot of games. You're going to need to learn about collision, scene graphs, space partitioning, networking, etc. Build games (start small) that let you understand these.

Write games with other people. You're going to need to fail, and hard. The fastest way to fail is to add more people to your team. If you can overcome these challenges, you'll learn a lot. I need people who can work with artists, designers, other engineers, and executives.

I hope that helps :)

# Answer
> 2 votes
Short answer, yes.

Long answer:
Computer Science degrees do have an advantage over I.T. degrees to a certain extent, since they teach more about data structures, algorithms, time and memory complexity, etc. However, if you spend enough time working on these yourself, then you'll be fine. The main thing to work on is your coding ability. Make a demo, work on your portfolio and brush up your maths. As long as you've got the skills necessary for whichever job you're applying for, the degree that you do doesn't really matter.

It could also potentially show that you're willing to go above and beyond since most of this will probably be done in your own time. If you do have the opportunity to take some data structures, algorithms or programming classes, by all means take it :)

Hope that helps.

# Answer
> 0 votes
A short answer, based purely off what I've read here/logical thought:

As long as your portfolio is of good quality and you can prove your worth in a programming environment (and don't need tons of sleep ;) ), you should be fine. However, be warned your application may be skipped over because you would appear as an IT student rather than a CS student, and they could assume you lack the ability (and you just think programming would be cool).

# Answer
> 0 votes
If you're in it for the thrill of programming then you would probably not have many issues with an IT degree over a CS degree, as the places where you would find the best work environment wouldn't be the same places that would pass over you because you don't have a CS degree.

At least I'm hoping that's the case when I graduate with my IT degree...

---
Tags: education
---


title: Best C++ Math Library for Game Engine?

text:
# Question
Title: Best C++ Math Library for Game Engine?
I'm looking for a fast opensource C++ math-library for my game engine with the following features:

* fast (sse?)
* vectors
* matrices
* quaternions

suitable for both opengl and directx

# Answer
> 11 votes
XNA Math might be for you. It's a header only C++ math library that is distributed with the latest DirectX SDK and uses SSE intrinsics. I can't talk much about its performance but from what I read about it, it seems to be pretty decent.

XNA Math Reference

XNA Math programming guide

DX SDK download

EDIT: I'm also not sure about the licensing terms. The DX SDK Eula states that "Distributable Code" may not be

> "run on a platform other than the Windows, Xbox and Windows Mobile platforms;"

I'm not entirely sure whether this applies for xna math as only sample and utility code is explicitly marked as "Distributable Code"

# Answer
> 15 votes
We use OpenGL Mathematics

Even though the name implies it's just for OpenGL I see no reason it wouldn't work for DirectX. It's a header only library, easy to use and is very actively updated.

Check it out.

# Answer
> 5 votes
Try Eigen -- fast, expression templates, vectorized, easy to use, and is licensed under the MPL2

# Answer
> 4 votes
Maybe CML http://www.cmldev.net/

# Answer
> 1 votes
Sony's vectormath library, used as part of Bullet Physics, meets all your requirements. Some work is involved to separate it from Bullet, but nothing serious - it doesn't depend on bullet, just that no one ever packaged it officially apart from it.

The version currently in the bullet tree supports SSE optimizations, and has a C++ interface.

An older version (probably now unsupported) also supports SOA formats, and a pure C interface.

# Answer
> 0 votes
Or, for speed, http://sourceforge.net/projects/simdx86/.

---
Tags: c++, mathematics
---


# Question
Title: Structuring game world entities and their rendering objects
I'm putting together a simple 2d tile-based game. I'm finding myself spinning circles on some design decisions, and I think I'm in danger of over-engineering. After all, the game is simple enough that I had a working prototype inside of four hours with fewer than ten classes, it just wasn't scalable or flexible enough for a polished game.

My question is about how to structure flow of control between game entity objects and their rendering objects. Should each renderer have a reference to their entity or vice-versa? Or both? Should the entity be in control of calling the `render()` method, or be completely oblivious?

I know there are several valid approaches here, but I'm kind of feeling decision paralysis. What are the pros and cons of each approach?

# Answer
> 2 votes
Assuming your "game entity" is a thing full of all sorts of game-specific bits (like health or a set of weapons or whatever), I would prefer an approach where the game entities know nothing about the renderer, as well as the other way around. Instead, you have a higher level bit of code in your primary loop which knows about both subsystems collect together all the game entities and create a bunch of render objects (or reuse cached ones, etc) based on the properties of the game objects. You then submit this list of render objects to the renderer itself. At its purest form this might look like:

```
while(!finishedPlayingTheGame) {
  GatherInput();

  // In practice this may do culling based on the collision world or whatnot
  // to remove objects that shouldn't be seen according to the game logic.
  List<GameObject> gameObjects = UpdateGameObjects();

  List<RenderObject> renderObjects = CreateRenderObjectDescriptions(gameObjects);
  renderer.Enqueue(renderObjects)
  renderer.Draw()
}

```

An advantage to this approach is a much higher isolation between the game and render logic; the disadvantage is the extra post-processing of the game objects into render descriptions.

In practice, you can alleviate the algorithmic overhead of that second processing pass by pushing the creation/configuration of a render object for a given game object into the loop that iterates the game objects and updates them. This typically doesn't introduce that much coupling between the logic and render subsystems.

If you are taking a component-focused approach that supports extensible aggregation of behavior into game objects, you can have the renderer publish a component that can be attached to each game object that configures its render object. This can allow for more extensible customization (via, for example, scripts -- which is probably overkill for this project).

What I think you should *not* do is directly have game objects a "render myself" method, because I think this creates scalability problems in terms of reconfiguring rendering techniques and styles (it can be much harder to have different classes of object share render configuration code this way). Plus it tightly couples the two subsystems and creates additional responsibilities for the game object interface (interfaces should ideally have one responsibility).

# Answer
> 0 votes
The lesser your entites know, the best. Do not assume your game "is simple". You may want to modify, improve, update it and then a not-too-bad design will help.

You can use a bus strategy : create an interface Bus. It will be able to register :

* Id of the image to display;
* If necessary, size of the image to display;
* x & y coordinates.

So that would be a very simple function :

```
void addReference(int idimage, uint width, uint height, int x, int y);

```

Then, the main loop will pass a reference to a Bus implementation to every entities. So your entites will need to know the interface (you can do it with an event system too, but it's not that different), but not the implementation, that's not too much a price to pay. This design has one quality : you can do many things with it.

1°) Display as it comes : immediately after addReference, display the entity. It's what I'm using for my Roguelike, because I do not need more.

2°) Wait for the full references (so you'll need to create a special object to store only display references - the logic being close to a reference system) and have rules for the display stored in the bus class.

3°) Store the references received, and check if there was any change (you might want to add an entity identity number for this), so you'll only display what changes.

You can have the bus do the rendering, or just be a pipeline for another class. Note that you'll have to implement a camera logic somewhere.

---
Tags: architecture, rendering
---


title: how do I make flash mmorpg?

text:
# Question
Title: how do I make flash mmorpg?
I want to make games like this.

http://www.fantasy-mmorpg.com/

simple 2d graphics but using Red Dwarf server on the background.

what flash game engine should I use ?

# Answer
You seem to be under the opinion that an engine will allow you to make an MMORPG straight away. Read this, and rethink your idea.

You could probably use Flixel or FlashPunk for the engine itself. Then have fun spending a few years dealing with the networking and all the content you need.
> 2 votes

---
Tags: mmo
---


# Question
Title: How does flash store (represent) movieclips and sprites?
When we draw any object in flash and convert it into a movieclip or a sprite, how is it stored or represented in flash. I know in vector art it is stored or represented as line segments using formulae. Is there any way to get the vertices of the shape that was drawn?

For example, lets say a simple rectangle is drawn and is converted to a movieclip. Is there anyway to obtain the vertices and the line segments from the sprite? So that its shape is obtained. Enough information should be obtained so that the shape can be replicated. That's the key - replication.

In simple terms, where does flash store information about a shape that has been drawn so that we can obtain it and attempt to replicate the shape ourselves?

# Answer
> 3 votes
If I interpreted your comment correctly, you want to: *Have arbitrarily shaped sprites in Flash and automatically extract the shape of these sprites to use it as collision shapes in Box2d*

Usually, collision shapes are much simpler shapes than the graphical asset they represent (performance). A highly detailed 3d Model can be represented just by a chamfered cylinder.

Some physic-bodies can be created automatically by algorithms, but it's also common practice to draw/model them manually. Unless you have a huge amount of different shaped sprites, it's most likely not worthwhile to implement an algorithm that extracts shapes for you.

If you have a look at the following image, you can see that a very complex shape can be represented by some circles and simple polygons (must be convex!). Drawing these shapes manually is (most likely) going to be superior to any algorithm you can come up with.

You could draw these shapes in a vector tool like Illustrator or Inkscape and export them to SVG, which can easily be parsed. Or use Flash and export the shapes as FXG, which is also a format that can easily be parsed.

If I haven't convinced you yet, and you really want to programmatically create the shapes from your sprites, here are two approaches that might work.

1. Render the sprite to a bitmap (using BitmapData.draw) and perform vectorization on the alpha-channel. If the resulting shape is concave, triangulate it.
2. Use the as3swf library to parse an existing SWF file in flash. You can extract shape-information from there. Your main problem here is going to be: Finding the shape(s) that form the outline of your object. Convert this shape into convex polygons.

# Answer
> 3 votes
"Flash" store all the information of the film or videogame into a own format. The data is stored in a vectorial format, this is a format that has a math definition. This is the main diference with bitmaps, because you can scale the image without data loss.

You can access to the .swf file, here is the specification (SWF and AMF Technology Center), and parse the movieclips, shapes, coordinates, etc. Because .swf format is very large you can use the code of SWFRIP project at http://sourceforge.net/projects/swfrip/ and see how you can parse a .swf file.

With a little patience you can obtain the data that you want.

---
Tags: architecture, flash
---


# Question
Title: Constant game speed independent of variable FPS in OpenGL with GLUT?
I've been reading Koen Witters detailed article about different game loop solutions but I'm having some problems implementing the last one with GLUT, which is the recommended one.

After reading a couple of articles, tutorials and code from other people on how to achieve a constant game speed, I think that what I currently have implemented (I'll post the code below) is what Koen Witters called *Game Speed dependent on Variable FPS*, the second on his article.

First, through my searching experience, there's a couple of people that probably have the knowledge to help out on this but don't know what GLUT is and I'm going to try and explain (feel free to correct me) the relevant functions for my problem of this OpenGL toolkit. Skip this section if you know what GLUT is and how to play with it.

**GLUT Toolkit:**

* GLUT is an OpenGL toolkit and helps with common tasks in OpenGL.
* The `glutDisplayFunc(renderScene)` takes a pointer to a `renderScene()` function callback, which will be responsible for rendering everything. The `renderScene()` function will only be called once after the callback registration.
* The `glutTimerFunc(TIMER_MILLISECONDS, processAnimationTimer, 0)` takes the number of milliseconds to pass before calling the callback `processAnimationTimer()`. The last argument is just a value to pass to the timer callback. The `processAnimationTimer()` will not be called each `TIMER_MILLISECONDS` but just once.
* The `glutPostRedisplay()` function requests GLUT to render a new frame so we need call this every time we change something in the scene.
* The `glutIdleFunc(renderScene)` could be used to register a callback to `renderScene()` (this does not make `glutDisplayFunc()` irrelevant) but this function should be avoided because the idle callback is continuously called when events are not being received, increasing the CPU load.
* The `glutGet(GLUT_ELAPSED_TIME)` function returns the number of milliseconds since `glutInit` was called (or first call to `glutGet(GLUT_ELAPSED_TIME)`). That's the timer we have with GLUT. I know there are better alternatives for high resolution timers, but let's keep with this one for now.

I think this is enough information on how GLUT renders frames so people that didn't know about it could also pitch in this question to try and help if they fell like it.

**Current Implementation:**

Now, I'm not sure I have correctly implemented the second solution proposed by Koen, *Game Speed dependent on Variable FPS*. The relevant code for that goes like this:

```
#define TICKS_PER_SECOND 30
#define MOVEMENT_SPEED 2.0f

const int TIMER_MILLISECONDS = 1000 / TICKS_PER_SECOND;

int previousTime;
int currentTime;
int elapsedTime;

void renderScene(void) {
    (...)

    // Setup the camera position and looking point
    SceneCamera.LookAt();

    // Do all drawing below...

    (...)
}

void processAnimationTimer(int value) {
    // setups the timer to be called again
    glutTimerFunc(TIMER_MILLISECONDS, processAnimationTimer, 0);

    // Get the time when the previous frame was rendered
    previousTime = currentTime;

    // Get the current time (in milliseconds) and calculate the elapsed time
    currentTime = glutGet(GLUT_ELAPSED_TIME);
    elapsedTime = currentTime - previousTime;

    /* Multiply the camera direction vector by constant speed then by the
       elapsed time (in seconds) and then move the camera */
    SceneCamera.Move(cameraDirection * MOVEMENT_SPEED * (elapsedTime / 1000.0f));

    // Requests to render a new frame (this will call my renderScene() once)
    glutPostRedisplay();
}

void main(int argc, char **argv) {
    glutInit(&argc, argv);

    (...)

    glutDisplayFunc(renderScene);

    (...)

    // Setup the timer to be called one first time
    glutTimerFunc(TIMER_MILLISECONDS, processAnimationTimer, 0);
    // Read the current time since glutInit was called
    currentTime = glutGet(GLUT_ELAPSED_TIME);

    glutMainLoop();
}

```

This implementation doesn't fell right. It works in the sense that helps the game speed to be constant dependent on the FPS. So that moving from point A to point B takes the same time no matter the high/low framerate. However, I believe I'm limiting the game framerate with this approach. Each frame will only be rendered when the time callback is called, that means the framerate will be roughly around `TICKS_PER_SECOND` frames per second. This doesn't feel right, you shouldn't limit your powerful hardware, it's wrong. It's my understanding though, that I still need to calculate the `elapsedTime`. Just because I'm telling GLUT to call the timer callback every `TIMER_MILLISECONDS`, it doesn't mean it will always do that on time.

I'm not sure how can I fix this and to be completely honest, I have no idea what is the game loop in GLUT, you know, the `while( game_is_running )` loop in Koen's article. But it's my understanding that GLUT is *event-driven* and that game loop starts when I call `glutMainLoop()` (which never returns), yes?

I thought I could register an idle callback with `glutIdleFunc()` and use that as replacement of `glutTimerFunc()`, only rendering when necessary (instead of all the time as usual) but when I tested this with an empty callback (like `void gameLoop() {}`) and it was basically doing nothing, only a black screen, the CPU spiked to 25% and remained there until I killed the game and it went back to normal. So I don't think that's the path to follow.

Using `glutTimerFunc()` is definitely not a good approach to perform all movements/animations based on that, as I'm limiting my game to a constant FPS, not cool. Or maybe I'm using it wrong and my implementation is not right?

How exactly can I have a constant game speed with variable FPS? More exactly, how do I correctly implement Koen's *Constant Game Speed with Maximum FPS* solution (the fourth one on his article) with GLUT? Maybe this is not possible at all with GLUT? If not, what are my alternatives? **What is the best approach to this problem (constant game speed) with GLUT?**

*I originally posted this question on Stack Overflow before being pointed out about this site. The following is a different approach I tried after creating the question in SO, so I'm posting it here too.*

**Another Approach:**

I've been experimenting and here's what I was able to achieve now. Instead of calculating the elapsed time on a timed function (which limits my game's framerate) I'm now doing it in `renderScene()`. Whenever changes to the scene happen I call `glutPostRedisplay()` (ie: camera moving, some object animation, etc...) which will make a call to `renderScene()`. I can use the elapsed time in this function to move my camera for instance.

My code has now turned into this:

```
int previousTime;
int currentTime;
int elapsedTime;

void renderScene(void) {
    (...)

    // Get the time when the previous frame was rendered
    previousTime = currentTime;

    // Get the current time (in milliseconds) and calculate the elapsed time
    currentTime = glutGet(GLUT_ELAPSED_TIME);
    elapsedTime = currentTime - previousTime;

    /* Multiply the camera direction vector by constant speed then by the
       elapsed time (in seconds) and then move the camera */
    SceneCamera.Move(cameraDirection * MOVEMENT_SPEED * (elapsedTime / 1000.0f));

    // Setup the camera position and looking point
    SceneCamera.LookAt();

    // All drawing code goes inside this function
    drawCompleteScene();

    glutSwapBuffers();

    /* Redraw the frame ONLY if the user is moving the camera
       (similar code will be needed to redraw the frame for other events) */
    if(!IsTupleEmpty(cameraDirection)) {
        glutPostRedisplay();
    }
}

void main(int argc, char **argv) {
    glutInit(&argc, argv);

    (...)

    glutDisplayFunc(renderScene);

    (...)

    currentTime = glutGet(GLUT_ELAPSED_TIME);

    glutMainLoop();
}

```

Conclusion, it's working, or so it seems. If I don't move the camera, the CPU usage is low, nothing is being rendered (for testing purposes I only have a grid extending for 4000.0f, while zFar is set to 1000.0f). When I start moving the camera the scene starts redrawing itself. If I keep pressing the move keys, the CPU usage will increase; this is normal behavior. It drops back when I stop moving.

Unless I'm missing something, it seems like a good approach for now. I did find this interesting article on iDevGames and this implementation is probably affected by the problem described on that article. What's your thoughts on that?

Please note that I'm just doing this for fun, I have no intentions of creating some game to distribute or something like that, not in the near future at least. If I did, I would probably go with something else besides GLUT. But since I'm using GLUT, and other than the problem described on iDevGames, do you think this latest implementation is sufficient for GLUT? The only real issue I can think of right now is that I'll need to keep calling `glutPostRedisplay()` every time the scene changes something and keep calling it until there's nothing new to redraw. A little complexity added to the code for a better cause, I think.

What do you think?

# Answer
I haven't read those articles you linked, but whenever I want to implement constant game speed, I call elapsedTime dependent code in my render function. Just like you in your second solution. And I think it's really sufficient for this purpose.
> 4 votes

# Answer
First off, you shouldn't be using GLUT for anything but testing. As far as I know, GLUT was never meant for application development. I recommend picking up SDL or SFML instead.

That said, implementing framerate-independent rendering is relatively simple.

```
// global gLastTick contains the last processed tick (ms)

// game loop
int tick = getCurrentTickSomeWay();
if (tick < gLastTick)
{
  // Going too fast
  sleep(1); // or however sleep is implemented in your framework
  return;   // go another round
}
// Here's how the magic is done
while (tick > gLastTick)
{
  // Update game physics
  update();
  gLastTick += 1000 / DESIRED_PHYSICS_FPS;
}
// Now we're ready to render
render();
// and swap
swap(); // again, however that's done in your framework

```

Caveats:

1. If your game does not get updates for a while for some reason (break in debugger, machine goes to sleep, etc), delta between tick and gLastTick can grow rather large, so adding a safeguard "if (tick - gLastTick \> 1000) gLastTick = tick;" may be useful.
2. If update() takes about as much or more time than (1000 / DESIRED\_PHYSICS\_FPS) ms, the game will grind to a halt. This is mostly relevant for heavy / complex physics cases (like trying to collide 10000 objects. Yes, I tried. It's heavy).
3. User input is still dependent on framerate, so if framerate drops below ~20fps, depending on your game, the game may become difficult to control.
> 8 votes

---
Tags: opengl, c, game-loop, frame-rate, glut
---


# Question
Title: What version of Java should I target for applets?
I recently deployed an applet that seems to require Java 6 Update 24. I assume the reason for this requirement is the matching JDK version I used to create the applet (I am new to Java).

The fact that my applet requires a Java download/update for users who already have some version of Java installed is a big concern for me; the applets I'm creating slip into a web comic, so it's very disruptive. Having used the most recent version of Java, it seems as though I am able to assume that most of the readers I get will have to update Java to continue reading/playing.

Is there a best practice concerning which version of Java to use to make the process of using an applet easy for end-users? Any reading material on this would be very helpful. Should I be using an older version of Java if I don't require new features? I am using Slick for 2D games.

# Answer
Normally the main compatibility issues are between major versions. If you compile for Java 6, it will not run on Java 5 but throw an java.lang.UnsupportedClassVersionError.

So a program complied on Java 6 Update 24 is supposed to work on lower versions of Java 6. But there is a small risk that you invoke a method that was added in a minor release, resulting in a java.lang.IncompatibleClassChangeError or one of its subclasses. The chance for this to happen is really small, usually you get away without explicitly testing older versions.

Stendhal targets Java 6, but tries to be mostly compatible with Java 5. Over the last year the number of users with Java 5 has decreased a lot. I think that is because of the huge improvements Sun made to the automatic update of Java. It is now around 0.1% for us, so we are considering dropping support for Java 5 completely.
> 3 votes

# Answer
Theoretically, if you don't want to require anyone to download a new JVM if they already have one, you must target Java 1.0. Realistically, you can probably expect most if not all of your visitors to have a 1.4 JVM at least, a 1.5 or newer most likely.

btw. if you compiled with 1.6.0\_24 it would run fine on any 1.6 JVM, not require a JVM update.

Personally, I'd not bother targeting a 1.4 or earlier JVM any longer. Those are out of support by Oracle (formerly Sun), and users should upgrade anyway (and will be forced to when visiting some other website if not yours that uses applets).
> 2 votes

# Answer
Java se6 has been around for a while but there are very few resources on it so if you can develop for java five with books like killer game programming in java and developing games in java then you should be fine as they're written for java se5 and considered best in their fields.

Also, if you're using slick2d I think most of it will work with java 5 without any interactions so I would say aim for java 5.

Another thing to consider is that java updates automatically and if the user has java 4+ they would have upgraded to java 6.
> 2 votes

# Answer
Considering Java 6 was released in December of 2006 and runs on just about every major operating system I would target that. Considering Java 6 doesn't really add any language features over Java 5 you could go back, if you aren't using any Java 6 features. However considering Sun stopped supporting Java 5 in November 2009 and thus support for Windows 9x I wouldn't write for it.

Forcing your users have at least Java 6 has other benefits as well as it:

* Guarantees your users aren't experiencing performance degradation due to using outdated libraries.
* Reduces the number of JVMs you need to support. I've worked on projects that fail due to incompatibilities between minor versions. It's rare, but sucks when it happens. Thus it's better to target the version you are developing on or better and politely ask the user upgrade than it is to have your application crash outright because you didn't test version 1.5 Update 6.
* Improvements to your coding style and standards. Stylistically Java has one of the slickest enum implementations ever, but you need to use at least version 1.5 to get access to it.
* Eliminate your chances of implementing a deprecated feature. (There aren't many but they do exist.)
* Ease your upgrade path to 1.7 which has some long overdue features.
* Some older JVMs have security issues. Forcing your user's to upgrade helps protect them against malicious programs, written by other people of course.

There are plenty of other reasons to force users to have 1.6, but without knowing your specific requirements it would take me days to list them. In the end though their is little reason to target older Java versions unless you specifically have to.
> 2 votes

---
Tags: java, web, slick
---