This is a semi-playable pre-alpha of my current efforts to clone TGM1 using OpenGL for graphics, and SDL 2.0 for everything else. The package attached to this post is source-code-only; I'm posting now to get assistance in fixing gameplay bugs that I don't quite know how to fix. Any fixes will be credited to the user(s) that provide them. Source updates: 2013-04-22: Fixed 20G a bit, and now holding down never causes gravity to halt. 2013-04-22: Added visible playfield borders that look just like TGM1's. 2013-04-24: Added joystick support, a configuration file, the option to choose screen/block resolution, and fullscreen support. 2013-05-06: Added joystick POV HAT support (D-pad), improved TGM1 accuracy, and the code should work on Mac OS X now.
haven't looked at the code yet, just trying to run the damn thing. the make runs fine, but I'm having opengl errors specific to my linux drivers from the looks of it. might try again tomorrow.
I'm not sure what the context is here, but that is a very common pattern and a legitimate use of goto.
Goto is much better than break in this instance, as its a nested loop and C++ doesn't have labeled breaks. Using break would require an extra variable, and would increase the possibility of branching screwing up your cache pipelines.
If I have some extra time this week, I'll probably post an OSX build. I played around with it earlier today, and it kept segfaulting after I got it to compile. I tracked it down to the glGenVertexArrays() call in void init(void)... Apparently OSX 10.7 requires a few extra API calls to obtain an actual OpenGL 3.2+ context.
Code: bool TGM1Game::isBravoField() { bool bravoField = true; /* Check each row. If a row is found with blocks, but it isn't a filled * row, then it's not a bravo field; else, it is a bravo field. */ for (int row = 0; row < FIELD_HEIGHT; row++) { if (!filledRow(row)) { for (int x = 0; x < FIELD_WIDTH; x++) { if (state.field[row][x] != PIECE_EMPTY) { bravoField = false; goto DONE; } } } } DONE: return bravoField; } Really? Code: bool TGM1Game::isBravoField() { /* Check each row. If a row is found with blocks, but it isn't a filled * row, then it's not a bravo field; else, it is a bravo field. */ for (int row = 0; row < FIELD_HEIGHT; row++) { if (!filledRow(row)) { for (int x = 0; x < FIELD_WIDTH; x++) { if (state.field[row][x] != PIECE_EMPTY) { return false; } } } } return true; }
You have a point. I guess I didn't read into it too thoroughly. Goto is a common pattern in C/C++ for labelled breaks and error handling, and I just assumed thats what it was being used for.
Thanks XaeL. That little refactor is much better than my goto; you'll be credited in the source for that change.
Do you happen to have your code in version control (Git, HG, etc)? I've made quite a few changes to the original files you posted to get it to compile on OS X, which you might want to include... Unfortunately, it seems that OS X still doesn't fully support OpenGL 3.3, so I'm having a bit of trouble getting the graphics to display properly
Sorry, no version control right now. Just post an archive of the code in a post to this thread (no .dmg files, please!), and I'll manually merge the code into my version.