Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6033159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:26:35+00:00 2026-05-23T05:26:35+00:00

I am making Pong using C++ and OpenGL using Visual Express 2010. It is

  • 0

I am making Pong using C++ and OpenGL using Visual Express 2010. It is one of the first games I have made, and I am wondering how to best structure it. The main part that is stumping me is the game menu. Should I put the different game modes in different functions, and have a switch in my main function? For example, in Main.cpp, I would include the line

glutDisplayFunction(maincode)

In another file, I would define maincode as something like such (again, psuedocode):

maincode():
    switch m:
       case 1:
           singleplayer = true
           multiplayer = false
           menu = false
       case 2:
           singleplayer = false
           multiplayer = true
           menu = false
       case 3:
           singleplayer = false
           multiplayer = false
           menu = true

I would then, in each file, check to see the values of singleplayer, multiplayer, and menu to determine which mode I am in, then display code accordingly.

However, I get the feeling that this method would get much more complicated as the game gets more complicated, so I don’t think this is the proper way to do it.

How should I structure the game and menu?

P.S. I am a C++ programmer for a living, but I just don’t have experience programming games.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:26:36+00:00Added an answer on May 23, 2026 at 5:26 am

    It’s just unnecessary complexity to have 3 distinct bools (totaling to 8 different states, 3 of which would be valid) when the only information you need is which mode you are currently in.

    Better use an enumeration, i.e.

    enum GameMode {
    
      GM_SinglePlayer, GM_Multiplayer, GM_Menu
    
    };
    

    and a single variable of type GameMode:

    GameMode mode;
    mode = GM_Menu;
    

    Having different, mutually exclusive (that’s the point that you missed here!) states to switch in between is an important concept in programming, so you are definitely on the right track. Keep working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While making a little Pong game in C++ OpenGL, I decided it'd be fun
Making my first steps with NHibernate, I'm trying to have it creating my Tables
I'm making another Pong clone using HTML5 canvas and JavaScript. The problem I'm having
I've run into an odd problem in a pong/brick-breaker game I'm making: one of
Making a 2D OpenGL game. When rendering a frame I need to first draw
Making my first Adobe Air app and was wondering if their was a fullscreen
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
I am making a Pong clone and I am treating my variables in this
Making a mobile friendly site, I have a single field and a submit button.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.