text:
Should I formally study to make games?
I don't have formal studies in programming nor in graphic design, I'm self-taught, you know I have learned some things here and there. So far have been doing amateur stuff, sort of hobbyist. I would like at some point of my life be doing professional games, don't know if that would mean acquiring formal knowledge at some gaming college. It is something even desirable or advisable?

From a programmer's perspective: http://gamedev.stackexchange.com/questions/1611/game-development-degree-vs-computer-science-degree

From an artist's: http://gamedev.stackexchange.com/questions/4438/should-i-go-to-a-university-or-trade-school-to-be-a-game-artist

If you think you'd enjoy making games then go for it!
It's always best to do what makes you happy.
But really, there are two routes you could take. You could take a generalised course that included computer programming for example a computer science course. Then maybe learn game programming afterwards. That way, if the game programming career falls through, you have other options.
If you look at the money some of the recent games made especially with the financial recession, then I suppose it would be an advisable career. Notch's minecraft game is a good example. He did that near enough on his own and he now has nearly 1 million paying customers. It pays off if you hit a niche. It all comes down to luck like a lot of things in life.
So definitely just go with it if you think you'll enjoy it.

When thinking about C/C++ (because these are the industrial standard languages), I learned most of C by myself, but I admit that school helped a lot for C++: C++ is really a fat subject when used for game programming, but that doesn't necessarily mean I couldn't learn things by myself; school is a very efficient shortcut, but like every shortcut, it's harder and can cost money, and even worst, sometimes you might feel you are learning nothing.
Don't forget there are 2 sides for being a game developer; first you have to be able to use C++ fluently, and not just classes and virtual function: also the basic STL containers. Secondly, since game programming is all about code and nothing else, you have to learn about design patterns, but often that might not be enough.
I'm sure you could do some Ogre programming for example if you have some project in mind and time to spare. Don't forget that it's much much better to learn something new to solve a problem when you explicitly know what it's for: learning the theory while practicing is more logical because you have a concrete example which makes it better to remind you what it's for. It's more reassuring than school.
On the other hand, you have to have a pretty good amount of free time and self-confidence, because at school you have help not only from teachers but also from students, but don't forget that there's also pretty good help on forums and IRC channels.
To answer your question, I'd say it mainly depends on what you need to learn, since the basics are quite important, but it also depends on your curiosity and how autonomous you can be.
I have taken the opportunity to get into a private school because I had funds at the moment, I don't know if I would have risked to make a loan for that. On the other hand I met people, which is an important thing, but that won't change the way I conceive programming and how I like to learn things: most of what I see are people unable to seek the information for themselves and are too much used to being teach planned things rather than asking questions or asking themselves questions, after to watch them complain about the program.
I guess the answer would have been very much different would you have asked it 10 or 15 years ago, but nowadays multi-core processors and giga-powerful consoles require a game programmer to be able to get hold of bigger data structures and algorithms and design patterns etc etc.
Of course I'm not talking about hobbyist/low-project game programming, which can be done with unity for example, but more about professional/know-how-it-s-done/from-scratch game programming, which gives you a lot more.

Straight answer: it is very advisable. I'll explain you what I've learned, and hope it helps.
Formal studies always help when you want to take things to the professional level. However, the entertainment industry is very big and there is an advantage/disadvantage when it comes to media: everything comes down to portfolio and imagination.
Let's say you want to work on EA. Big thing, huh? They ask for formal studies; sure, but then they see your portfolio (and you need a strong one, not necessarily a big one). So... it helps, but imagination and portfolio helps better.
Now, let's say you want to go indie. Good thing. People don't ask for code standards, design documents or formal education; they want games. Good, funny, maybe free ones.
If you have the time, and the budget, to afford formal education; go for it. Why? You'll be on the shoulder of giants and you'll have subjects to focus your attention on; so learning will be kind of faster. But always remember that all of the theoretical material is worthless unless you make games, show it to people and get feedback from them to get the hang of it.
Finally, keep self-teaching yourself. That's key on being successful. Users/clients/bosses don't care too much if you were taught about a subject, but rather whether you actually know about it.
PS: As David pointed out, it's recommended to go for a specialized curriculum. Computer Science or Arts and getting a game development major. But that's up to you to decide and there are pros and cons that don't belong to this subject.


text:
What are the restrictions of 3g online games
I am looking into make a 3g online multiplayer game for the iphone. Multiplayer is my main focus but I have noticed all game apps require wi-fi. Dose anyone know if this is simply an issue with the speed of the 3g network or dose apple put restrictions on their 3g network that prevents developers from doing this?

So is it 'what restrictions are there' or 'why are there restrictions' you are asking?

What are the restrictions, speed wise and the technicalities that Apple imposes

I don't know of any specific limitations Apple imposes regarding 3G.  The communication medium would still be TCP/UDP or HTTP POST/GET.
In terms of network limitations, cell networks like your 3G service certainly have a unique set of characteristics.  3G networks are notorious for having horrible latency, it isn't uncommon to see round-trip times of up to 700 ms.  In terms of bandwidth, 3G isn't that bad once the data starts flowing.
If you are looking at a multi-player action game where every second counts, having spikes of 0.7 seconds would be pretty bad.  This is one reason why you would use Wifi.  However if it's a Mafia Wars type game, you would be ok.
I may be remembering this incorrectly but I seem to remember there being an issue establishing a client/client session between two 3G users - like there was a firewall that prevented any incoming ports over 3G.  For this reason you would either need a centralized server to match clients or use Wifi.

Phones using 3G networks typically (not always, but mostly) operate behind very restrictive NATs. UDP packets from the same source socket to two different destinations will typically appear from the device using two different IP addresses. This makes it very difficult to create peer to peer connections.
Network conditions such as latency and packet loss are more common than home ADSL or cable connections. However if the user has a very good signal then bandwidth can be higher than ADSL or cable.
You can usually use TCP and UDP. However if you're using UDP then I would recommend using a library that can cope with poor UDP performance. I've used ReplicaNet with great success on networks with poor network performance. The reliable UDP connections it uses seems to be very stable and recovers from packet loss well.

Really good points, but it's worth noting that even when the user has a very good signal, whilst bandwidth can be higher than ADSL or cable, the latency/ping is usually significantly worse, especially when establishing new connections.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/2.5/

sort: votes


text:
Bitmap font rendering, UV generation and vertex placement
I am generating a bitmap, however, I am not sure on how to render the UV's and placement. I had a thread like this once before, but it was too loosely worded as to what I was looking to do.
What I am doing right now is creating a large 1024x1024 image with characters evenly placed every 64 pixels. Here is an example of what I mean. I then save the bitmap X/Y information to a file (which is all multiples of 64).
However, I am not sure how to properly use this information and bitmap to render. This falls into two different categories, UV generation and kerning. Now I believe I know how to do both of these, however, when I attempt to couple them together I will get horrendous results.
Now for the algorithm. I am doing my letter placement with both GetABCWidth and GetKerningPairs. I am using GetABCWidth for the width of the characters, then I am getting the kerning information for adjust the characters.
Does anyone have any suggestions on how I can implement my own bitmap font renderer? I am trying to do this without using external libraries such as angel bitmap tool or freetype. I also want to stick to the way the bitmap font sheet is generated so I can do extra effects in the future.
Rendering Algorithm
for(U32 c = 0, vertexID = 0, i = 0; c < numberOfCharacters; ++c, vertexID += 4, i += 6)
{

    ObtainCharInformation(fontName, m_Text[c]);

    letterWidth = (charInfo.A + charInfo.B + charInfo.C) * scale;

    if(c != 0)
    {

        DWORD BytesReq = GetGlyphOutlineW(dc, m_Text[c], GGO_GRAY8_BITMAP, &gm, 0, 0, &mat);
        U8 * glyphImg= new U8[BytesReq];
        DWORD r = GetGlyphOutlineW(dc, m_Text[c], GGO_GRAY8_BITMAP, &gm, BytesReq, glyphImg, &mat);

        for (int k=0; k<nKerningPairs; k++)
        {
            if ((kerningpairs[k].wFirst == previousCharIndex) && (kerningpairs[k].wSecond == m_Text[c])) {
                letterBottomLeftX += (kerningpairs[k].iKernAmount * scale);
                break;
            }
        }

        letterBottomLeftX -= (gm.gmCellIncX * scale);
    }

    SetVertex(letterBottomLeftX, 0.0f, zFight, vertexID);
    SetVertex(letterBottomLeftX, letterHeight, zFight, vertexID + 1);
    SetVertex(letterBottomLeftX + letterWidth, letterHeight, zFight, vertexID + 2);
    SetVertex(letterBottomLeftX + letterWidth, 0.0f, zFight, vertexID + 3);
    zFight -= 0.001f;

    float BottomLeftX = (F32)(charInfo.bitmapXOrigin) / (float)m_BitmapWidth;
    float BottomLeftY = (F32)(charInfo.bitmapYOrigin + charInfo.charBitmapHeight) / (float)m_BitmapWidth;

    float TopLeftX = BottomLeftX;
    float TopLeftY = (F32)(charInfo.bitmapYOrigin) / (float)m_BitmapWidth;

    float TopRightX = (F32)(charInfo.bitmapXOrigin + charInfo.B - charInfo.C) / (float)m_BitmapWidth;
    float TopRightY = TopLeftY;

    float BottomRightX = TopRightX;
    float BottomRightY = BottomLeftY;

    SetTextureCoordinate(TopLeftX, TopLeftY, vertexID + 1);
    SetTextureCoordinate(BottomLeftX, BottomLeftY, vertexID + 0);
    SetTextureCoordinate(BottomRightX, BottomRightY, vertexID + 3);
    SetTextureCoordinate(TopRightX, TopRightY, vertexID + 2);

    /// index setting

    letterBottomLeftX += letterWidth;

    previousCharIndex = m_Text[c];

}

It looks like you get either wrong character widths or kerning values. Did you try disabling the kerning altogether to check if you get correct character widths this way?

Yes I did, I am not getting the correct character widths. how can i properly obtain those?

Sorry, my comment was probably ambiguous. What I meant is: If you disable the kerning (eg. the whole if(c != 0) block). Do you still get these overlapping characters?

This is very difficult to answer without knowing what ObtainCharInformation and SetVertex do, and what's in gm.

Also, please don't ask the same question on Stack Overflow and here (http://stackoverflow.com/questions/4601217/bitmap-font-rendering-uv-generation-and-vertex-placement).

Why can't I ask on both forums? ObtainCharInformation gets abc widths, SetVertex sets the verticies and GM is the kerning information from GetKerningPairs

Justification for vote-to-close as too localized: The author hasn't been here since a week after the question, it's "fix my code" in a very specific case, not enough information is provided, and tools to solve the general problem are widely available and referenced in other answers.

Gah. This keeps getting bumped by the bot. Can't we just close it?

Like bluescrn and Jari have suggested, I'd say go with bmfont if you can.
But if you want an example that just draws text, here's a snippet I was toying with some months back.  Part are surely borrowed from somewhere (the PNG codec writer), but I have no idea where.
Good luck!
#include <Windows.h>
#include <Wingdi.h>
#include <gdiplus.h>
#include <Gdiplusgraphics.h>
using namespace Gdiplus;

extern int MyGenTexture[512*512];
int MyGenTexture[512*512];

int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
   UINT  num = 0;          // number of image encoders
   UINT  size = 0;         // size of the image encoder array in bytes

   ImageCodecInfo* pImageCodecInfo = NULL;

   GetImageEncodersSize(&num, &size);
   if(size == 0)
      return -1;  // Failure

   pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
   if(pImageCodecInfo == NULL)
      return -1;  // Failure

   GetImageEncoders(num, size, pImageCodecInfo);

   for(UINT j = 0; j < num; ++j)
   {
      if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
      {
         *pClsid = pImageCodecInfo[j].Clsid;
         free(pImageCodecInfo);
         return j;  // Success
      }
   }

   free(pImageCodecInfo);
   return -1;  // Failure
}

extern void MakeTexture();
void MakeTexture() {
    HDC myDC = CreateCompatibleDC(NULL);
    //HBITMAP GenTexture = CreateCompatibleBitmap( Context, 512, 512 );

    BITMAPINFOHEADER myInfoHeader = {
        sizeof(BITMAPINFOHEADER),
        512,
        -512, // Negative, to make it top down //
        1,
        32,
        BI_RGB,
        0, // Size of compressed data //
        4096, // Pixels per meter //
        4096,
        0,
        0
        };

/*  HBITMAP myTexture = CreateDIBitmap(
        myDC,
        &myInfoHeader,
        NULL,
        NULL,
        NULL,
        DIB_RGB_COLORS
        );
*/

    BITMAPINFO myInfo = {
        myInfoHeader,
        0
        };

    int* Data;

    HBITMAP myTexture = CreateDIBSection(
        myDC,
        &myInfo,
        DIB_RGB_COLORS,
        (void**)&Data,
        NULL,
        NULL
        );

    SelectObject( myDC, myTexture );

    GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR           gdiplusToken;
    // Initialize GDI+.
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    {
        Graphics g( myDC, myTexture );
        SolidBrush brush( Color(255,255,255,255) );
        FontFamily fontFamily( L"Times New Roman" );
        Font font( &fontFamily, 48, FontStyleRegular, UnitPixel );

        for( int idx = 0; idx < 512*512; idx++ ) {
            Data[idx] = 0x00FFFFFF;
        }

        //g.Clear( Color(0,255,255,255) );
        g.DrawString(L"Using \"Technology\", i.e.",-1,&font,PointF(0,20),&brush);
        g.DrawString(L"GDI+, I have created a",-1,&font,PointF(0,70),&brush);
        g.DrawString(L"texture from system",-1,&font,PointF(0,120),&brush);
        g.DrawString(L"installed fonts! That",-1,&font,PointF(0,170),&brush);
        g.DrawString(L"means international",-1,&font,PointF(0,220),&brush);
        g.DrawString(L"characters!",-1,&font,PointF(0,270),&brush);
        g.DrawString(L"",-1,&font,PointF(0,320),&brush);
        g.DrawString(L"      スマイルズ ",-1,&font,PointF(0,370),&brush);
        g.Flush();

        for( int idx = 0; idx < 512*512; idx++ ) {
            MyGenTexture[idx] = Data[idx];
        }

        // Write File //
        Bitmap OutBitmap(myTexture,NULL);

        CLSID encoderClsid;
        GetEncoderClsid(L"image/png", &encoderClsid);
        Status stat = OutBitmap.Save(L"Awesome.png", &encoderClsid, NULL);
    }

    GdiplusShutdown(gdiplusToken);

    DeleteObject( myTexture );
    //DeleteObject(GenTexture);
    DeleteDC(myDC);
}

You could always give this a try: http://www.angelcode.com/products/bmfont/
It generates nicely-packed textures of bitmap characters, and an .xml file of all the UV/spacing data. Results are generally very good.

He explicitly says "I am trying to do this without using external libraries such as angel bitmap tool or freetype.", but yes, I would also recommend using the angelcode bitmap font tool. =)

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/2.5/


text:
How can I move an object around the screen in cocos2d?
I am trying to move the object around the screen using cocos2d. I have this code:
-(void) move
{
  CGFloat upperLimit = mWinSize.height - (mGunda.contentSize.height / 2.0);
  CGFloat upperLimit1 = mWinSize.height;
  CGFloat lowerLimit = (mGunda.contentSize.height / 2.0);
  CGFloat RightLimit = mWinSize.width - (mGunda.contentSize.width/2.0);
  CGFloat Right = (mGunda.contentSize.width/2.0);

  if(mImageGoingUpward ) {
    mGunda.position = ccp( mGunda.position.x, mGunda.position.y + 5);

    if(mGunda.position.y >= upperLimit) {
      mImageGoingUpward = NO;
      mHori = NO;
    }
  } else {
    mGunda.position = ccp( mGunda.position.x, mGunda.position.y - 5);
    if(mGunda.position.y <= lowerLimit) {
      mGunda.position = ccp(mGunda.position.x +5, lowerLimit);
    }

    if(mGunda.position.x >= RightLimit) {
      mGunda.position = ccp(mGunda.position.x, mGunda.position.y+10);
      mHori = YES;
    }

    if(mHori) {
      if(mGunda.position.y >= upperLimit) {
        mGunda.position = ccp(mGunda.position.x - 5,mGunda.position.y);
      }
    }
  }
}

It is supposed to move the object around the screen. The code mostly works, but it doesn't move the object from the top-right of the screen to the left of the screen.

you will propably have to explain what the ccp function does. And it would be nice if you format your code in some better way

ccp is just a wrap for CGPointMake

It's probably important to note that this code is using cocos2d.  Also, could someone with edit powers please clean up the sample code?  It's very hard to read!

it's basically because when you mark mHury as true, this statement if(mGunda.position.y >= upperLimit) is still not true.

Check through your logic - it is broken. To sum it up in English, assuming I got it right (your code is horribly indented and not C++ :P)
if going upwards then adjust position upwards and if we exceed some limit in y stop further upwards movement.
else:
  lower the image (wtf???)
  if y is below some lower limit move it to the right (wtf???)
  if x is above some upper limit then move it upwards at double speed (again, wtf???) and set a flag to say we are moving horizontally
  if the horizontal flag is set and we have y exceeding some upper limit then move it to the left. (again, wtf???)
Maybe I am missing something, but this makes no sense to me. What are you actually trying to achieve and how is the requirement to move input to this code (e.g. who sets mImageGoingUpward - can mHori be set from outside, etc.)? It is not very obvious, which precludes a detailed and complete answer to the question.

It's Objective-C code, not C++.

Also this doesn't really answer the question.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Random generation of interesting puzzle levels?
I'm making a Sokoban-like game i.e. there's a grid that has some crates on it you can push and you have to get the crates on crosses to win the level (although I'm going to add some extra elements to it). Are there any general algorithms or reading material I can look at for  how I could go about generating interesting (as in, not trivial to solve) levels for this style of game? I'm aware that random level generators exist for Sokoban but I'm having trouble finding the algorithm descriptions.
I'm interested in making a game where the machine can generate lots of levels for me, sorted by difficulty. I'm even willing to constrain the rules of the game to make the level generation easier (e.g. I'll probably limit the grid size to about 7x7). I suspect there are some general ways to do level generation here as I've seen e.g. Traffic Jam-like games (where you have to move blocks around the free some block) with 1000s of levels where each one has a unique solution.
One idea I had was to generate a random map in its final state (i.e. where all crates are on top of their crosses) and then the computer would pull (instead of push) these crates around to create a level. The nice property here is that we know the level is solvable. However, I'd need some heuristics to ensure the level was interesting.

That idea you have for generating levels is very interesting. Honestly I'd just go ahead and try that, rather than waiting for discussion about it. I'm guessing you could tune the difficulty of the generated levels by setting the number of pulls, and one heuristic you'd probably want is to distribute the pulls over multiple crates, both so that every crate is moved a fair amount, but also so that the player sometimes has to go back and forth between crates (I'm guessing that sort of intertwining logic is more interesting than one-crate-at-a-time).

See the paper: Automatic making of Sokoban problems
From the abstract:

This paper describes our program that makes Sokoban problems automatically. Sokoban is one of one-person puzzles invented in Japan. The program consists of three stages: generation, checking and evaluation. First, candidates for problems are generated randomly by a prototype and three templates . Second, unsolvable candidates are removed by the Sokoban solver. Finally trivial or uninteresting candidates are removed by the evaluator. The problems that the program made are judged good by human experts. Creation of art by computer is an important target of Artificial Intelligence. Our work can be characterized one of the attempts to create some arts by computers.

For solvable puzzles, it's often easy to just play the game in reverse, starting from a solved state and un-making moves either planned or at random (or in an editor.)
Sokoban fits this approach very well, and will be much easier to implement than an exclude-and-solve strategy.


text:
IDE & Debugging of Official SDK for wii and ps3?
I remember hearing that wii and the ds uses CodeWarrior as their IDE. I know xbox uses visual studios but i have no idea what ps3 uses.
What IDE do ps3 developers use and how do they debug? How do wii programmers debug? I always heard they use GDB but is that built into CodeWarrior or is that a separate application?

One can use the Visual Studio IDE for PS3 development -- the PS3 relevant bits are, of course, just command-line tools (GCC ports) that can be plugged in to makefiles that VS can understand, after all.
There's also a toolchain called ProDG, by SN Systems that is used for PS3 development.
GDB, as an aside, is its own, command-line program. Some IDEs (such as Xcode on the Mac) have a GUI that wraps it. So it's not "built in" to CodeWarrior or any other IDE, per se, but ships with some as GUI layers some times communicate with it.

From looking at this it would appear i could use ProDG with any IDE of my choice on the ps3. Would i be able to use GDB?(on ps3). For wii developers they strictly use GDB? i should look more into GDB, it sounds interesting. It sounds like GDB can be used with any language (but i am unsure how it would find source file and line. Maybe any gnu compile embeds that information). I think this answers my question

GDB is just a command line debugger; it alone isn't all you'd need to develop a game -- and while it is powerful, it can be quite tedious to use. You can use GDB for many platform by virtue of the fact that it's been ported to many -- you'd need to use the rest of the ported GNU toolchain to make it effective.

And if this does answer your question, please mark it as such :)


text:
Problems moving a rectangle in Pygame
I'm making a game in Pygame and I want to be able to target enemy unit.
I made it so when I click on them a variable "targeted" becomes true, and stays true until I click somewhere else on the screen. I also want targeted units to have a small green circle around them, so I made it in GEDIT. I have made a function that draws everything on the screen (the background, the player, objects, etc) and in the part where it draws the units it checks if the variable "targeted" is true and if  it is it should move that little green circle over the enemy units.
here is the code that does that:
screen.blit(enemy_unit.pic, enemy_unit.rect) #draw the unit

if enemy_unit.targeted == True: #if the unit has been targeted then draw a circle over it
    target_rect.move_ip(enemy_unit.pos)  #move the circle to the unit
    target_rect.fit(enemy_unit.rect)     #there are some bigger units and some smaller ones, so we have to "scale" the circle
    screen.blit(target_pic, target_rect) #actually draw the circle

This doesn't work, when I target the unit the circle just appears for a 1/5 of second next (not on, but just next) to the unit and then disappears. I am sure that I am keeping a good track of "enemy_unit.pos" because I tested it (I added a piece of code that would print one units position and mouse's position every time i clicked the mouse and when i was near him the numbers were same).
If you could give me a hint about what I'm doing wrong. I think its in move_ip function, but I tried just move and it didn't work either (the circle didn't even show at all)!

This would probably be better suited for gamedev.stackexchange.com

How is enemy_unit.targeted determined?

i just have one question, could you make a seperate picture with the green circle and use that? so, if enemy.targeted == True, use the other picture?

 elif event.type == MOUSEBUTTONDOWN and event.button == 1 and pressed == False:
      pressed = True
      for enemie in lista_neprijatelja:
           if enemie.rect.collidepoint(pygame.mouse.get_pos()):
                enemie.targeted = True
           else:
                enemie.targeted = False

 elif event.type == MOUSEBUTTONUP and event.button == 1 and pressed == True:
      pressed = False

I am sure that this works as it should - I tested it.

in each game iteration you should check - if user clicked on other unit or surface, if yes - change selected unit or remove selection from currently selected
It will look something like this:
somewhere in main loop:
    user_input.get_user_input() # grab user mouse input
    game.screen.event_handling(user_input)  # see below:

game.screen.event_handling function:
def event_handling(self,event_handler_object):
    for unit in self.unit_list:
        unit.update_state(event_handler_object)

In unit.update_state(event_handler_object) function you should check any mouse events like MOUSEMOTION, MOUSEBUTTONDOWN, MOUSEBUTTONUP. Also you should store last mouse event to compare current event, for example - usel clicks some unit, your actions:
1 - wait mouse event
2 - check if there any unit under this coordinates, if yes:
2.1 - set unit status "selected"
2.2 - set last_event = {"event":"click,"pos":pygame.mouse.get_pos()}
3 - get next (current mouse event)
4 - check if event is MOUSEBUTTONDOWN:
IF event is MOUSEBUTTONDOWN then:
4.1 - goto #2
sorry, I'm little drunk in this moment, but logick will be like above.
I you have any questions - tomorrow I will can share my code of the same mynctionality


text:
Collision filtering by object, team
I am looking for a good method to determine which objects will be considered for collision with other objects.
My current idea is that each object has the following properties:
alwaysCollidesWith = [list of objects that will always trigger a collision check]
neverCollidesWith = [lost of objects that will never be considered]
teamCollidesWith = [list of objects that will be checked, provided they belong to a different team]
For example:
-projectiles never have to be checked for collisions with other projectiles
-players are always checked for collisions with players, regardless of team
-projectiles are only considered for collisions if they collide with another teams players
Does anyone see any weaknesses with this approach? Can anyone recommend a better approach?

I think another way of doing it is to just have an identifier for each object saying what collision channel it is in and have another field/property that has a list of identifiers for which this object will collide with. You could use an integer/long with some bit operators to just make this an integer for the identifier and another integer for the "list".

Also, I think it depends on how you want collisions to be resolved. Do you want to do some logic and then resolve the collision? Do you always want collisions resolved first?

@Omnion: how does that differ from my answer? I honestly can't see the difference.

I don't remember there being an answer when I posted. My comments were based of Farseer (which is based of Box2D). I wasn't trying to copy you or anything of the sort.

The problem I see with your approach is that it doesn't scale very well. For every object, you are storing relations with all the objects that collide with it. If you only have 2 players and a 10 proyectiles, it will work ok. But when that number increases to, say, 20 players and 100 proyectiles, then the number of relations increases exponentially. It'll gradually run more slowly and consume more memory when the number of players increases.
You would be better off by organizing your objects into "groups". And then adding collision/non-collision relationships between each object and those groups. The memory consumption will be slower, and the checks will be faster.
Box2D has a fairly flexible system set up for that.
First, there's categories and masks:

Shapes can have up to 16 "categories" (it's really a 16-bit mask). By default, they are on category "1"
Shapes can also have a "mask" that defines with what categories they can collide. By default, they collide with category "1" only.

Then, there's also groups. A group is an integer.

Two shapes with the same group will always collide, if the group is positive.
Two shapes with the same group will never collide, if the group is negative.
Group rules override mask and category rules.

With these two things, the question "do these two objects collide?", filtering is very fast (a bitmask operation and an integer comparison) and has a very small memory footprint (4 bytes per object).
In your example:

Players would have category 1, and mask {1,2} (so they collide with all projectiles by default)
Projectiles would have category 2, and mask {1} (they only collide with players)
Players and projectile of team 1 would all be in group -1, and team 2 would have the group -2. This way, friendly fire would not happen.

The most recent tutorial that I could find is from 2009 - here it is:
http://www.emanueleferonato.com/2009/10/01/introducing-box2d-filtering/
You can also browse the box2d manual - scroll down until it says "Filtering"

Collision channels are probably a better way to go, they save memory, are simpler, and are more scalable.

I'm curious. Care to elaborate?


text:
Changing Palette for Day/Light Mode using GIMP
Suppose I've a picture, which want to achieve day/light mode by changing 8bpp color palette.

If I want the pixel index of my picture is always fixed for both day mode and night mode. For example, the 1st pixel index is 100. Which I can look up index 100 in day mode palette and night mode palette. How can I use GIMP to do so? My goal is to not update my pixel index of my picture.
Also, as you see in two palette, they are not one one mapping. That is index 1 of the day mode palette and index 1 of the night mode palette may not used in the same pixel of the picture, how can I tackle this problem?
Actually, my use case is as follow
I want to use one 8bpp picture to achieve day/night mode by update only the color palette (without updating the pixel index). The advantage is I only have to prepare 2 256 byte palette rather than saving 2 big pictures in my limited data ram.
Thanks a lot

@J.C., welcome to the community. The two images, although look similar, actually differ in the contents of their pixels. By this I mean that if the day picture actually uses all the colors in the palette, then there are pixel values that are not representable in the night image.

This seems like it might be a game programmming question, not a photography question.

From a glance, it seems like the images are more or less monochromatic, with one using a color ramp tinted to red and the other tinted to blue. So, I'd store the image as greyscale and alter the palette accordingly at runtime.

In any case I wonder where the two images came from.. you probably want to alter your content production pipeline so that the palettes do match (i.e, make the second image by altering the palette of the first).

I can't see how this is a game development question.

Me neither, but this answer may help you out.

When I want to change the color balance on an entire image like is being done in the example, I tend to use the Color Balance tool, which is one of the simplest ways the shift colors throughout a selected area.
There are also a few other tools that you can use to fine tune the color in your images.

Gimp Color Tools Documentation


text:
How do I get Apple to pull an App that violates a copyright?
A friend of mine has had his Flash game stolen and published on the iPhone app store without his consent.  What is the best way to get Apple's attention about this?

I thought that iPhones cannot execute Flash?

They might have made an identical clone that ran natively on the App store.

Since it's most definitely a re-implementation... how much of the original game actually is there? If they "stole" the graphics it's one thing, if they just copied the gameplay don't even bother.

There's an iPhone packager put out by Adobe that will convert Flash apps into native iPhone apps.

At the bottom of every app's page in the app store on the phone is a "Report a problem" button you could try, but I suspect the best way is to have your friend's lawyer handle it (and if your friend does not have a lawyer, he or she may want to consider finding and talking with one).

IANAL but unless they directly copied art resources you are likely out of luck. Game mechanics are incredibly hard to defend and frankly it's in the industries interest that they remain that way.
You can attack someone for directly coping the wording of your games rules, and art coping is an obvious point of contention. However if their game just plays like your game then you are pretty much out of luck.

This is why you see stuff like "Boggle. Rules copyright 1985". Because they can't copyright the mechanics.

Here is a interesting thread regarding copyright and games.
How closely can a game legally resemble another?


text:
Recommended book for cocos2d?
I'm an experienced programmer that recently got into iOS development by working through the big nerd ranch book by Aaron Hillegass and Joe Conway. I loved the way the book was structured in terms of typing in the code and doing the challenges.
I'm interested in learning more about iOS gaming and cocos2d, but am a complete newbie in terms of game development/design. There are a number of books on amazon on cocos2d, can anyone recommend one in particular?

I recommend this book :
http://apress.com/book/view/1430233036
check it out

any reason in particular you recommend this one? there are quite a few

I would recommend wandering down to your local Large Chain Bookstore (Borders, Barnes & Noble, et cetera) and see if they have a copy of any of the books you are interested in. That way you can peruse them for yourself and hopefully get a better idea of whether or not a particular book would be good for you and your particular learning style. Amazon's "Look Inside" feature, if available for the books in question, may also allow you to do this to some extent.
Personally, I'd be very cautious about buying a book that focuses on a specific API, largely because such books tend to go out of date relatively quickly and thus I don't see them to be as strong of an investment. I would thus suggest that you take a good look at all the freely-available online reference and educational material for cocos2d and game development in general (if you have not already, of course) and see if that is suitable enough for you.
All of that having been said, I'm generally a fan of the O'Rielly books, however both of their iPhone books seem relatively old at this point. The Apress books have looked promising when I browsed them in stores, so that would be my secondary suggestion (the caveat being that I have not reviewed any of those books in detail and am basing this recommendation on my experience with the quality of the publisher's other material and quick flip-throughs of the books).

There are only 2 books available on cocos2d, i think
https://www.packtpub.com/cocos2d-games-for-iphone-0-99-beginners-guide/book
http://apress.com/book/view/1430233036
from which i recommend the second one "Learn iPhone and iPad Cocos2D Game Development".
its very well written and a nice introduction to the topic. Autor has described very useful insights using his experience with tools and tips to make a iphone games.

I haven't seen many books on Cocos2d, so I'm curious about the statement that there are "quite a few". Please share your list.
The book "Learn iPhone and iPad cocos2d Game Development" is available on Safari Books Online, if you happen to be a member, but I don't recommend it. As previously said, the book is easy to read and includes the author's best practices. On the downside, the writing style is perhaps too casual, the book is already dated with respect to the current version of cocos2d and it's I found it difficult to apply supplied code directly into my projects. I've been more successful using the tutorials on the Cocos2d website than with the book. The book also glosses over some topics, such as sound.
But since there are so few books on Cocos2d and there are at least two recommendations for this book, I suggest you try out the book in combination with tutorials on the product websites (Cocos2d, SneakyInput, etc), googling for specific information and of course asking questions here on Game Development - Stack Exchange. The book will give you a good idea on how things are supposed to work and you can use the web as a supplement.

I would highly recommend you read Ray Wenderlich's excellent book on Cocos2d, "Learning Cocos2D".  I've just finished reading it cover to cover, completely worth the price.  In particular, Rod and Ray introduce you to game concepts in a very gentle way through incremental level design.  They cover menus, level changes, sprites, sprite sheets, behaviors, AI, physics, etc.  In particular, the introduction to Box2D makes the book worthwhile, IMHO.
You can get a flavor of the book by reading some of the excellent tutorials and articles on Ray's site: http://www.raywenderlich.com/.
I'm a more experienced iOS developer, so reading the code samples was constructive (I didn't compile any of the example code, nor the final game "Space Viking").  I did enjoy that all the game code and assets are available for download, so you can build it yourself along the way.

Direct links to useful presentations (especially for Tetrad moderator):
intro to cocos2d
about performance
And my translation of the first presentation in Russian:
intro to cocos2d на русском


text:
problem with frustum AABB culling in DirectX
I am currently working on a project with a few friends, and I am trying to get frustum culling working.  Every single tutorial or article I go to shows that my math is correct and that this should be working.  I thought maybe posting here, somebody would catch something I could not.  Thank you.
Here are the important code snippets
     /create the projection matrix
void CD3DCamera::SetLens(float fov, float aspect, float nearZ, float farZ)
{
 D3DXMatrixPerspectiveFovLH(&projMat, D3DXToRadian(fov), aspect, nearZ, farZ);
}

//build the view matrix after changes have been made to camera
void CD3DCamera::BuildView()
{
 //keep axes orthoganal
 D3DXVec3Normalize(&look, &look);

 //up
 D3DXVec3Cross(&up, &look, &right);
 D3DXVec3Normalize(&up, &up);

 //right
 D3DXVec3Cross(&right, &up, &look);
 D3DXVec3Normalize(&right, &right);

 //fill view matrix
 float x = -D3DXVec3Dot(&position, &right);
 float y = -D3DXVec3Dot(&position, &up);
 float z = -D3DXVec3Dot(&position, &look);

 viewMat(0,0) = right.x;
 viewMat(1,0) = right.y;
 viewMat(2,0) = right.z;
 viewMat(3,0) = x;

 viewMat(0,1) = up.x;
 viewMat(1,1) = up.y;
 viewMat(2,1) = up.z;
 viewMat(3,1) = y;

 viewMat(0,2) = look.x;
 viewMat(1,2) = look.y;
 viewMat(2,2) = look.z;
 viewMat(3,2) = z;

 viewMat(0,3) = 0.0f;
 viewMat(1,3) = 0.0f;
 viewMat(2,3) = 0.0f;
 viewMat(3,3) = 1.0f;
}

    void CD3DCamera::BuildFrustum()
{

 D3DXMATRIX VP;
 D3DXMatrixMultiply(&VP, &viewMat, &projMat);

 D3DXVECTOR4 col0(VP(0,0), VP(1,0), VP(2,0), VP(3,0));

 D3DXVECTOR4 col1(VP(0,1), VP(1,1), VP(2,1), VP(3,1));

 D3DXVECTOR4 col2(VP(0,2), VP(1,2), VP(2,2), VP(3,2));

 D3DXVECTOR4 col3(VP(0,3), VP(1,3), VP(2,3), VP(3,3));

 // Planes face inward
 frustum[0] = (D3DXPLANE)(col2);    // near
 frustum[1] = (D3DXPLANE)(col3 - col2);  // far
 frustum[2] = (D3DXPLANE)(col3 + col0);  // left
 frustum[3] = (D3DXPLANE)(col3 - col0);  // right
 frustum[4] = (D3DXPLANE)(col3 - col1);  // top
 frustum[5] = (D3DXPLANE)(col3 + col1);  // bottom

 // Normalize the frustum
 for( int i = 0; i < 6; ++i )
  D3DXPlaneNormalize( &frustum[i], &frustum[i] );

}

    bool FrustumCheck(D3DXVECTOR3 max, D3DXVECTOR3 min, const D3DXPLANE* frustum)
{
 // Test assumes frustum planes face inward.

 D3DXVECTOR3 P;
 D3DXVECTOR3 Q;
 bool ret = false;

 for(int i = 0; i < 6; ++i)
 {
  // For each coordinate axis x, y, z...
  for(int j = 0; j < 3; ++j)
  {
   // Make PQ point in the same direction as the plane normal on this axis.
   if( frustum[i][j] > 0.0f )
   {
    P[j] = min[j];
    Q[j] = max[j];
   }
   else
   {
    P[j] = max[j];
    Q[j] = min[j];
   }
  }

  if(D3DXPlaneDotCoord(&frustum[i], &Q) < 0.0f  )
   ret = false;
 }
 return true;
}

you set the variable ret = true/false, but you just return true explicitly, is this a "typo" or actual code error?

sorry typo, its really a return false there instead of setting it to false

Thank you for looking at the code, everyone that did, I have fixed the problem.  The problem was that our level editor's coordinate system was flipped on the x axis.  So what we had to do was flip the x on the vectors of the min/max of the bounding boxes so that they were accurate.  However, eventually we will go back and fix the level editor so that it has the correct coordinate system. lol

Could help if you put that in an answer and accept it in case anyone else runs into a similar problem :)

@Matthew Poole: what happens to P?  You compute it but don't test it?

@Will Here he has computed P unnecessarily. It is used for detecting if the box is partially inside : if(D3DXPlaneDotCoord(&frustum[i], &P) < 0.0f ) return INTERSECTING;

Thank you for looking at the code, everyone that did, I have fixed the problem. The problem was that our level editor's coordinate system was flipped on the x axis. So what we had to do was flip the x on the vectors of the min/max of the bounding boxes so that they were accurate. However, eventually we will go back and fix the level editor so that it has the correct coordinate system. lol


text:
2D game - Missile shooting problem on Android
I have to make a tank that sits still but moves his turret and shoots missiles.
As this is my first Android application ever and I haven't done any game development either, I've come across a few problems...
Now, I did the tank and the moving turret once I read the Android tutorial for the LunarLander sample code. So this code is based on the LunarLander code.
But I'm having trouble doing the missile firing then SPACE button is being pressed.
private void doDraw(Canvas canvas) {

canvas.drawBitmap(backgroundImage, 0, 0, null);
// draws the tank
canvas.drawBitmap(tank, x_tank, y_tank, new Paint());
// draws and rotates the tank turret
canvas.rotate((float) mHeading, (float) x_turret + mTurretWidth, y_turret);
canvas.drawBitmap(turret, x_turret, y_turret, new Paint());

// draws the grenade that is a regular circle  from ShapeDrawable class
bullet.setBounds(x_bullet, y_bullet, x_bullet + width, y_bullet + height);
bullet.draw(canvas);

}

UPDATE GAME method
private void updateGame() throws
 InterruptedException {

 long now = System.currentTimeMillis();

 if (mLastTime > now)  return; double
 elapsed = (now - mLastTime) / 1000.0;
 mLastTime = now;

 // dUP and dDown, rotates the turret
 from 0 to 75 degrees. if (dUp)
 mHeading += 1 * (PHYS_SLEW_SEC *
 elapsed);

 if (mHeading >= 75) mHeading = 75;

 if (dDown) mHeading += (-1) *
 (PHYS_SLEW_SEC * elapsed); if
 (mHeading < 0) mHeading = 0;

 if (dSpace){

//  missile Logic, a straight trajectorie for now
       x_bullet -= 1;
       y_bullet -= 1;
//doesn't work, has to be updated every pixel or what?
 }

boolean doKeyDown(int keyCode, KeyEvent msg) {
            boolean handled = false;
            synchronized (mSurfaceHolder) {
                if (keyCode == KeyEvent.KEYCODE_SPACE){
                    dSpace = true;
                    handled = true;
                }
                if (keyCode == KeyEvent.KEYCODE_DPAD_UP){
                    dUp = true;
                    handled = true;
                }
                if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN){
                    dDown = true;
                    handled = true;
                }
                return handled;
            }
        }

}
a method run that runs the game...
public void run() {
            while (mRun) {
                Canvas c = null;
                try {
                    c = mSurfaceHolder.lockCanvas(null);
                    synchronized (mSurfaceHolder) {
                        if (mMode == STATE_RUNNING)
                         updateGame();
                        doDraw(c);
                    }
                } catch (InterruptedException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    } finally {
                    // do this in a finally so that if an exception is thrown
                    // during the above, we don't leave the Surface in an
                    // inconsistent state
                    if (c != null) {
                        mSurfaceHolder.unlockCanvasAndPost(c);
                    }
                }
            }
        }

So the question would be, how do I make that the bullet is fired on a single SPACE key press from the turret to the end of the screen?
Could you help me out here, I seem to be in the dark here...
Thanks,
Niksa

Where are you setting the value of dSpace?

Is the problem that the turret keeps firing when space is held?

I've edited the thread: dSpace is being handled in the doKeyDown method... The problem is that the bullet should have a constant motion from the turret to the edge of the screen. I doesn't have it, that's my problem, I don't know how to do the physics in the updateGame method when dSpace is true....

All the movements in the lunar lander game are multiplied by the elapsed time since the last frame. This comes from the formula velocity * time = distance. Because of this the motion will be constant no matter what the frame rate is.
Instead of
x_bullet -= 1; y_bullet -= 1;

You should have something like:
x_bullet -= BULLET_SPEED * elapsed;
y_bullet -= BULLET_SPEED * elapsed;


text:
Recursive dungeon maps as represented by an elastic 2d array
I came up with a method for recursively generating simple dungeon maps by starting with one room and recursively connecting new adjacent rooms randomly to it.
Maps are represented as two dimensional arrays where each cell contains a value of 0-15. 0 represents no room while each direction is represented by north=1, east=2, south=4, west=8.
I wanted to start with a single non room ([[0]]) and then expand the 2d array as necessary to fit the generated map. The difficulty I face with this tree like recursion is that if the arrays have to be unshifted to add rows and columns to the left and top of the map, I have to adjust the current position of the function, what row and column it is at. This makes it so that separate branches are not aware of array index adjustments from other branches, only their child functions will know because they have the adjusted position passed to them as their row and column arguments.
Is there a way to do this? I tried storing row and column offset values outside of the recursion, but it did not work for some reason.

Is there a reason you must use a 2D array, or would some a hash table or other kind of map work? Then the x,y indices just continue into negative space, but it doesn't matter.
If you're concerned about memory or CPU speed, 1) Don't be, hash tables are very efficient at things like pairs of dense integers, 2) you can build the level in a hash table and then post-process it into an array once you know the final size.

so the hash function would accept an x and a y argument and this would be mapped to basically an associative array with keys like 1x1, -1x3, etc?

Yeah. In C++ I'd just use an std::pair<int,int>; in Python, a dict with (x,y) tuples for keys. I'm not sure what language you're using.

I'm doing a similar thing, in Python. (Or at least the elastic part).
I have a dictionary of (x,y) tuples mapping to the cells. In pseudo code:
map = dictionary( (0,0) : cell at (0,0), (1,0) : cell at (1,0) ... (2, 2) : cell at (2,2)
getCell(x,y):
    return map[(x,y)]
    catch error if out of bounds:
         map[(x,y)] = new cell and return

A hash table would be very good for this kind of thing.

The minimum effort solution is to pick a maximum size (X and Y extent) that you want the dungeon to reach, put your starting point in the center of that, and don't allow growth outside of it.  No need to do any shifting.  Depends on a fixed extent being acceptable, of course.

You would want to use a graph instead of the 2D array.
Each room would be a node in the graph and knows which other rooms are adjacent to it:
Room {
    long x;
    long y;
    List adjacentRooms;
}

That way you don't have to define how large your map can become.
The x,y-Coordinates can be used as unique key in a hashmap for fast access to each room. Adding a new room would just add entries to the adjacentRooms lists of the rooms close-by.
The graph is also great for path finding algorithms, if you need them.

This will perform poorly and require much more bookkeeping than a hash table or array. There's no benefit in the rooms having both an X,Y hash key and forming a directed graph.

How would you do fast access of rooms with only the directed graph? How would you do path finding with only an X,Y hash key? This would require additional logic to determine the adjacent rooms. The hash key is really just another view of the game world. I agree that handling a graph is more trouble, but will benefit algorithms using the graph. Performance depends on the size of the game world. So this has to be prototyped. Thx for the down-vote. Cheers!

Nothing in pathfinding precludes using a hash of X,Y pairs. Successor states are successor states, it doesn't matter if you maintain a crazy graph or look it up on a hash table, except that the hash table is faster and uses less memory.

The hash key solution is less abstract. As I wrote before the pathfinder must know which rooms are adjacent to each other, how to calculate the distance to the target room etc. You would put knowledge about the game world into your pathfinding algorithm. If the setup of the game world changes e.g. movement from rooms which are diagonal to each other is permitted or a third dimension is added, you would need to change every algorithm accessing the game world. Graphs abstract this away. Nothing crazy about it. There are always drawback to every solution.

"Graphs abstract this away." So does any iterator, generator, coroutine, or list-building method, and they don't require O(n) structure bloat nor more build-time bookkeeping.

Please mention more random computer science terms. This is pointless


text:
Going fullscreen without stretching in an XNA game
I've got a 2D game that I'm working on that is in a single aspect ratio. When I switch it to fullscreen mode on my widescreen monitor it stretches. I tried using two viewports to give a black background to where the game shouldn't stretch to, but that left the game in the same size as before. I couldn't get it to fill the viewport that was supposed to hold the whole game.
How can I get it to go fullscreen without stretching and without me needing to modify every position and draw statement in the game?

From: http://forums.create.msdn.com/forums/p/58545/358858.aspx (emphasis mine)

There is a very simple answer to your
  question: your monitor is a widescreen
  monitor, if you set a non-widescreen
  resolution to it, it will have to
  stretch the output to give you an image.
  Some graphics adapters and some
  screens provide a '4:3 in wide' mode
  which destretches for you.
However if you want your game to
  always look right and not be stretched
  you have todo the following:

Render to a rendertarget instead of to the screen directly
Get the texture from the render target
Clear the screen to black
Start a spritebatch and render your texture at the correct aspectratio on
  screen scale it by using an overload
  that uses the targetRectangle, this
  way you have automatic black borders
  either above or on the sides.

This should be be realy easy to
  implement :)

The problem is explained above (Monitors will generally stretch out an image to make it fit in full screen). I however think the easiest solution is to just change your rendering resolution with the adapter to a support full screen resolution. I would imagine that XNA still has the render mode enumerable that you can get that information from.

Exactly, there isn't an automatic way to do this for 2D -- you need to render on something besides the screen, then render that to the screen.

You can just set your ProjectionMatrix like so:
ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4,
                                                        (float)Game.Window.ClientBounds.Width / (float)Game.Window.ClientBounds.Height,
                                                        1.0f,
                                                        3000.0f );

This will set your aspect ratio correctly, in whatever screen you're using.

projection matrix?  Isn't that just if you're using cameras?  My game is only in 2D so I'm not using a camera.


text:
OpenGL or OpenGL ES
What should I learn? OpenGL 4.1 or OpenGL ES 2.0?
I will be developing desktop applications using Qt but I may start developing mobile applications in a few months, too. I don't know anything about 3D, 3D math, etc and I'd rather spend 100 bucks in a good book than 1 week digging websites and going through trial and error.
One problem I see with OpenGL 4.1 is as far as I know there is no book yet (the most recent ones are for OpenGL 3.3 or 4.0), while there are books on OpenGL ES 2.0.
On the other hand, from my naive point of view, OpenGL 4.1 seems like OpenGL ES 2.0 + additions, so it looks like it would be easier/better to first learn OpenGL ES 2.0, then go for the shader language, etc
Please, don't tell me to use NeHe (it's generally agreed it's full of bad/old practices), the Durian tutorial, etc.
Thanks

I suggest going the route with OpenGL ES 2.0, because as you have already said it is pretty much a subset of modern OpenGL. You should also be aware that even today some mobile devices only support OpenGL ES 1.0, which is radically different to OpenGL ES 2.0 and more like OpenGL 2.x (fixed function).

From a general point of view, either. The practices you learn in one will benefit you in the other.
It's more of a question of what you have access to, and what your interests are.
As for books, any book related to OpenGL later than 2.0 will help you get into the bleeding edge, since OpenGL works through extensions.
Also see What is the difference between OpenGL ES and OpenGL?


text:
Whats a good setup/toolchain for a project?
I was thinking, what is needed for a good setup and what are good (free) tools to use? Some of what i came up with are

Bug tracking
Some good (distributed:P) source control (which means no svn fellas)
automated nightly builds or a continuous integration (or anything that automates builds and possibly sends emails when there are build errors)
wiki to document decisions, road map or milestones.
Something to backup assets (art, sound, etc)

What else? and do you have suggestions for any of the above? i pretty much clueless of all of these except for source control

Do you care about keeping your source closed or not, and do you care about whether or not a service must be self-hosted? Many of the better free options for some of your questions depend on those criteria -- for example, I like Google Code (which supports Mercurial for DCVS) but it requires you make your code available under an open source license.

@Josh: I think everything should be able to run on your local network just for reliability reasons (in cause your internet or isp goes down or the operating site is down for maintenance). I think many ppl would want private code so self hosted and private is recommended for these answers.

Oh, well, I posted my answer while you were posting this comment I guess, and most of it focuses on hosted stuff, but... hopefully some of it is still useful to you. :D

Converting to CW as this feels like a "list of X" question.  Although, X is pretty vague.  This really feels like it probably should be separate questions.

This sounds like five community wiki questions to me.

It sounds like four CW questions and a dup of http://gamedev.stackexchange.com/questions/480/version-control-for-game-development-issues-and-solutions to me.

@acidzombie: Except in very rare cases (one developer once told me their SOX compliance requirements forbid it, e.g.), hosting your own VCS is really more of a liability than an asset. It takes a surprising amount of time/people/money to keep it running well.

@Joe Wreschnig: Really? Any idea if the same problem with distributed version control? I never had a problem with git and having a bare repository for each user to push to and only pulling seems to work very, very well.

@Tetrad: Yes, but i am really hoping someone can mention tools that work well together or a package with two or more of these. Not that i think they should all be in one package such as TRAC or redmine. I'm thinking it would be cool if all of these were separate but have a plugin so if i am looking at bugs i can easily visit the doc on wikimedia and another link say in the toolbar of all of these to bring me to nightly builds and see what failed or not. Or an article to explain how to set the toolchain up but really i like the idea of good solid separate package then one that handles it all

On your fifth question, I'd put the assets in source control. Whether in the same repository as the code or not depends on how big they are.

I can't say enough positive things about FogBugz.  It's the best bug/task tracking system I've used.  As of FogBugz 8 it even has a decent Wiki based of CKEditor.  It supports plugins so you can extend it to do a bunch of stuff (like a Kanban board), or customize its workflow, or do more extensive timesheet reporting, or whatever.  You can do self hosted or pay them to host.
Now the base solution isn't free, but you can do a "students and startups" hosted solution which is good for 2 users.
They have a separate product, Kiln, which is basically Mercurial but tied in Fogbugz (optionally) and has a pretty slick code review pipeline.  I talked to one of the guys that worked on it and they said it had pretty decent tools for dealing with the "big file" problem with DVCS solutions (namely that every client has every version of every file, and that not scaling for, say, giant zbrush files), like filtering "big files" by extension, and that sort of thing.

Bitbucket uses Mercurial as its dvcs and has features similar to Github, but it also has a great free plan where you can store unlimited private projects with up to 5 collaborators.
http://bitbucket.org

Github, git, Hudson (note: this is not a hosted service), Github, Github :-)

I like Google Code a lot -- if you are willing to make your project open-source, it's pretty awesome. It provides you with hosting for code (SVN or Mercurial), files for releases, a simple-but-effective wiki, and a straight-forward bug tracker. The downsides are that access control for the wiki is limited, and edits to the wiki cause commits to your repository.
I've heard good things about github, and from what I've seen of it while grabbing people's code from it, I like it. But I have never used it for more than that, because I don't have a compelling need (or desire) to use distributed version control.
In the realm of less-general tools, Perforce is a powerful version control system that is used by just about every professional game development studio I have worked at or know of. They have free limited-user licenses. You need to host and administer the server yourself, though, which is something I have very limited experience doing so I can't comment much to that.
I have used Trac for bug tracking before (and still do for my own projects that I host on my private SVN). It's also simple -- I am a fan of simple bug tracking and such, instead of systems like Bugzilla, which I think are too much trouble to configure. I don't use Trac's built-in wiki, really, preferring DokuWiki instead. There is also the ever-popular MediaWiki, if that's your thing.
Backup-wise, I mostly use Backblaze, which is awesome but violates your "free" constraint. If I couldn't use Backblaze I'd just back everything up via a cron job or something to an external hard drive and mirror that to my web server, probably.


text:
Is there an algorithm for a pool game?
I am looking for algorithm to calculate direction and speed of balls in a pool game. I am sure there has to be some type of open source code for this since pool games are some of the oldest computer games I can remember.
I mean, when one ball hits another, I need a algorithm to calculate direction of both of them. It will depend of exact angle of where they hit each other and on speed.
I want to practice Java coding, so I am looking for java code or package that has this type of code.

If you want to solve it yourself, though, you are probably going to need some knowledge of vectors. Luckily, someone posted a great walkthrough on linear mathematics elsewhere on this site just the other day.

maybe this site can help you http://archive.ncsa.illinois.edu/Classes/MATH198/townsend/math.html#COLLISION

Whilst basic sphere-sphere collision detection/response is quite simple, doing it accurately enough for a good pool simulation would be more tricky, as you'd have to deal with spin.
Are you aware of the existence of physics engines? Some popular examples are these (and they can do a lot more than just pool ball collisions). Probably a good choice for making a pool game, but not so much for learning Java...
In 2D
Box2D:  http://www.box2d.org
Chipmunk:  http://code.google.com/p/chipmunk-physics/
In 3D
Bullet:  http://bulletphysics.org/
ODE:  http://www.ode.org
If you were making a big-budget commercial game:
Havok: http://www.havok.com

Which of these are Java physics engines though?

There are Java ports of, or at least bindings for Box2D, Chipmunk, Bullet, and ODE

You may be interested in the article "Pool Hall Lessons: Fast, Accurate Collision Detection Between Circles or Spheres" if you choose to go the "roll your own" route.  It's not Java-specific, but does discuss some of the algorithms involved for a simple simulation.

For a simple pool game where spin is not modeled the algorithm is quite simple.

To check if a collision happens, check if the distance between the balls is smaller than the sum of their radius.
Calculate the normal of the impact
Calculate the impact force based on the speed difference, normal, impact coefficient and masses
Apply the impact force to both balls

In pseudo code this becomes:
vector difference = ball2.position - ball1.position
float distance = sqrt(difference)
if (distance < ball1.radius + ball2.radius) {
    vector normal = difference / distance
    //vector velocityDelta = ball2.velocity - ball1.velocity
    vector velocityDelta = ball1.velocity - ball2.velocity

    float dot = dotProduct(velocityDelta, normal)

    if (dot > 0) {
        float coefficient = 0.5
        float impulseStrength = (1 + coefficient) * dot * (1 / ball1.mass + 1 / ball2.mass)
        vector impulse = impulseStrength * normal
        ball1.velocity -= impulse / ball1.mass
        ball2.velocity += impulse / ball2.mass
    }
}

You can omit the mass from the algorithm if all balls have same mass and also assume constant radius for all balls for a pool game, but the code will be more useful for you without those simplifications.
The code is based on this tutorial, but I remember that the impulse multiplication was incorrect there.

What about if dot is less than zero?  I've been investigating this pseudocode (and the one you linked too, but the other one ends up with my trying to take the square of a negative number - perhaps that's the problem you identified with it).  Surely you want to produce a result with every set of input positions and velocities?

@Poldie If the dot is negative, the balls are already moving away from each other. No need to handle collision in that case.

I've just knocked up my version of your code here: http://ideone.com/DhsAoW and I'm getting -0.707 for a positions of 110,90 and 100,100, and velocities of 0,2 and 0,-3.  This is a more or less head-on collision. (Assume the initial radius-based collision detection check has already occurred).

I'm not sure about the "quite simple": for high speed trajectories tied to framerate, it is trivial to run into the situation where either one ball is moving so fast that it just "passes through" another ball in between frames, or the lower speed problem where two balls are moving fast enough that their crossing only occurs between frames.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Does C# have a future in games development?
I recently learned that the MMO Minecraft is powered by Java from a recent interview on CVG.co.uk on a possible collaboration between two former and now competing colleagues. In the interview he bluntly said that the founder of Minecraft is a Java coder and he is a C or C++ coder so they are incompatible with each other. So collaborating on future projects will be difficult.
This got me thinking, If Java could do that? What does the future hold for MS very popular C# language and .Net platform as far as games or mainstream games development is concerned?

Yes. http://en.wikipedia.org/wiki/Microsoft_XNA

It's all about the performances you need, Minecraft is ok in a managed language, but for high end graphics games, C or C++ or other natives languages are prefered

Minecraft is not really an MMO.

@Guillaume86: Jittered code can currently outperform native code, and Jits are getting better all the time. Also, managed languages produce far more robust programs. So in the end C++ loses it's performance advantage, and is significantly harder to write robust programs in (which means longer development times and more costs)

A JIT can beat poorly written native code, not tightly optimized and tuned inner loops. Granted even with C# you have the option of writing those sensitive segments in C/C++ if you really want.

Notch (The author of minecraft) also played a large part in Wyrm Online, which was written in C++ - he's not a "Java coder" so much as "a coder who knows java".

C# is faster than C++ by about 3 months.

Uh.. are you basically asking if unity has a future? =)

@coderanger Of course super optimised native code can beat jittered code. But doing those kind of optimisations is time consuming and costly. Where writing all your managed code is almost as fast, and a helluva lot easier/faster to develop. And if one of the companies out there started releasing games twice as fast as they currently do, with less bugs, I think gamers would be pretty happy about that - even if it took 5% more CPU load ;)

@Martin See my answer here to see why that doesn't really happen that often. I can also say from personal experience that a 5% decrease in RAM usage can save thousands (multiple concurrent server processes, less RAM means less hardware means less $$$). As a big Python supporter I would love to the CLR become a more viable option for AAA game development, but it sure as hell isn't there yet.

@coderanger: I know that currently not many large studios use managed languages, and I'm sure that's going to continue for a very long time. However more and more small scale companies are using managed languages, and I can't imagine that going away anytime soon either.

I'm sure its not ironic then that Minecraft is an incredible performance hog?

You should check out XNA. A platform for building games for Windows, Xbox 360 and Windows Mobile 7. All in C# and .NET.

I've been working in professional game development for over 5 years. Most of this time, I used C# almost exclusively.
C# and .NET stack in general is really great for server-side tech. I've worked on no less than 4 MMO games with server written in C#. Also, with Unity3D gaining popularity, many browser AND mobile games require C#. Don't forget XNA framework: it's not the engine of choice for AAA console titles, but there are many great games made with it, and many more currently in the making.
Overall, C# definitely has a future in game development.

it's an old question, but one thing bothers me. "server-side tech" - what exactly do you mean by that? A WindowsService running on some Windows Server using .NET Framework? I always thought that servers are made in c++ and running on unix os. I was just curious

Yep, exactly that. There are lots of servers running on Windows out there - including the ones that run this very site, AFAIK.

thanks for getting back to me. Just to clarify - "running on Windows" as headless Windows Services or programs like WinForms (with built in config or something like that)?

Headless service is usually a better idea, but nothing's stopping you from just running a console application. Or even a GUI one, except there's no one on the server to use said GUI.

As has been mentioned, Mono brings C# to multiple platforms. In that same area, you'll find Tao, a multiplatform library for Mono and .NET that allows access to Cg, DevIL, FreeGLUT, GLFW, GLU, ODE, OpenAl, OpenGL, PhysicsFS, SDL, and WGL. It's obviously not as robust when it comes to features as XNA (which provides fundamental engine components directly to the developer); but, it's plenty powerful.
So, cross platform beyond Microsoft controlled OS's and hardware is definitely possible. Just, not as many popular indie games have utilized this ability, yet.
As has also been mentioned, XNA coupled with C# allows independent developers to publish to the 360, PC, and Windows Phone 7.
Overall, C# is alive and well in game development as an engine/game language.
As a tools language, it's in use everywhere. I've built tools for EA, THQ, and now Arkadium all using C#.

Not only does C# have a future in games development, it has a present -
Check out Magicka, a game recently released (and selling well) that was developed using XNA.
Also take a look at the winning Dream.Build.Play entries. C# is a viable way to make games (although right now I don't believe it's the right choice for all games).
As time goes by we'll see it becoming more popular in the computer gaming industry, however I don't expect a sudden shift to C# at any point.

Java has always been a very versatile language and there's always been the ability for people to code games in it, from simple web based games (Java applets / GWT with the canvas plugin) to full 3D beasts (checkout JMonkey). So I wouldn't say the fact Java can do that sort of thing is a C# killer, because most people know Java can do that already.
C# will still remain popular though since it inevitably ties in with Windows, Windows mobile and the Xbox much better than Java (which, really, is all game developers really care about targeting so the cross platform advantage that Java has is mostly lost.) It's also got XNA which has really taken off in terms of game development.
So yes, Java is a perfectly good platform for games development if anyone wishes to go down that route, but it's certainly no C# or .NET killer.

Check out Unity 3D; C# (and JavaScript, and Boo) scripting in a high-performance 3D engine.
Add XNA to the mix and you're looking at a couple of great platforms for using C# for game development.

Unity also has a web player so you could play in the browser. The plugin doesn't have a huge market penetration like flash or java, but it's possible.

yay for unity!!

Yes, C# has a future, with the XNA framework. Most prefer C++ because of speed, but C# is not that slow anymore...

It's not slow at all. It's rarely worse than about 70% of C++ speed, and can even be faster sometimes!

CPU bound operations in C# are quite fast, it does some extra checking which vastly improves the safety of code at the cost of some minor performance hits but where it's much worse than C++ is in memory consumption and management. It's a heck of a lot easier and less leak prone in C# but the performance hits of the GC can be an absolute dog.

Beware when targeting the Xbox360 though. The XNA runtime there lacks the ability for some of the major optimizations and prevents you from shifting performance sensitive portions to unmanaged code.

Also - MonoDroid may be an option for C#.

What he did with Java in this instance was create an applet so that you could just log on to the site and play with a very common plugin, completely transparent to which operating system was being used. I imagine his thinking was that Java was quite transparent when used this way and it would make it easy for the quick iterative development / testing he was getting fans to do. I don't believe you can just do this with XNA because usually the tester has to have everything installed as well as the game and some general knowledge about how to compile and run this.
So I would say that there is no paradigm shift from this, it just suited what he needed at the time and obviously worked out well.

Sure, lots of programming languages have a future in games development.  It is an often used false dilemma used in the computing press that there can be only one tool of type X and that everybody wants this to occur.
Nothing could be farther from the truth.
C# and Java have been used in games for a long time.  C and C++ have for even longer, and still are.  Lua is used as the scripting language for some incredibly popular games, with the engine written in C/C++.
So clearly, no programming language is blowing other programming languages out of the water as The Game Programming Language.  In fact, we see a tendency for leading games to be composed of a high performance compiled programming language for developing the engine(s) in. and then a higher level dynamic programming language for scripting how the UI and stuff behaves.
The key at the moment is performance.  If any of the programming languages/libraries used cause unpredictable/uncontrollable pauses in the application then in an action game, that will fall flat on its face. In a text-based adventure game, that might be okay however.


text:
Drawing particles with CPU instead of GPU (XNA)
I'm trying out modifications to the following particle system. http://create.msdn.com/en-US/education/catalog/sample/particle_3d
I have a function such that when I press Space, all the particles have their positions and velocities set to 0.
for (int i = 0; i < particles.GetLength(0); i++)
{
    particles[i].Position = Vector3.Zero;
    particles[i].Velocity = Vector3.Zero;
}

However, when I press space, the particles are still moving. If I go to FireParticleSystem.cs I can turn settings.Gravity to 0 and the particles stop moving, but the particles are still not being shifted to (0,0,0).
As I understand it, the problem lies in the fact that the GPU is processing all the particle positions, and it's calculating where the particles should be based on their initial position, their initial velocity and multiplying by their age. Therefore, all I've been able to do is change the initial position and velocity of particles, but I'm unable to do it on the fly since the GPU is handling everything.
I want the CPU to calculate the positions of the particles individually. This is because I will be later implementing some sort of wind to push the particles around. How do I stop the GPU from taking over? I think it's something to do with VertexBuffers and the draw function, but I don't know how to modify it to make it work.

I changed your tag from 'xna-4.0' to 'xna' because I don't think anything in your question is XNA 4 specific, except for the fact that the sample you link to happens to have been updated to compile with XNA 4.

The particle system you are using as a base is explicitly designed to perform all its animation on the GPU. To disable that, you need to use a different design.
You can modify the baseline you have to remove all position update/animation code from the vertex shader (see ComputeParticlePosition) and move that to your application. You'll have to employ dynamic vertex buffers -- locking the buffer each frame, copying the position out of the particle system data structure and in to the buffer (although with the rest of the particle's vertex attributes), and then unlocking the buffer. You may want to remove/modify the rest of the ComputeParticleWhatever methods in the shader, since any modifications they make to the particle system will clobber any updates you do on the CPU.
Then you'll have complete CPU-side control over the particle attributes, at the cost of decreased performance due to the additional cost of updating the vertex buffer each frame -- this the bottleneck that the sample describes avoiding in the description:

When displaying large numbers of
  particles, games can easily become
  bottlenecked by the amount of CPU work
  involved in updating everything and
  transferring the latest particle
  positions across to the GPU for
  drawing. This sample avoids that by
  animating particles entirely on the
  GPU, so the CPU overhead remains low
  regardless of how many particles are
  active. Moving eye candy to the GPU
  leaves the CPU free for other things
  such as gameplay, physics, or AI.

So you should be aware that you are eliminating this optimization by moving per-frame update back to the GPU. Note that, depending on the complexity of your "wind" function, you could probably instead push that computation to the GPU as well, which would give you the finer control you are after as well as obviate the need to update a vertex buffer every frame.

Alternatively, you can modify the shader used to update your particles so that it does the wind calculations on the GPU as well.  That way you have the added wind control, but don't lose the performance benefits of the GPU particle system.  Obviously there are limitations to what you can do with a GPU particle system, but adding wind shouldn't be one of them.  Good Luck!

Ha, my very first post and I failed.  Josh already pointed out that it might be possible to move the "wind" update to the shader.


text:
Mental Ray render loss in Maya?
The option in the rendering menu of Maya doesn't say "Mental Ray" anymore.
Please help me to get it back, or even a better plugin for Maya game quality rendering.

A quick google search says that sometimes it "deactivates itself" and it has to be reactivated on the plugin manager (Window > Settings/Preferences > Plug-in Manager)
EDIT: According to this other post, Mental Ray's dll is called Mayatomr.mll

Mentalray.dll or something simular to that isn't in the folder at the plugin manager?

Sorry, is that a question?

@egarcia yes it is. Joris says that Mentalray.dll is not in the folder.

@Joris: I've edited my answer to include the name of the Mental Ray dll. I hope this solves your issue.

@Joris: if my answer solved your question, please mark it as valid by clicking on the "flag" on the left.


text:
What's the purpose of OpenGL's Vertex Array Objects?
I've just started out with OpenGL I still haven't really understood what Vertex Array Objects are and how they can be employed.
If Vertex Buffer Object are used to store vertex data (such as their positions and texture coordinates) and the VAOs only contain status flags, where can they be used? What's their purpose?
As far as I understood from the (very incomplete and unclear) GL Wiki, VAOs are used to set the flags/statūs for every vertex, following the order described in the Element Array Buffer, but the wiki was really ambiguous about it and I'm not really sure about what VAOs really do and how I could employ them.

I think you will understand their purpose better with a sample. By reading the comments you will understand how VAOs are used.
// BEGIN INITIALIZATION
// Define some vertex data
struct Vertex {
  GLfloat position[3];
  GLfloat texcoord[2];
};
Vertex vertexdata[NUM_VERTS] = { ... };
GLubyte indexdata[NUM_INDICES] = { 0, 1, 2, ... };

// Create and bind a VAO
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);

// Create and bind a BO for vertex data
GLuint vbuffer;
glGenBuffers(1, &vbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vbuffer);

// copy data into the buffer object
glBufferData(GL_ARRAY_BUFFER, NUM_VERTS * sizeof(Vertex), vertexdata, GL_STATIC_DRAW);

// set up vertex attributes
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, texcoord));

// Create and bind a BO for index data
GLuint ibuffer;
glGenBuffers(1, &ibuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibuffer);

// copy data into the buffer object
glBufferData(GL_ELEMENT_ARRAY_BUFFER, NUM_INDICES * sizeof(GLubyte), indexdata, GL_STATIC_DRAW);

// At this point the VAO is set up with two vertex attributes
// referencing the same buffer object, and another buffer object
// as source for index data. We can now unbind the VAO, go do
// something else, and bind it again later when we want to render
// with it.

glBindVertexArray(0);

// END INITIALIZATION

// BEGIN RENDER LOOP

// This is it. Binding the VAO again restores all buffer
// bindings and attribute settings that were previously set up
glBindVertexArray(vao);
glDrawElements(GL_TRIANGLES, NUM_INDICES, GL_UNSIGNED_BYTE, (void*)0);

// END RENDER LOOP

Can I do this with GL_DYNAMIC_DRAW buffer data too? Would the rendering part just contain the glBindVertexArray(), glBufferData() and then glDrawElements()?

How do you deal with normals in this example? I mean what if you add a GLfloat normal[3] in your Vertex class and want to upload the normals to client?

VAOs are useful, because you don't have to set up everytime all attributes. It should also be faster just bind one VAO rather then setting all attributes.

This is my favorite link: http://www.songho.ca/opengl/gl_vertexarray.html
It should help you get a better understanding of the differences between VAO and VBOs. Also, Id recommend reading a chapter in OpenGL superbible on this topic. It does a good job at explaining these basics at length and with examples.

The article you linked does not cover VAO's, only vertex arrays (which have been around a while longer). I'm puzzling over the specific differences between these two myself.

There is not much difference. The VAO just encapsulates all state regarding the vertex arrays and their usages and formats, except for the array data itself, which is stored in VBOs. But you're right in that this answer (or the link) doesn't really talk about VAOs.

Lecture 9 Here http://nccastaff.bournemouth.ac.uk/jmacey/CA1/index.html has some stuff about it (as do the rest of my notes) and If you look at the NGL library on the same site I have a class that wraps up the behaviour of a VAO