I'm making this snake game, and I've created a class to handle the snakes (players and AI snakes), this works out quite well, however, at the moment I'm declaring my main snake (player 1), as global, in terms of:
class Snake
{
//... Lots and lots of code.
}
Snake Andy;
^^ this works out quite fine, however I'm interested in being able to call Andy in the running of the program, but still as a global variable, however I still need Andy to be global, since I've need to access him from a lot of different threads and functions. I've got about 10 threads running in real-time, and about half of them, are using Andy, so somehow pointing to Andy, and sending the pointer as argument, doesn't really satisfy me.
The reason I'm interested in calling Andy in the game code, is to be able to like send him some values doing the constructor, and to be able to declare my snakes on the fly, when they're introduced in the game, rather then having them created and being like, on 'standby'.
Beside of this, then I've got the following lines of code, to switch between full screen and windowed mode:
if (key == GLUT_KEY_F1) // Toggle FullScreen
{
fullscreen = !fullscreen; // Toggle FullScreenBool
if (fullscreen)
{
glutGameModeString( "1280x800:32@60" );
glutEnterGameMode();
}
else
{
glutLeaveGameMode();
}
}
^^however this seems to somehow 'crash', well the game keeps running, however I'm not entering or leaving fullscreen, and it somewhat freezes, I've tried to call the:
glutGameModeString( "1280x800:32@60" );
glutEnterGameMode();
In main, and it works like a charm if called that way, however, then I'm unable to use, like windowed mode; i tried using the following code instead, for the fullscreen:
if (key == GLUT_KEY_F1) // Toggle FullScreen
{
fullscreen = !fullscreen; // Toggle FullScreenBool
if (fullscreen)
{
glutFullScreen(); // Enable Fullscreen
}
else
{
ResetWindowSize(); // Make Window, and resize
ResetWindowSize(); // Dual call needed to make it work
}
}
The ResetWindowSize, is simply the following:
GLvoid ResetWindowSize(GLvoid) // Reset WindowSize
{
glutReshapeWindow(800, 600);
glutPositionWindow(0,0);
}
This effectively fullscreens, however, if I'm calling variables instead of just 800x600 for the " glutReshapeWindow", then it wont leave fullscreen, I've made a thread about this here:
http://www.daniweb.com/forums/post1035534.html#post1035534
I should mention that my code is written using freeGLUT for graphics. - When talking about freeGLUT, anyone into making a menu in glut? - Since I've could need a helping hand there.
However I'm interrested in getting help to loading mp3 files into an OpenAL buffer, if anyone is able to help me with that as well, as the memory usage is quite heavy using wav files.
If anyone know a replacement for 'Createthread()' and the associated event system (handles; 'CreateEvent()'), please let me know, since I somewhat want it to be platform independend.
Crossing fingers for more responds, then to the last thread >.<
^^just answering parts of it, will be fine :)