Sign in to follow this  

splash screen and logo

This topic is 4053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello everyone, im having trouble figureing out how to show my company name then wait for the user to press any button and load the title screen of my game. everything is an object includeing company_screen. it has a member function show(). here is my main: int main( int argc, char* args[] ) { //Make the timer Timer myTimer; //Start the timer myTimer.start(); //keeps track of current bullet on screen int bullet_num = 0; //Game Over flag bool game_over = false; //Initialize if( init() == false ) { return 1; } //Load the files if( load_files() == false ) { return 1; } //Create all objects for screens Company company_screen; Title title_screen; Story story_screen; Credit credit_screen; Level1 level1; //Create all the title button objects ButtonNew newButton (200,200,120,40); ButtonStory storyButton (200,240,120,40); ButtonCredits creditButton (200,280,120,40); ButtonExit exitButton (200,320,120,40); //Create all game objects Player newPlayer; std::list<Bullet> activeBullets; std::list<Enemy_A> activeEnemy_A; //Create animations for sprites set_playerClips(); set_buttonClips(); //Frame rate cap timer Timer fps; //While the user hasn't quit while( quit == false ) { fps.start(); while(SDL_PollEvent (&event)) { newPlayer.handle_input(); newPlayer.set_life(30); //If the user has Xed out the window if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } //******************************************* //* Display company * //******************************************* company_screen.show(); //******************************************* //* Display level1 * //******************************************* level1.show(); newPlayer.move(); newPlayer.set_camera(); newPlayer.show(); //Get the keystates Uint8 *keystates = SDL_GetKeyState(NULL); //If spacebar is pressed shoot bullet if(keystates[SDLK_SPACE]) { Bullet newBullet; newBullet.set_xy(newPlayer.get_x(), newPlayer.get_y()); activeBullets.push_back(newBullet); } std::list<Bullet>::iterator iBullet = activeBullets.begin(); while(iBullet != activeBullets.end()) { if(iBullet->is_dead()) { iBullet = activeBullets.erase(iBullet); } else { iBullet->show(); iBullet->move(); ++iBullet; } } //Update the screen if( SDL_Flip( screen ) == -1 ) { return 1; } //Cap the frame rate with fps while(fps.get_ticks() < 1000 / FRAMES_PER_SECOND) { //wait... } } //Clean up clean_up(); return 0; }

Share this post


Link to post
Share on other sites
There are a number of options to solve this problem. One is Finite State Machines.

--> Initializing
|
--> Display company logo
|
--> Display menu
|
--> Options
|
--> Game
|
--> Deinitialize

Each state should have its own functions and events (to handle input for example). Upon starting your game, make sure it starts in initialize. When done move to Display company logo. (this can be the same if you wante to). Upon pressing a key switch to Display menu. Each menu item will then switch you to a different state (options, game, exit).

Share this post


Link to post
Share on other sites

This topic is 4053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this