# Question
Title: Can a scrub design/develop a strong competitive fighter?
The definition of Scrub in this question comes from David Sirlin's famous article, Playing To Win

I am a fan of fighters, and I am fairly well versed in design (I get my daily dose of gamasutra). However, I am also a MASSIVE Scrub. I don't like using tactics/characters that I feel lessen the experience or go against the spirit of the game (for example, Street Fighter's roll-cancel glitch, MVC2's infinite combos, Cable, etc).

I will practice and get good at using those tactics/characters, so that I can better defend against them, but I'd never use them against another player.

~~My question is, can someone like me design/develop a strong competitive title, or does my outlook prevent me being able to appreciate elements of design that are a necessity for developing a competitive scene?~~

My question is, are such elements necessary in creating a competitive fighter? What are the "gotchas" a scrub would by hindered by when designing/developing a competitive fighter?

# Answer
> The definition of Scrub in this question comes from David Sirlin's famous article, Playing To Win

Resist the urge to rant on Sirlin... resist the urge to rant on Sirlin...

OK, with that out of the way, yes, you would be perfectly capable of developing a competitive fighting game. As long as you pay attention to what you're trying to make, rather than whether you *personally* like it.

Most competitive fighting games were never designed to be competitive games. Or at least, they are descended from games that were never designed that way. Take the Street Fighter combo system; that is derived entirely from a game bug, yet it is the cornerstone of competitive SF play.

Pop Quiz, hot shot: as a game designer, you are presented with your players (or if the game is still in development, testers) having found a game bug which they have exploited. This bug, when properly exploited, allows them to deal far more damage than your game design normally allowed. Which means that a move that you could punish with one hit (maybe 10% damage at most) can be punished by 30 or 40% damage instead.

What do you do? Do you remove the bug, thus eliminating the problem entirely and allowing your original vision of the game's design to show through? Or do you instead allow the bug to persist and effectively balance the game *around* the bug?

The real essence of this Pop Quiz isn't the answer; it's your justification *behind* your answer.

If you want to remove the bug, why do you want to remove it? Is allowing more punishment really that bad for the game? What is it exactly about the bug that you find objectionable?

If you want to keep the bug around, why do you want to keep it? Does it detract from the challenge, because exploiting it is too easy? Does it make the game one-dimensional? Will it *always* be one-dimensional, or is this simply a temporary metagame moment that will get smoothed out as people learn to deal with it?

> My question is, are such elements necessary in creating a competitive fighter? What are the "gotchas" a scrub would by hindered by when designing/developing a competitive fighter?

The most vital element when creating a competitive game is this: player stratification. Good players must consistently beat weaker players. Good players must have the tools to beat weaker players. The system must have enough depth that good players are able to do things that weaker players can't, and those things must lead to victory. The use of these tools becomes what decides who is good and who is not.

Exactly *how* you bring this about is up to you. However, consider that competitive gamers like the feel of owning the game and the metagame. They like finding and exploiting glitches; they get off on pushing a game so far that it breaks and becomes a different game. In part because that enhances player stratification.

As a fellow "Scrub" (*urge to rant rising*...), the hardest thing you will have to deal with is the simple fact that competitive games are not made for *you*. What Sirlin derogatorily calls a "Scrub" is simply someone who does not enjoy a competitive play environment. We see the design of what the game *ought* to feel like, and any deviation from that is inherently antithetical to that designed purpose.

Because of that, you will constantly want to assert the purity of your original design over the organic growth of your game in development. Resist this urge. Constantly re-evaluate your design as you see the game coming into shape. Constantly remind yourself, anytime you see anything "wrong", that you are making the game for people who are not you.

At all times, you should strive to remember who the game is for. You should make decisions about what goes into the game and how it changes based on how best to serve a competitive gamer. So if a bug comes along that your "Scrub" senses tell you is unfair, evaluate it based on how it actually affects competitive play. And if it helps create useful depth of play, then you should keep it (or at least promote it to a full-fledged feature and work with the good parts).
> 7 votes

# Answer
All other things being equal, I don't see why not as long as you realize the side effects of the decisions you're making, and can balance the game appropriately given that certain players won't abide by self imposed rules of "cheapness".
> 2 votes

# Answer
Just because you don't appreciate an element of a game, doesn't mean you can't design it. You may miss some obvious things, but that's what testers are for. From personal experience, my current project is just begging for an "Achievement System", which I've never found any joy in, but I see a lot of other people do. So even though I don't see the fun, it doesn't mean I can't work with it.
> 1 votes

# Answer
The Roll Cancel Glitch and the Bugs found in the combo system that have morphed into things like infinite combos that you see in games like Street Fighter Alpha are obsolete.

These games are a dying breed and younger players enjoy the far more realistically gounded UFC games which focus on a realistic combo system with real world physics implemented.

Frankly it's the UFC games and even games like Tekken that manage to manufacture far more tactics and strategy during a match than the ridiculous 2D fighters we have grown up with in Arcades.

Don't get me wrong ... I grew up playing Street Fighter in an "ARCADE" anyone remember that?

Re-visiting these games now you realize button mashing and luck was why the competitive players won. ;)
> -3 votes

---
Tags: game-design
---


# Question
Title: C# different resolutions compatible application
Can you give me a quick tour for an application which has to work in different resolutions. It's a game, with lot's of graphics and images and effects. We are using C#. The game is simple 2D, looking like OGame but working like a desktop application. Our problem is how to make it compatible with different resolutions. What I expect you to give me is an advice - which technologies or combination of technologies and/or some basic tricks I should use to make my application work the same in different resolutions. Thank you!

# Answer
What you can do is draw everything to a rendertarget with a nice resolution. Say 1280x720 (a lot of games use this resolution or lower on the consoles). You then get the texture from the rendertarget and stretch it over the entire screen (you might want to add Anti-Aliasing as a post process step when upscaling). When you you stretch the game to a non-widescreen resolution you should add black bars on the top and bottom.

This approach works fairly well, and is easy to implement. But if you want to support a very large set of (odd) resolutions (say 640x480 to 1920x1080) you have to make sure the text and everything is readable by testing the game at all resolutions. Btw don't use anti aliasing when downscaling as this will actually worsen the image.
> 1 votes

---
Tags: c#, resolution, screen
---


# Question
Title: C/C++ code to generate texture coordinates for a curved surface
I have a triangular mesh of a surface curved in two directions, e.g. a sphere. It is therefore not possible to roll this surface flat (essentially specifying a mapping to U,V texture coordinates) without distorting some of the triangles. Does anyone know of a C++ library that can take the mesh as input and produce as output suitable U,V texture coordinates for each mesh vertex, such that the resulting implied texture map distorts the triangles as little as possible?

EDIT: An example of this process is described in this paper \- "Least Squares Conformal Maps for Automatic Texture Atlas Generation". I'm basically after an implementation of that, or something which does the same thing.

# Answer
So, it sounds like you don't actually want a texture atlas *per se*, but instead just a generalized technique for performing a UV unmapping of an arbitrary mesh. Unwrapping can be used to create texture atlases, but not all texture atlases are UV unwrappings, which I why I bring up the distinction.

Unwrapping is a mesh parameterization problem. Specialized solutions exist for simple cases, such as spheres, but arbitrary polygonal meshes are non-trivial. That said, it is a solvable problem because most modelling tools have the capability to do this kind of unwrapping. For example, you can check out Blender's documentation on unwrapping for example (in fact, were you particularly adventurous you could even poke around in Blender's source code to check out their implementations -- but that's probably crazy talk). There's also this tool.

Blender uses the Least-Squares Conformal unwrapping technique, which you can find several academic papers on. This paper is one of the better ones. There is also the Angle-Based Flattening technique, which is related (though older, I believe).

This page may also be of some utility. In particular, on that page you can find the OpenNL library which provides a C++ implementation of an iterative LSCM solver (it's the only one I know of outside of perhaps a few papers that might include a pseudocode implementation).
> 4 votes

# Answer
If you are using OpenGL, gluSphere does it for i.e. a sphere. Make sure to read the part with gluQuadricTexture at the bottom of the page.
> 0 votes

# Answer
My suggestion is to have an artist make the mesh and have them play around with UV mapping it. Tools like Max and Maya have advanced projection capabilities, as well as the ability for an artist to eyeball it until it looks right.
> 0 votes

# Answer
I use UNITY although you'll have to get used to the LUA scripting in it. But manipulating geometric objects is pretty smooth with it. Hope that helps.
> -3 votes

---
Tags: c++, textures, 3d-meshes
---


title: XNA game loop Update and Draw

text:
# Question
Title: XNA game loop Update and Draw
I'm confused on how the game's methods are called and when.

So I read that the sequence is:

1. Initialize
2. LoadContent
3. Update
4. Draw
5. UnloadContent

Where 3 and 4 are the game loop, so after `Update` is called, `Draw` is called, then `Update`, then `Draw`, and so on. The game loop (Update and Draw) is executed 60 times per second.

Then I read in another place that `Update` and `Draw` can be invoked at different times and `Update` may be called more then one time before `Draw` and so on.

... and at the end `UnloadContent` is invoked after the `Update` if the `Exit` method is called.

# Answer
> 13 votes
There is actually two ways that XNA can execute the game loop, Fixed Step and Variable Step. When you setup your game to run Fixed Step, it will consistently call the Update method based on the targeted elapsed game time. So no matter how fast your computer may be, it will always call the Update method at the same elapsed game time interval, so Update and Draw will get called in succession as you described. However, if your game happens to be running slowly, XNA will begin to call the Update method multiple times before the Draw method, in order to "catch up".

Variable Step on the other hand does not attempt to "keep up", or make multiple Update method calls before the Draw method call, if the game is running slowly.

EDIT: Nice form post that explains Fixed Step and Variable Step is much more depth. gamedev.net

*Mirror link for Understanding GameTime - Shawn Hargreaves Blog*

# Answer
> 0 votes
Unless you are writing a game for Windows, and you are loading unmanaged content, don't worry about UnloadContent. If all you are doing is drawing with SpriteBatch and maybe playing SoundEffect and Song objects, just forget about UnloadContent() for now.

For Update and Draw, when you are getting started with XNA, just think in your mind that the XNA Framework will automatically call Update, then Draw, then Update, then Draw... and so on. Are there exceptions? Yes. Do you need to worry about them when you are getting started? No, unless you are an experienced game developer already. If so, accept my apologies...

If your game uses Fixed Time Step, then it will delay so that this loop doesn't go faster than the time step. Windows Phone projects add in a line of code to fix the game to 30fps. You'll learn a little about that by doing nothing more than creating a brand new Windows Game project and then a brand new Windows Phone Game project. Look for the one line of code on the Windows Phone project that fixes time step.

The comment above to look at Shawn Hargreaves post is spot on. In fact, he is THE source if you want frank developer talk on the XNA framework. It's a few years of posts to go through, but that is a good resource.

# Answer
> -2 votes
I don't know a way of changing the order, but Update and Draw are just functions so you could call them from other places - though I can't think of a use of this. As a general rule, you would just use Update, Draw, Update, Draw etc. like you said.

Unload is called after exit function is called yes.

---
Tags: xna, game-loop
---


# Question
Title: What do potential employers look for in a good portfolio?
A buddy from work and myself are wanting to get into the indie scene for game development. I've done a few tech demos demonstrating different ideas and approaches for various problems. Now, I feel it's time for us to commit to a project in order to develop a portfolio for later down the road.

I've been struggling greatly with how to begin an actual project, more specifically to create an engine or use an OTS package, or use one then create one, or create one then use one.. etc.

**Which looks better to potential employers? A smaller portfolio of games that includes your engine or a (possibly) larger one that was built using something OTS?**

I am a programmer. I'm not an artist. I will be performing most of the programming for this project. My buddy is also a developer, but he is also proficient with graphical tools (thus, he becomes the art guy).

At work, we are both .NET developers (C#). I know, I know "Well then use XNA" some will yell at me. The demos I've completed thus far have been in XNA. But I have some concerns with building an XNA portfolio. While it is nice to abstract DirectX, I worry that I may not build the necessary knowledge base to extend beyond XNA easily. The counter to that argument is probably "you can more easily move on to DirectX after XNA", but since I will move careers from Business Development to Game Development, is it even worth while to focus on XNA currently? Or will potential employers giggle when I say XNA?

**Should I embrace the experience of XNA knowing the concepts and lessons learned will mostly transfer? Or spend my most valuable resource (time) else where?**

Looking for some advice from any industry vets out there.

# Answer
> 44 votes
I've been a programmer in the console game industry for almost fourteen years, and have often been involved in hiring decisions.

So speaking as one of those potential employers, when evaluating a possible employee there are three things I look for in a new hire, and I look for them in this order.

1. Will this person fit into my team? (social, hygiene, etc)
2. Is this person a quick learner? (often incorrectly phrased as "is this person smart?")
3. Does this person have any relevant experience that will help me?

Now, addressing your question. This whole "which type of project should I do" issue is addressing by far the least important of the criteria that I care about. I care far more about whether you'll fit into my team socially, and about how well you'll be able to learn new things quickly, than I care about whether you used XNA or your own game engine in some previous project. By and large, I'm assuming that I'm going to have to train you up in our own in-house game engine, and so your earlier projects don't really matter to me at all. That is, of course, unless you magically happen to have experience with a particular tool or technology that I need someone to know about. But this is unusual; usually, I'm assuming that I'm going to have to train you up to use our API.

All of this isn't to say that I don't want you to have done home projects. I absolutely do. But I don't really care about what those projects are, or what technologies they used, because they probably aren't going to be relevant to what I need you to do for me, since we'll be using different libraries or APIs.

But I do want you to tell me about your projects. I want to see how enthusiastic you get when you talk about them, because that tells me about what sort of person you are (see point 1, above). I want to hear about the problems you ran into, and how you overcame them in developing your project (see point 2, above). I absolutely want you to have completed at least one project -- being able to push through the pain and actually complete something says a lot about the sort of person you are, and tells me that you're somebody I'll be able to rely on if ("when") things get tough.

So honestly, neither option is "better"; the important thing is to complete something, anything. Any technology you learn along the way is icing on the cake, but almost certainly isn't what would make me hire you.

(But with all that said.. I *will* expect you to be proficient in C++. One way or another, you really need to learn C++ in order to get hired into the mainstream games industry. Your home projects don't necessarily need to be in C++, but I'll expect you to be able to demonstrate fluency in it.)

# Answer
> 12 votes
One thing others haven't mentioned yet is that it's important to finish your projects.

Having a portfolio with a bunch of unfinished things isn't nearly as impressive as a portfolio with one finished, well-polished thing.

Also, if you base your work on someone elses' existing work (such as some open source engine, or freely available art assets), make sure you mention on your portfolio which part is yours.

# Answer
> 4 votes
It seems to me that the answer depends on what kind of game programming you want to do.

If your goal is to be an *engine coder* or *graphics coder*, you'd benefit from going under the hood and learning how engines work. This doesn't mean you can't use XNA or another off-the-shelf engine, framework, etc. Gaining familiarity with the innards of a high-quality engine is a great way to learn how to build a high-quality engine! If you go this path, you don't *necessarily* even need to write any actual games. A portfolio of standalone graphics demos and/or nontrivial extensions to an existing engine (e.g. implementing a new shader in an engine or suchlike) will do you well. You can take a look at my portfolio of graphics demos here; it's a few years out of date now, but this is basically what got me a graphics programming job at a game studio.

On the other hand, if you'd rather be a *gameplay coder*, one of the people who work on the game mechanics, controls, enemy AI, etc. then your time won't be well-spent digging into Direct3D. Of course it's helpful to have a general, high-level understanding of how graphics works, but in a professional context you probably won't be coming into direct contact with low-level graphics stuff very often. In this case I would absolutely recommend using an off-the-shelf engine so that you can spend your time building actual games.

So, to sum up, if you want to do gameplay then just use an existing engine; if you want to do engine/graphics then build your own stuff and/or extend an existing engine.

# Answer
> 2 votes
when i was just finishing uni my portfolio was featured in this article. it does seem a good idea on what to do and what not to do when getting your portfolio together

http://leewinder.co.uk/blog/?p=23

# Answer
> 1 votes
Don't do your portfolio based on how you perceive the "standard" to be. You should work on projects that interest *you*. If you like game mechanics, go ahead and make a bunch of games. If you like creating interesting AI, maybe make a demo for an RTS-like setup. As an example, I have a growing interest in graphics programming, and putting more time into learning rendering concepts and applying them in my engine. (Consequentially, my game project has been temporarily put on the shelf.)

When you work mostly on things you like, it really brings out the "you" in the portfolio. On the other hand, having at least one completed game shows that you can pull through the "uninteresting" parts of making a game. It's good to have some degree of flexibility to break into less familiar territory, but don't force yourself into it extensively. You can tell good portfolios from the level of enthusiasm and interest put into the work, and projects based on your areas of interest are naturally gonna get the most polish. So whatever your area of interest is in, you will eventually have to focus towards that area of programming for a job.

---
Tags: career
---


title: Anyone have a game UI recommendation?

text:
# Question
Title: Anyone have a game UI recommendation?
> **Possible Duplicate:**
> What C++ GUI library can you suggest?

I am creating a simple 2 dimensional GUI for an RPG game. It will be pretty simple and will contain a few windows a chat box. Does anyone have any suggestions for UI code to use?

# Answer
For really, really, really simple GUIs, I recommend rolling your own IMGUI library. If all you need are buttons and sliders, it's dead simple. If you need anything more, I recommend looking at some other GUI libraries, though.
> 4 votes

# Answer
I have had a positive experience with Guichan. It has an SDL back-end (as well as others) and a good set of basic widgets.

Some highlights:

* Widgets are easy to extend, which makes it great if you're building a simple RPG GUI. I was able to extend widgets for my game such that new ones could be created entirely by the scripting language -- it was great!
* It is not multi-threaded, which could be seen as a positive and a negative. It's up to the implementer to decide when (and in which thread) things are rendered.
* It allows components to communicate through the use of an Event system.

If you haven't already, check it out. I have used it in the past and plan on using it for my next project.
> 2 votes

# Answer
The Ogre3D team recommends both Crazy Eddie's GUI System and MyGui, so they might be worth checking out.
> 0 votes

# Answer
There are Flash based GUI systems too. There's the open-source projects GameSWF and Hikari for . There are commercial products too - Scaleform
> 0 votes

---
Tags: c++, gui
---


# Question
Title: Is there a better way to set up an event system?
Event Systems are amazing, they make extremely unwieldy code tame and really allow for dynamic creation of games through easy communication of objects and the game loop. I am having a hard time with the efficiency of my current implementation. Currently my slight optimization of separating the lists of objects into the events they respond to has done wonders, but there should be more I can do.

Currently I have two methods:

1. **Simplest :** all objects are added to a vector when an event is sent all objects are sent the event through it's handle\_event() method
2. **More complex :** I have a map with string as it's key and int as it's value. When an event type is added, it's added to this map, with the int simply being incremented (there must be a better way)
the vector of vectors of objects then pushes back a new vector to handle that type of event.
When an event is called it simply calls the corresponding int in the eventTypes map to the type inside the vector of vectors of objects and sends that event to each object handling that event type.

These first method is quite slow (obviously) for lots of objects, but quite quick for very few of objects. Whereas the second method is quite quick with large objects that would like to handle different types of events, but slower than the first method per object with objects handling the same type of event.

Is there a faster (run time wise) way? Is there a faster way to look up an int from the string type? (Initially I had an enum, but it didn't allow custom types, which are necessary because of the desired level of dynamism.)

# Answer
It sounds like you're saying the big performance bottleneck is looking up event IDs (integers) from their string names. You could preprocess your game data to convert all event names into integers before running the game, or possibly while loading the level; then you wouldn't have to do any conversions during gameplay.

If objects are frequently being created and destroyed, there may be a lot of churn in the vectors of objects. In this case you could benefit by using linked lists instead of vectors; they're faster for insertion and deletion.
> 5 votes

# Answer
Well, let's get the simple stuff out of the way first. You have this `map` between strings (the name of the event, presumably) and integers (the index of the registered event listeners).

Lookup time in a `map` is based on two things: the number of items in the map, and the time it takes to do the comparison between two keys (ignoring cache issues). If the lookup time is a problem, one way to handle it is to change the comparison function by changing the string type.

Let's assume you're using `std::string` and `operator<` for comparison. This is highly inefficient; it does a byte-wise comparison. You don't care about the real string less-than comparison; you just need some kind of comparison that gives a strict-weak ordering (because `map` doesn't work otherwise).

So you should use a 32-byte fixed-length string instead of `std::string`. I use these for identifiers. Comparison tests for these fixed strings don't do byte-wise comparisons; they do 32-bit (or 64-bit) comparisons instead. It takes every 4 bytes as an unsigned integer and compares it with the corresponding 4 bytes of the other string. That way, the comparison only takes at most 8 compares. It ensures a strict-weak ordering, though the ordering has nothing to do with the data as characters.

Storing strings longer than 31 bytes (need the NULL character) truncates the string (but from the middle, rather than the ends. I find that entropy tends to be greatest at the beginning and the end). And strings shorter than that pad out the remaining characters with `\0`.

Now, you could ditch the `map` entirely and use a hash table. If you really have over 100,000 different kinds of event types, this could be a good idea. But I don't know of a game where that would be a remotely reasonable thing.
> 2 votes

# Answer
To answer the general question:

> Better Way To Set Up an Event System

There is none. All you can do is identify the specific needs you'll have for your event systems (there can be several different) and then use the right tool for the right job.

I've implemented and tried to generalize tons of event systems and I have come to this conclusion. Because tradoffs are really differents if you make it compile-time or run-time, if you use object hierarchies or blackboards etc.

The best way is to study the different kinds of event systems and then you'll have clues about which one to use in which case.

Now, if you want the really most flexible system, implement a black-board system (runtime) with dynamic properties of events and you'll have something very flexible but maybe very slow.
> 0 votes

---
Tags: performance, events
---


# Question
Title: client/server Silverlight turn based game - domain model question
I am making multiplayer (2 players) Minesweeper like the one that's available on MS Live Messenger.

Client side is going to be silverlight, server side will be MVC Application. Client (the one who is waiting for his turn) will poll server every X seconds to get current state, the other client (who's turn it is will post his click to server and than roles will reverse)

Now my question is: should domain model classes be the same for client and server side? I mean you need Minefield class on both sides, but while server-side class will have rules and logic, client-side will be more or less a data holder.

# Answer
I suppose you could use the same objects on the client side to represent the state of the "game board", but the client shouldn't need much more than that. When a player makes a move (clears a block), the client should only need to issue a command to the server (with the payload being the coordinates of the block to clear). The server could then process the move, and the clients would download the new game board state. The game board state itself should not contain any logic, so it could be quite appropriately used by both the clients and the server.
> 2 votes

# Answer
I know the question is kind of old but...

I've found that having a common DLL containing domain model classes is useful. The server classes inherit from these and add some logic. The client classes also inherit from these and add some animation data to them.

For network performance reasons I had custom serialization and deserialization routines in the common DLL as well. Deserialization took a factory as parameter such that new objects were of the server or client type depending on usage.
> 0 votes

---
Tags: multiplayer, client-server, silverlight
---


# Question
Title: Run-time Navigation Mesh Generation for 2D Tile Maps
I have a 2D tile map, where each tile is marked as blocking or non-blocking. Each tile is 16x16 pixels and sub-tile movement is possible. I'm attempting to generate a navigation mesh from this data, at run-time, using C++.

Is there any well known library that can be used to generate a navigation mesh, given a 2D tile map? Alternatively, is there any algorithm that can be used to intelligently generate a navigation mesh from the tile data?

As far as I can tell, all of the popular solutions are aimed at 3D maps and don't perform well when given the simplified case of a 2D map.

# Answer
One idea would be to turn the center points of your tiles into a graph (see your data structures text book), on which any number of pathing/traversal algorithms will work (A\*, depth first and breadth first traversals). Given the results, which would be a queue of points to follow, your movement routines can build a smoothed path to follow with splines or simply use LOS checks to get from place to place within that point set.

Another idea would be to actually use your tile set and build a 3D representation of your walkable squares and feed it to your favorite 3D navmesh generator and library.

In either case the pixel count doesn't matter as long as you decide on a standard of one tile = 10 units in space (totally arbitrary), just to keep things simple for your math.
> 3 votes

---
Tags: c++, path-finding
---


# Question
Title: Determining if player-created structure matches a template in a 3D block-based game
Disclaimer: this is one of those dreaded Minecraft-style questions, but I feel it's more a data structures and algorithms question

I'm really new to 3D data structures and am wondering what the best way to store and match a 3D block structure.

Right now, the player is able to place blocks in any arbitrary space and when these blocks match a pre-defined structure an event happens. The way I'm doing it currently is when a player places a block the game recursively checks each adjacent block to find the block with the lowest x, y, z coordinate and makes that block the root block. Then it checks the rest of the blocks, based off of the root block, to make sure they match a certain template. The problem is that as the template gets more complicated, so does my (terribly inefficient) code.

I'm thinking the best way to do this is to store some type of matrix that defines the structure and then match against the matrix whenever a player places a block. Are there already data structures/algorithms that would match this type of problem?

# Answer
> 10 votes
To be honest, I'd take the simple solution.

Make a matrix that defines the structure. Whenever a block is changed, attempt to apply that matrix to all locations that might have created the new structure. That's going to be width\*depth\*height locations, since the player could have finished any point on the structure, but it shouldn't be too bad because most of these locations are going to early-exit when the first check fails.

Basically, you've got a 3d matrix, and you're comparing it against another 3d matrix, at a bunch of offsets.

From here there's a bunch of totally optional optimizations you could do. For example, if your structure is extremely sparse - i.e. the player is building a tall tower with a sphere at the top, but you don't care if the bottom of the tower is surrounded by trees - you could turn it into a *list* of blocks instead of a matrix. (I'd generate the list from the matrix - the matrix will be far easier to maintain directly.)

If you wanted to be super-clever, break the structure apart into blocktypes. If you know that the player just changed block 1,2,3, and you know that placing your structure at coordinates 0,0,0 would require block 1,2,3 to be obsidian, and block 1,2,3 is wood, then you don't even need to try block 1,2,3. Generate all possible offsets for the structure given that the player has just placed a specific type of block. Then, when the player places that block, just check the pregenerated possible offsets.

But, seriously, this is all optimization. Just make a matrix, then compare your matrix with the world brute-force style. Assuming you're making something Minecrafty, people really don't place all that many blocks - a few blocks every second at most. Unless you have hundreds of huge structures you'll be able to test that easily.

# Answer
> 0 votes
Well you come up with an interesting problem. I would suggest something like the following: use your blocks as pixels and do a per/pixel collision detection, where all blocks must match to return a true collision.

This would work fine, however make sure you only do this when objects/blocks change. So I'd recommend a simple event system to pass a change to a object checker, that can certainly use your algorithm. Which would then do whatever you want that object to do. Also I'd recommend checking height and width, before running the algorithm, because if it isn't high enough/is too high obviously it won't match.

As far as a data structure, a simple vector would do, or perhaps a custom data structure.

Interesting question.

---
Tags: 3d, algorithm, data-structure, minecraft-modding
---


# Question
Title: Physics or Time-Based Animation In Corona SDK (iOS) Using Box2D
I am part way through creating a Doodle Jump clone for iOS using Corona SDK. I'm currently using the physics engine (box 2D). It's not a straight clone, but I need the basic principles in place to progress to the next stage of development.

I have encountered a problem that is prohibiting me to carry on, and I'm wondering whether it's worth re-writing the game using time based animations rather than the physics engine, as it could give me more flexibility.

The problem I'm faced with involves moving the platforms down and the character's height. If you play Doodle Jump and watch how the character behaves you'll see that he doesn't EVER go any higher than a certain point, no matter what height the platform he came off was. The higher he appears to jump is actually the platforms moving down faster. The character also jumps for the same duration every time. If you look at his position on the screen, he may only move up by a few pixels, but he'll appear to be jumping for a lot longer, the same length of time for each jump.

I cannot grasp how this could have been achieved using the physics engine. I am currently moving the platforms down at the same speed as the character moves up - but this doesn't stop him gaining height, and doesn't mean his height on the screen is fixed.

I have an idea how to do it in the physics engine, but it seems VERY complicated for something so simple. It would involve working out a calculation for his current height and then manipulate the gravity and his density so that he always jumps the same height for the same length of time. This would be a trial and error scenario, and to be honest, it's clutching at straws.

My question is, has anyone achieved this behaviour already, know how it has been achieved, or can shed any light on it? Would I be better with the physics engine, or with time-based animation (using timers to manually track the ball's position and use easing libraries to mimic basic physics)?

Here is a link to a YouTube gameplay video of Doodle Jump, hopefully you'll see what I mean - it's a difficult concept to describe in text. http://www.youtube.com/watch?v=kIqG2ICUS-c

# Answer
> 2 votes
Let me describe a bit how I do specific-height physics jumps in my current Corona game:

* Both the hero as well as the platforms are physics objects
* I put my own non-physical functionality and data on top of every sprite in the game, where needed (as I have a sprite object which mixes physics and manual behavior)

When the hero runs right, I apply constant velocity right, in every frame of the game. Sort of like this ("self" is the hero, as this is the hero's main handling function):

```
self.data.speedX = 100 -- or whatever value
local speedX, speedY = self:getLinearVelocity()
self:setLinearVelocity(self.data.speedX, speedY)

```

You can see that speedY is "ignored" because I'm passing back the same value it had (I suppose passing nil didn't work, I'd have to check again).

What happens when the hero -- heroine in my case! -- jumps, i.e. when the jump button control I made receive a touch event? Then I do something similar to this (not actual code, again, but snipped to get the point across better):

```
local speedX, speedY = girl:getLinearVelocity()
if speedY >= -5 then -- I allow multiple jumps, but only when descending or about to descend
    local speedY = -9
    girl:applyLinearImpulse(0, speedY, girl.x, girl.y)
    girl.phase:set('justJumped', 25, 'default') -- ignore if you want, this is just my sprite object handler, which could trigger sounds, animations, further behavior for the "justJumped" phase
end

```

The result for my game is that I have very specifically timed jumps. Each jump has a known specific height and length, so I can create jump n run style puzzles which rely on this.

Hope this helps!

# Answer
> 0 votes
I created a game similar to Doodle Jump using Corona (called Dungeon Tap), where the basic game logic was the same: platforms move down as player moves up. The only difference was the platforms slowly moved down on their own, and the player controlled his jump.

The platforms moved down based on gameSpeed variable in an enterFrame listener. When the character reached a certain point, the gameSpeed adjusted until the player fell below that certain point, giving off the illusion that he could never pass a certain point on the screen. Here is a snippet of my code:

```
if playerObject.y < 185 then
    gameSpeed = -playerObject.y + 175
else
    gameSpeed = startGameSpeed
end

```

As you can see, the gameSpeed is adjusted depending on the player's y position. With that, the player never moves past a specific y-position on the screen. The platforms just move quicker downward until player goes back below the "threshold".

Hope that helps!

---
Tags: physics, box2d, ios, corona-sdk
---


# Question
Title: What technology does the iPhone game "Zombie Highway" use?
Does anyone know anything about the technology behind the "Zombie Highway" iPhone game?

What 3D engine does it use, especially what kind of tools did they use for the UI animations, transitions, etc.?

Also, when you go to the settings screen, they are using the native iPhone keyboard and controls. Do you think that's all UIKit overlaid on top?

It looks brilliant!

# Answer
> 1 votes
Try contacting them through their website. If they are nice enough they will disclose some technical info about their projects.

Yes, usually when you need to show keyboard input or message alerts, a new UIKit layer is overlaid on top of the existing OpenGL view.

---
Tags: iphone
---


title: Is XNA for iOS overkill?

text:
# Question
Title: Is XNA for iOS overkill?
I'm working on iPAD game using MonoTouch which is similar to an IQ testing game. At the moment, I can write some simple games using basic UIImages and animations.

I'm wondering if I should learn XNA to create a game where people can throw a ball against a wall and see it bounce.

Has anyone seen any good examples of tutorials using XNA for simple 2d games?

# Answer
There isn't "XNA for iOS". You can use MonoGame, an attempt to recreate the functionality of XNA under Mono. And yes, you can do a lot of things with it (if you stick to 2D games, they don't have 3D support yet); and you *should* use lower-level APIs like this if you are creating more complex, performance-demanding games.

Check MonoGame's site (previously linked) for examples of successful games published on iOS.
> 6 votes

---
Tags: xna, monotouch
---


# Question
Title: When would I use "scripts" or "scripting" in a game, as opposed to the core language?
The terms scripts and scripting appear to be used interchangeably on the Game Development Stack Exchange, but other than reading questions about a scripting language choice, I don't understand the relationship between scripts and scripting, and the core language. What does a script typically do, when would it be used, and are scripts in some contexts (as defined by game programmers) different than a scripting language?

# Answer
Scripts are written for a scripting language. People can use the words in slang sentences to get the muddling that you are referring to but ask anyone for the definitions of Script, Scripting and Scripting Language and you will get something like: Scripting is the act of writing Scripts using a Scripting Language.

When you embed a scripting language into a game engine, or core language as you are referring to, you are exposing not only the objects within the game engine but also allowing logic to be written for the game engine. One other thing of note is that this turns your game into kind of a virtual machine, as scripting languages seldom compile down to machine language and are instead put into a form of byte code and interpreted at run time by your game engine.

This has some huge benefits to the development team, a few of which you can find listed next:

* Scripting languages are usually memory managed so you do not have to worry about allocations
* They are usually a loosely typed language that removes the need to make sure you are using the variable type for what you are doing, just make a variable and go with it.
* The languages themselves are often very simplistic while delivering quite a bit of control to people who are not programmers
* Altering scripts does not require the core engine to be recompiled.
* Scripting vs Coding often reduces the time required for very iterative tuning of game logic.
* Depending on design and language, you can often reload a script while the game is running for even easier tuning/testing.

I am sure the list can keep going on and on I am sure, especially when you get into specialized game types and how scripting can help define group formation rules for moving groups of units in an RTS or how you can create a UI's logic in a scripting language to provide an extensible UI to your end-users and the like.
> 16 votes

# Answer
Using scripting has many advantages over "core language". Some of these include:

* Moving (more) of the content from core developers to artists, freeing the core developers to engine tasks from gameplay tasks
* Scripts tend to be sandboxed, can't do anything really dangerous in it
* Modifying scripts does not require recompilation and re-execution of the game
> 9 votes

# Answer
A script is usually a piece of code that runs outside your core engine. It is usually contained within text files wherever you like to keep them. Then it is usually loaded by the engine, parsed, and executed at runtime.

What generally happens is that whatever language you use (Lua, Angelscript for example), this language usually has some facilities that enable the engine programmer to expose engine-functions or even entire classes to the instance of the "scripting engine" that is currently running.

For example (totally stupid example, but just to get the point across) your game code might have a public function that spawns zombies somewhere:

```
void SpawnZombie(int x, int y, int hp /* whatever else */)
{
   //...
}

```

The scripting language that you use now enables you to expose this function to the scripting parser that is running. This effectively means that you can open a text file, write "SpawnZombie(200,300,1337)" and once your engine executes the code, a Zombie will spawn at that location.

The other answers already list a couple of good examples of how this is typicaly used, but they leave out one point which I find very important:

These kinds of scripts make it very easy to debug or test gameplay during runtime.

Let's say you want to figure out the perfect way to place a zombie in the map so it has the maximum scare effect on the player once they discover it. Without scripting support, you'd have to exit the application, change some magic numbers in the code, recompile and test it.

With scripting support (providing you already have some method of entering text during runtime, for example a debug console), you just type in "SpawnZombie(333,444,555)" and see how it looks.

In the same manner it could be possible for you to spawn weapons, vehicles, load different maps, change the values of some things in the game etc, instakill enemies because you don't want to waste time getting to the part that needs to be tested etc.

This will save you tons of times in more complex games.
> 6 votes

# Answer
1) Scripts are often much easier to modify than code.

2) Scripts are often field-modifiable. This permits modding the game.
> 2 votes

# Answer
Most scripting languages are a lot more expressive than the language in the core engine. Often the engine is written in a relatively low-level language (eg. C++) for performance reasons, but the gameplay code doesn't need to be as performant and so the priorities shift toward being able to express functionality easily.

For example, dynamic vs. static typing. Another example: garbage collection vs. manual memory management.
> 2 votes

# Answer
Scripting allow you to write logic at a higher level. In other word, you write less code with more functionality.

So an example, the following shows the difference between writing something in code and writing it in a script language.

# Game Code

```
Update Loop
{
    if (CarExplodeAnimation.FinalFrame == true)
    {
        SceneGraph.Remove(Car);
        Message("You have destroyed the car.";
    }
    else
    {
        CarExplodeAnimation.AdvanceToNextFrame();
    }

```

}

# Script Code

```
PlayAnimation(ShipExplode)  // blocks until animation completes
Message("You have destoryed the car.")

```

See how much less coding the designer have to do if you use a scripting language?

The reason is becase in game code, you have to split an event into multiple frames, and write code from a multiple frames perspective. On the other hand, scripting allow you to think of multiple frames event as a just a single line of code, because all the extra codes are abstracted behind an script function.

You may asked, but can't that function just be written in game code too? Well, yes, but that means the designers will have to open the source code of the game engine and write all the codes in there, and you don't want your designers going through the source code of the game engine (they might accidentally change some other code and the whole thing crash).

Instead, you want your designer to do something like this instead: Right-click a car in the Map Editor, click Insert Script, type in the script codes. There's no messing with the critical game engine source codes.
> 0 votes

---
Tags: scripting
---


# Question
Title: Maya depth buffer plus OpenGL depth buffer
I am trying to write an plugin for Maya, using -among other things- OpenGL. Everything works fine so far, but the final Maya scenario is not taking into account the OpenGL depth buffer (or OpenGL is not taking into account the Maya depth). Hence, OpenGL things always appear "over" the Maya native objects.

I looked at the Maya's documentation and I found out that you can get Maya's depth may through MStatus M3dView::readDepthMap function, which basically returns a float array with Maya's depth.

I am now in a situation where I have two float arrays, one with OpenGL depth's and another with Maya's depth, and I believe I should combine them both somehow to get a final render in Maya that would respect both depth maps.

So, the question is, is there anyway to "add" depth information into OpenGL's renderbuffer / depthbuffer? Or... I am trying a completely wrong approach and there's a much nicer and better way to do this?

Thanks a lot!

# Answer
I am answering myself here, I hope it helps others when dealing with the same issue...

The trick here was to use MStatus M3dView::readDepthMap rather than MStatus M3dView::readDepthMap.

readDepthMap creates a 2D texture of the current Maya depth map. Note that you have to previously generate and bind this texture as follows

```
int mayaDepth;
glGenTextures(1, &mayaDepth);
glBindTexture(GL_TEXTURE_2D, mayaDepth);
GLint m_viewport[4];
glGetIntegerv( GL_VIEWPORT, m_viewport );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, m_viewport[2], m_viewport[3], 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
MStatus status = view.readBufferTo2dTexture(0, 0,m_viewport[2], m_viewport[3]);

glBindTexture(GL_TEXTURE_2D, 0);

```

This texture can be later on used in a GLSL fragment shader. Comparing the OpenGL depth accessible through gl\_FragCoord.z and the depth information from Maya that can be passed to the GLSL shader through a normal sampler2D, you can decide whether to render your OpenGL stuff or Maya as follows

```
if(gl_FragCoord.z < maya_depth_value)
    gl_FragColor = col_acc;
else
    gl_FragColor = vec4(0,0,0,0);

```

Good luck! :)
> 0 votes

---
Tags: opengl, maya
---


title: Is there anything like XNA for c++?

text:
# Question
Title: Is there anything like XNA for c++?
I love the features of XNA but I want to get into c++ game dev. The problem is that I now have to worry about everything from loading a png file to opening a window. This is a little bit annoying.

I would really like a c++ version of XNA to solve these issues for me.

# Answer
> 16 votes
I would recommend that you look at SFML and Polycode.

I think the answers here are kind of missing the point. It is annoying to have to link to ten different libraries, such as Freetype, libpng, tinyxml, Ogg, Vorbis, etc, to get some basic XNA features.

---

**SFML**

http://www.sfml-dev.org/features.php

SFML is a free multimedia C++ API that provides you low and high level access to graphics, input, audio, etc. In a sense, its kind of similar to XNA but does not hold your hand as much. For example, SFML does not have a Model class.

---

If you are planning on using Models in your games, you should look at using Assimp.

Assimp adds support for importing the following formats:

```
Collada ( .dae )
Blender 3D ( .blend )
3ds Max 3DS ( .3ds )
3ds Max ASE ( .ase )
Wavefront Object ( .obj )
Stanford Polygon Library ( .ply )
AutoCAD DXF ( .dxf )
LightWave ( .lwo )
Modo ( .lxo )
Stereolithography ( .stl )
AC3D ( .ac )
Milkshape 3D ( .ms3d )
Quake I Mesh ( .mdl )
Quake II Mesh ( .md2 )
Quake III Mesh ( .md3 )
Quake III BSP ( .pk3 )
Biovision BVH ( .bvh )
DirectX X ( .x )
BlitzBasic 3D ( .b3d )
Quick3D ( .q3d,.q3s )
Ogre XML ( .mesh.xml )
Irrlicht Mesh ( .irrmesh )
Neutral File Format ( .nff )
Sense8 WorldToolKit ( .nff )
Object File Format ( .off )
PovRAY Raw ( .raw )
Terragen Terrain ( .ter )
3D GameStudio ( .mdl )
3D GameStudio Terrain ( .hmp )
Izware Nendo ( .ndo )

```

---

**Polycode**

http://polycode.org/features/

> Polycode is a free, open-source, cross-platform framework for creative code. You can use it as a C++ API or as a standalone scripting language to get easy and simple access to accelerated 2D and 3D graphics, hardware shaders, sound and network programming, physics engines and more.
>
> The core Polycode API is written in C++ and can be used to create portable native applications.
>
> On top of the core C++ API, Polycode offers a Lua-based scripting system with its own set of compilation tools. The Lua API mirrors the C++ API and can be used to easily create prototypes and even publish complete applications to multiple platforms without compiling C++.

Polycode is opensource, meaning that you can learn from how things are done behind the scenes. Also, it uses Assimp to load models so you do not need to worry about manually linking to Assimp.

# Answer
> 4 votes
There are literally hundreds of libraries out there that handle all kinds of aspects of game development. From loading images, to opening and managing windows, to rendering, to sound, to physics, etc.

What there are not are very many "one-stop-shop" solutions, where you get everything all at once. That's one of the benefits of XNA. You generally have to pull together many libraries to build an engine. This gives you great flexibility, as if one component is lacking, you can (relatively) easily swap it out for another. But at the same time, it requires more work.

Really though, why are you so hung up on what programming language you want to use? It seems to me that you really like XNA and want to use it for game development. So go do that.

# Answer
> 3 votes
You can use the D3DX and the DXUT at first, which are not stuffed like XNA but helps a lot on setting the environment at least, such as creating a window, running the main loop and have some useful functions such as D3DX11CreateTextureFromFile()--you will have to manage the pointer though, but it's not *that* hard. There are also many libraries you can use in C++, which you can replace with your own if you want to improve performance or whatever you want to change.

The D3DX libraries and the DXUT are best suited for D3D9 and 10, and DXUT comes with its source code. For DX11 they culled some functions from those libs but I hope they still have the most useful ones, and if I remember well now they provide the effects framework in source code form (for if you have the patience to explore it).

I've learned much more when working at lower levels than over pyramids of frameworks, so I can't say you to use XNA, but that depends on your goals mostly.

# Answer
> 1 votes
If you are just getting familiarised with c++ language, I would recommend using a simple library like SDL for getting experience in game development and then programming using openGL.

---
Tags: xna, c++
---


# Question
Title: Am I hurting myself by not knowing C++ for game design?
Right now, I feel I am strong in both Java a C#. (Not much of a leap from one to the other really).

While I don't expect a game designer/programmer is an attainable goal early on in my career, This is a goal I will reach later on in my career.

With this in mind, I feel that ignoring C++ and game design tools associated with it are eventually going to hurt me or slow me down in my ability to reach my goal.

Is this the case? Or can I continue to hone my C# skills using XNA and WPF for personal projects that can elevate me into such a career?

# Answer
> 21 votes
IMO, yes, you are likely to be hurting yourself. First of all, rightly or wrongly there *is* a perceived hierarchy among programming languages -- and C++ generally has a higher standing than Java or C# (e.g., questions like yours are fairly common -- the reverse is virtually unheard of). If you apply somewhere that uses C# or Java, and you know C++, they're unlikely to question your programming ability. If you apply somewhere that uses C++ and you know C# and Java, there's a *pretty* fair chance, they will question your programming ability, at least to some degree. That's not to say the perception can't be overcome, but you're still putting yourself at a disadvantage.

Second, at least among the independent game developers I know (admittedly, not very many), there's some basic dislike of C# just because it's from Microsoft. Sun was viewed a lot more positively, but since the Oracle buyout that doesn't seem to be the case anymore at all. Most see "Oracle" and "cool games" as about as close to exact opposites as humanly possible.

Finally, from a practical viewpoint, games are one of the places where C++ is used most heavily. If you don't know C++ to at least a reasonable degree, it simply restricts your options considerably.

# Answer
> 5 votes
It isn't entirely clear, but what are your goals? To be a game designer? What do you think that position is/does?

In the basic case, as long as you're not writing actual code, not knowing C++ specifically won't hurt you. Of course, having a fundamental understanding of programming itself (object oriented design and being able to think in terms of conditionals, etc) *is* going to help you. What C++ itself does compared to C# or Java probably isn't going to matter when it comes to helping design game rules that are easy to describe with code.

# Answer
> 3 votes
It really depends on what your goals are. If you want to move into design as quickly as possible and work your way up there to be a director, the technical background you have knowing Java and C# well will be more than enough.

If your intent is to work your way up to a senior / lead programming position and move over to a director position from there, you'd better learn some kind of unmanaged language. Not necessarily C++ - C, Objective C, or something more fringe like D would be fine. But even working at higher levels of abstraction in C#, it's hard to be a great programmer without understanding pointers and memory management, without being able to read assembly and memory dumps, without being able to understand or even really implement low-level optimizations.

I should also add - if you're not in the industry now, planning 20 years out is silly. Maybe you'll find out you hate it; maybe you'll find out you don't want to be a director because of all the non-development crap involved, and you'd rather just stay a senior designer or programmer, working under a director but with lots of freedom in a specific domain you enjoy.

# Answer
> 2 votes
You will probably be fine using the languages you know; C# with XNA is popular right now since you can develop to XBOX360, Zune, and PC. Java's popularity is coming back because of Minecraft's indie success with it.

I was in a similar position as you though, and decided to "start over" so to speak with C++, and 2 weeks ago I purchased "Beginning C++ through Game Programming." It is NOT a game programming book, but a C++ beginner book that covers everything you will need to know in C++ when programming games with another API or Library, and substitutes boring projects with more game-related ones. It was a great read.

Now I am moving on to DirectX and purchased a book titled "Programming an RTS Game in DirectX" by Carl Granberg. It has fantastic reviews. I'm still not sure if I made a bad decision with DirectX over OpenGL, but we'll see.

# Answer
> 2 votes
Learning more languages will only be to your advantage. Even if nearly all pro engines use--or should use--scripting and/or extensive tools for designer ease-of-use, you're correct in that it helps greatly to have a project that you have specifically worked on. Even if your interviewer doesn't pay attention to your projects (which is already unlikely,) working on even one personal project will be a huge learning experience.

For designers and artists, the portfolio is arguably even more important, since you can't take programming tests or have straightforward tech interviews. So, I'm not saying that you should freak out and learn everything there is to know about C++.

Rather, you should be able to show a few games that have good design potential (think small, clear game concepts like Limbo or Portal,) whether you developed them yourself or you made them using Flash. Use coding as a tool, not as your primary weapon. Make sure they're easily accessible on your site with gameplay videos, screenshots, and available downloads.

Above all else, polish everything you make, no matter how small or what kind of project you have. If programming is about robustness and usability, then designing is about fun (people often forget this) and showing that you can really nail the details.

# Answer
> 0 votes
C++ is the originator and the creator of some of the most widely used languages which includes Java. By learning C++ (whether for game dev or otherwise), you'll be able to learn almost any language with speed and ease. That's the magic of this language. C++ gives you more control of the code as compared to Java. So if you want to really be a true master of your code, then you'd be in a much better position learning C++

---
Tags: xna, c++, c#, java, wpf
---


# Question
Title: Has anyone used PhoneGap to make 2D games for the iPhone?
I love simple casual games. I've been riding the bus a lot recently and so simple, no-brainer games are great fun and well worth the small price I pay on the App Store.

It got me thinking... I know HTML5, CSS3 and JS very well. I looked into PhoneGap and it looks like it's something I could use for making apps for the iPhone.

The games I've been fleshing out myself are very simple 2D affairs. Fun, simple and high quality. That's what I'm after with my games... I also make music and my friend is an digital illustrator so together we have all the media covered.

Does any one make 2D games for the iPhone using PhoneGap?

I'm presuming that because I want to code in JS and use the HTML5 Canvas tag, that PhoneGap does nothing more than provide me a wrapper with a WebKit view?

I know it won't be as fast as using native... But is using PhoneGap a viable option?

# Answer
If you do not have an Apple Developer account, then there is no way to deploying your app into any iOS device for testing. So you've no other go but to accept using emulators. PhoneGap does pretty well when it comes to emulation as far as I know.
> -1 votes

---
Tags: iphone, javascript, html5, html-canvas
---


title: ActionScript 3.0 and iOS

text:
# Question
Title: ActionScript 3.0 and iOS
In Adobe CS5 you can export games to iOS, but all my research in the past indicated that Apple was not going to support Flash. It's my understanding that Adobe and Apple were working on this at one point and then Apple terminated the project. I was chatting with some other developers about this and one mentioned they were porting an AS3 project to their iPhone. Is there a way to get a Flash App on to the iStore? I don't think so.

# Answer
Apple changed their mind about Flash-derived apps (as seen here). Developers can use Adobe's Packager for iPhone to convert Flash apps to native iPhone apps. The Flash VM is still not supported in the iPhone's browser.
> 2 votes

# Answer
You can't take a flash app and just have it run on an iOS device as-is. CS5 does have an export process to put projects on a device. I'm assuming it's running in a VM or is some kind of cross compiler or something.

Using Flash in CS5 for iOS
> 2 votes

# Answer
Flash CS5 can allows you to export your flash app as a native iPhone app, using the AIR for iOS extension. But in order to create a native iOS app, you need the digital certificate from Apple, which you'll be given only when you register yourself as an Apple developer.
> 0 votes

---
Tags: ios, actionscript
---


# Question
Title: Beginner flash game development: Start with framework or from scratch?
I want to write some simple flash games (as a hobby). I have a lot of programming experience, but no experience with Flash/ActionScript.

My question is: As a beginner, is it a good idea to start with a framework like Flixel, FlashPunk or PushButton or would it be better to write my first games from scratch?

Also, if you vote for using a framework, which one would you recommend? What are the differences?

And another question: What about Flex, would you recommend using it?

# Answer
> 6 votes
I'd say you should start without a framework, just to get used to ActionScript and the core flash classes. Maybe write something very basic like Pong.

When you feel comfortable with ActionScript and the core concepts, feel free to use a framework like Flixel or FlashPunk (look here to get started). They are quite different from the usual Flash philosophy, since they don't use the flash display objects (like Sprite, MovieClip etc.). Instead they implement their own display classes and a bitmap-based rendering engine. This is especially nice/useful if you don't own Flash or don't want to use Flash to create game assets.

IMHO Flex isn't very useful for games. It's more of a Web-Application/GUI framework and would add a lot of bloat to a game. Use one of the more game-oriented frameworks like Flixel or FlashPunk instead.

# Answer
> 2 votes
I'd recommend you to start without any framework like flixel, flashpunk or even Box2d. They do really make life simpler to you by keeping in mind the ancient programmer philosophy *"Don't always reinvent the wheel"* If you start programming games with just flash, these would be your plus points

1. You learn little bit about the essential computer graphics necessary algorithms, ideas and programming logic.
    1. You make a lot of mistakes and *learn a lot more* when correcting them.
    2. You do think of "making" the game logic, rather than allowing the framework to do it for you.

If you start with a framework, these are the plus points

1. They provide you with a plethora of built in functions which help a lot in the game logic.
2. They make life simpler.
3. You would get more time to invest in building your core game logic.

But, If you start programming games in flash with a framework, these are minus points

1. You wouldn't need/try to understand the algorithm behind the game logic implementation.
2. You may/would find it difficult when changing to another language for a similiar game programming need if that particular language doesn't have similiar library features as the one you use.

To sum it all up, If I were a teacher I'd ask my students to start learning Game Programming without a framework.Using an SDK is recommended though.Flex SDK is useful if you were thinking of programming in FlashDevelop IDE or other Flash IDEs.

Best Wishes.

# Answer
> 2 votes
Use a framework; I recommend Flixel because it's the one I'm familiar with. There's no real value in reinventing the wheel, and Flixel makes development much faster and easier, which means that you'll see results faster and you'll get experience more quickly.

Frameworks help to structure your game, so you'll make fewer rookie mistakes with regard to organization and architecture. Frameworks also tend to collect tutorials and example code. If you need something a framework can't provide, you can always learn the lower-level Flash techniques... but honestly, the difference between framework and non-framework is very small. It's not like comparing machine code and managed code.

Regarding Flex: use the free Flex compiler, but compile a simple AS3/Flash project. I wouldn't use Flex unless you wanted to use the Flex layout approach, and it's not especially compatible with more frameworks.

# Answer
> 0 votes
I'm not a Flash/ActionScript developer, but as this is a hobby, what is do you want to work on most?

If you first and foremost want to makes games, then by all means use a framework to do all the other stuff you don't care about too much at the moment. You'll get yourself up and running much faster and you'll have something on the screen quickly. You can worry about how all the other stuff happens another day when that becomes interesting.

If you care more about how the whole thing works, plus love getting your hands dirty with all the behind the scenes stuff, then start from scratch and learn about it all as you go.

# Answer
> 0 votes
Since you have a lot of programming experiences i could recommend you using one of the frameworks that are avaible, i have some tutorials and a template for flixel in my blog, maybe you should take a look at them.

However i think the most important thing in games aren't the tools, is the game design.

# Answer
> 0 votes
If you are into game programming in Flash, then a framework would give you more power over functionalities. But these frameworks are not easy to work with, and you'll have to play around with them for quite some time before you can finally use them. So I'd recommend to first understand the basics of Flash and ActionScript and how they work before you think about using a framework.

---
Tags: flash, actionscript
---


title: How to start publishing Flash games

text:
# Question
Title: How to start publishing Flash games
I'm already pretty adept at AS3 and all, and I have plenty of ideas for Flash games that I want to start making. However, I was wondering, when I've made my first one, how should I publish it, and how can I make it popular? I will upload it on my own website, but should I upload it to a more well-known site? And if so, which do you recommended? (Armor Games, Kongregate, etc.)

# Answer
Try to push to as many websites as possible. http://www.mochimedia.com/ is a great resources for learning about developing, publishing, and monetizing flash games.

If you are interested in getting a sponsor and making some money I definitely recommend you check out http://www.flashgamelicense.com/ . I used them in the pass and got a sponsor to pay me $4,000.00 for my flash game. Back when I used them they recommended that you give 10% to Flash Game License if they helped you with getting a sponsor (yes it's a recommendation, I ended up giving them 10%).

Good luck!
> 5 votes

# Answer
First think of a great idea that you think would really get ppl glued to your game. Then think of how good of an artwork you could implement in your game to make it more cooler and attractive. Finally when you're done with the game, look for sites that allow you to post your game and then just publish it. If your game is good enough, you'll attract sponsors.
> -1 votes

---
Tags: flash, actionscript-3, publishing
---


# Question
Title: What 2D engine can I use to port my flash game to iOS and Android?
I would like to port my 2D flash game to Android and iOS. Is there any cross platform engine you could recommend? Corona is the only promising one I have found so far.

# Answer
I would try http://gamesalad.com/. While Android publishing is not yet supported (planned for fall according to http://gamesalad.com/corporate/roadmap/) it can publish in HTML5, which should work well in many places, possibly android browsers too. YMMV.
> 2 votes

# Answer
Have you tried to use CS5.5 or Flash Builder 4.5 to take your existing game to mobile?

http://blogs.adobe.com/flashplatform/2011/06/build-mobile-apps-for-android-devices-blackberry-playbook-iphone-and-ipad-today.html

AIR 3.0, currently in beta, will also bring captive runtime (already available for iOS), where you can bundle the runtime with your app. The Flash Player 11 and AIR 3 betas are on Adobe Labs labs.adobe.com. If it doesn't work out for you, let us know why!

Emmy Huang, Group Product Manager, Adobe Gaming Solutions
> 2 votes

# Answer
Native code + cross platform solution.

Set up a Cmake build environment, cmake looks for installed compilers and builds make files for each platform... i.e.

You have a src folder with a cmake file, it tells cmake what's in it and how it links to other projects.

you have visual C++ 10 installed, cmake finds it via path variables, and uses it to build the visual studio 10 solution files from all of your source.

you rinse and repeat on each platform, windows is your win/android dev environment, a cheap mac mini to do your iphone/mac compiles, and a linux box if you so desire.

Android native requires cygwin and gcc.

From there you pick a well supported core library, I recommend STL or Boost which both have active port and optimization projects for them online.

You hide your core away via cmake so each build pulls the library optimized for your platform.

Additional libraries that are nice to have include a 2d rendering engine Skia or Cairo should do it, skia is more performant but has less documentation, don't let the Cairo openGL Backend fool you either, I hear there are issues with it.

You will need a sound library or something of the like, as well as a nice openGL library, since most of what I have done is mostly 2d graphics in the cross platform realm I can't help you on libraries for that.

Learning CMake for native cross platform is going to be hard work and you'll want to learn shell programming and windows batch or even better vbscript to automate some file creations and stuff when you want to add a new library to your application level code.

once you get your first file including skia/cairo with boost/stl and get a successful cross platform compile you will love yourself!!!!

I can tell you the build chains for everything though:

CMake

Windows Machine: Visual Studio C++ 2010 (primary app development, do it here the debugging tools are amazing) Android NDK Android SDK Cygwin (With GCC build tools and libs)

Mac Machine: CMake XCode Iphone development Libraries

I would recommend source control as well: Subversion or GIT = awesome.
> 2 votes

# Answer
You can download AIR for android and iOS extension for Flash cs5 which enables you to port your flash apps to Android and iOS. I've tried porting into my android device and it works. For porting to iOS, you nedd a digital certificate from Apple, which will be provided to you only if you're registered as an Apple Developer. The two extensions are inbuilt in Flash CS 5.5.

You can get the android extension for Flash CS5 here http://hobbymerge.wordpress.com/2011/08/19/air-for-android-extension-for-flash-cs5-to-develop-apps-for-android-devices/
> 0 votes

---
Tags: 2d, android, iphone, flash, ios
---


# Question
Title: Is it essential that I learn Try/Catch and Finally statements for Game Programming, or is it something I can come back to?
Doesn't seem like something that would be an essential part of GAME Programming.

# Answer
They are 100% essential. Do you want your game to crash any time an error happens? Granted, some errors will always cause a crash, but what about something as simple as network timeout? Wouldn't it be smarter to tell the player and have him try again, or check his network connection?

Picking them up is very easy.

```
try
{
    //open a network connection and try to get the leaderboard
}
catch(Exception ex)  //type of exception, and a variable to access it by
{
    //tell the user something happend, and have them try again.
    //maybe you jut want to log it.

    LogError(ex);
    //so we have a record it happend, but the error was really bad! (out of memory) just throw it again if you need to
    throw;
}
finally
{
    //this happens no matter what. it will run on success and failure
}

```
> 24 votes

# Answer
While I agree with Joe's answer that exception handling is a useful skill to learn, it's my experience that they are rarely used in game development.

I'm not too sure on the differences in implementation, but in C++ the overhead involved with keeping stack traces to allow for effective unwinding whenever a 'throw' is encountered is pretty much the sole reason they're frowned upon.

This answer may provide you with more insight on the overheads involved with C# exception handling.

In terms of general program architecture, exceptions are not useful for determining the exact reasons for a crash, and make it troublesome to determine exactly where an error is occuring. You'll unwind to the point of the catch, but have little to no information (depending on usefulness of your exception) of where the error actually originated.
> 8 votes

# Answer
I would agree that it is something that you can come back to.

It is perhaps not essential to "game programming" in the ways that it can be to maintenance/support programming. In other words, if you can think of "game programming" as the discipline of crafting and delivering the game, then exception handling's benefits come to light **after** shipping out-the-door.

That said, there are things that can play a role in how soon:

* Your logging. So there will be a point when you start formulating a error management strategy. How early you form your strategy is directly related to the amount of support you incur from bug reports and captured log entries like "null reference". Often times, without the context that you can capture from the exception, you have to do more detective work and it is more difficult to group errors together, to see the similarities.
* Your patch system. If you can push out updates, then you have a lot of freedom to wait on doing exception handling. Same with if your logic is a web app and clients are just browsers.
* Your team size. If you are a one man team, then you have tremendous freedom to wait. You know your code. You may even know before hand that the exception was on your todo list. If you work and share code with other developers, you may be assigned a ticket to trace someone else's code so you may not immediately see where the exception is tripped.
* Concurrency. To me, this one is hard to plan for so it may not be worth the effort. Also, I feel this is part of robustness or resiliency. So if the requirements allow sudden crashes, then you have great freedom and so you'll wait to address exceptions. One thing you may find with threads is that it is easy to get non-deterministic behavior. When this happens, you want ways to capture as much information about the state leading up to the failure. This can include simulation in a lab of machines, regression tests, logs, (live) data. Individually each of these pieces can offset the the others to some degree. For example, if you have infinite tests you should be able to expose every logic failure and therefore not need exception handling (or logging or anything else).
> 2 votes

# Answer
Exception handling is a cleaner way to handle unexpected errors from any point in the game. But the beauty of it is, in your codebase, it won't matter how deep you are in the code to handle it. Without exceptions, some kind of error handling routine would be returning a bool or int for some kind of status, then unwinding the nested subroutines till you got to a top-level area (your game class) and exit from there. It will get very cumbersome to write your code to error check from any possible point, wheras using exceptions requires little to no refactoring.

Since your question is XNA specific, it will probably be of good use to know how to handle exceptions in an Xbox game, because when a game in there doesn't catch one, you are not left with a clue as to why it happened. This article shows you a clever way to work around that by running your entire game in a try/catch block. It will launch a new "ExceptionGame" if something happens to go wrong, passing the details of the error to display in the ExceptionGame.
> 2 votes

# Answer
I don't know anything about C#, but here are my three cents:

1. The try/catch/finally exception handling paradigm is widespread, and for good reason: it provides an excellent framework for dealing with exceptions in your code.
2. If you're using a certain language, you should learn all its statements and how to use them or your code will be some combination of confusing, buggy, and inefficient. A lot of thought goes into the design of programming languages, and trying to write a program without using all the tools available to you is just... *silly.*
3. Not to be disparaging, but there are many challenging aspects of game development and trying to do it with the attitude of "I'm only going to learn what I *absolutely need* to get by" is not going to end well. You'd be better served using the journey to your goal of developing a game as an opportunity to learn as much as you possibly can.
> 2 votes

# Answer
No, exceptions aren't vital or essential in any way. For the most part traditional game programs are very heavy on error checks and knowing exactly what's going on with the data and parameters.

The exception to that is when accessing system calls, those will be throwing exceptions and how to catch them is very well documented and you can use the try/catch like a black box until you start to use exceptions more deeply on your own.

The whole try/catch thing **is** however very easy to pick up and once you get familiar with C# you will be able to see where exceptions make sense and you can start to add them into your own code naturally.

Assuming, of course, that you're just starting out. If you're learning C# after other languages then you should pick up exceptions and not wait until later.
> 1 votes

# Answer
I believe it depends on the nature of your game code. Are there areas in your flow of execution where things may fail? Is your code 100% handled? If the code has no way of failing, if you are aware of the post condition and certain of it, then exception handling is of little use, and would simply increase the use of resources to check for no reason. However, the majority of code does have situations where things may fail. Especially in game development, if a game is predictable, it would most likely lack the essence of being a game. Regardless of its use in game development, you MUST be aware of it and how to use it. But apply it where needed.
> 1 votes

# Answer
Do you want to know what went wrong in ur program without inserting breakpoints or looking at your entire code. If yes, then try-catch statements help you to do just that. It tells you what went wrong using preset types of errors. So by actually learning these statements and knowing what error stands for what, you can effectively debug your code without any hassle.
> 1 votes

# Answer
Well,

Normally Object-Oriented software trend to use Exceptions for reporting errors in the running proccess. If something happens that the current method can't deal/resolve, it should throw an exception and let someone in the higher to treat this problem. If you do this way, your main processing methods (the more specific ones) will be much cleaner without the need to treat errors that it can't solve.

But normally, in game development Exceptions are not thrown because you are designing the hole enviorment. If you are designing your Engine, then yes, you'll use exceptions to basically I/O features, but in the scene, for example, it's not likely that you'll use it. I find out that it's better to try to add to a list of things that must be solve instead of throwing an error. For example, you have a client/server game. In the client, you noticed something that gone wrong. I find that it's better (for me) to add this error to a list of errors that must be solve, instead of breaking the sequence. That way, you could just jump this error and don't throw an exception, but someone will try to fix this problem.

But in any OO software you'll work with, remember that exceptions are always used. It's a really good thing to learn, very usefull and not hard at all.
> 0 votes

---
Tags: c#, software-engineering, xna-4.0
---


title: Allegro 5 Mouse Look

text:
# Question
Title: Allegro 5 Mouse Look
I found good tutorial on how to do mouse look for 2D game here: http://www.atburrow.com/2010/03/08/objects-facing-the-cursor/

My code looks like this:

```
w = (double)mouse_x - (double)pos_x;
h = (double)mouse_y - (double)pos_y;
d = sqrt(w * w + h * h);
theta = asin(w / d) * 2 * ALLEGRO_PI;

```

Problem is i cant figure out how to translate it for Allegro 5. Tried this on many different ways and its working, but not correctly. First im not using OpenGL (its a simple project for 2D controlls) so what i did after this is:

```
al_draw_rotated_bitmap(playerLook, imWidth / 2, imHeight / 2, pos_x, pos_y, theta, 0);

```

Object is rotating a bit faster than it should be. So this is blocking me from further exploration. I also found good tutorial for blitz from guy that im subscribed: http://www.youtube.com/watch?v=zFAaILFJtCY

Just went out, but still there is something that confuse me when using Allegro fixed math and i cant learn it without good example.Do anyone know how to set this code right in allegro5 ? How to do 360 degree rotation using mouse in allegro5?

# Answer
> 5 votes
"He who would learn to fly one day must first learn to stand and walk and run and climb and dance; one cannot fly into flying..."

You appear to want to draw a sprite that is always facing the mouse, correct? Then your first task must be to draw a sprite that is always facing *something*. Pick an arbitrary point and then do the math to draw the sprite so that it faces it. Then pick another point; the math should still work.

For only once you have mastered the sprite, can you slave it to the mouse.

The `al_draw_rotated_bitmap` function takes an angle to rotate the bitmap by. The documentation sadly isn't specific about what direction it rotates in. It also doesn't say whether the angle is in degrees or radians.

You should be able to find out both of these via experimentation. You shouldn't have to, but there's not much you can do about it. Just draw a sprite, then draw the same sprite next to it with a 45.0 rotation. If that causes the sprite to rotate right by 45 degrees, then you know it's a clockwise rotation and its in degrees. If it goes left by 45, then it's counter-clockwise and in degrees. If it's something else, then you know it's in radians, and you should try again with 0.785.

Once you know how the function works, it's a simple matter to use it. Given the location of the sprite `S` and the location of the point of interest `P`, you can compute the vector direction from the sprite to that point (`P` \- `S`).

Then, you want to compute the angle you need to rotate from whatever your zero facing is to face that point. Let's assume that a zero angle represents facing right (a direction of (1, 0)). This means your sprite, when not rotated, faces right. I make this assumption because it allows me to do this:

```
double angRadians = atan2(P.y - S.y, P.x - S.x);

```

If `al_draw_rotated_bitmap` takes radians, you can feed that directly to it. If it takes degrees, you'll have to convert it to degrees by multiplying by the radians by 180/Pi.

---
Tags: mathematics, rotation, mouse, allegro
---