opengl_tgm1

Thread in 'Research & Development' started by nightmareci, 20 Apr 2013.

1. nightmareci

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.

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.

Attached Files:

• opengl_tgm1.7z
File size:
49.5 KB
Views:
23
Last edited: 6 May 2013
2. Marq

as a computer programming drop out. I will be doing extensive testing on this.

3. Deeem2031

Code:
goto DONE;

4. Marq

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.

5. Muf

I'm not sure what the context is here, but that is a very common pattern and a legitimate use of goto.

6. Deeem2031

Too bad there is no "Goto - not even once" meme

7. Caithness

Is there a difference between the .zip and the .7z files?

8. Muf

The 7z is the build and the zip is the source code, as far as I can tell.

10. PetitPrince

MSVCR110.dll is missing.

13. cleure

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.

14. cleure

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.

15. Caithness

I'll probably love you forever.

16. XeaL

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;
}

17. cleure

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.

18. nightmareci

Thanks XaeL. That little refactor is much better than my goto; you'll be credited in the source for that change.

19. cleure

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

20. nightmareci

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.