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 7036011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:22:22+00:00 2026-05-28T01:22:22+00:00

I am programming the game Battleship in OpenGL(GLUT) and C++. I know how do

  • 0

I am programming the game Battleship in OpenGL(GLUT) and C++.

I know how do to the graphics stuff (like displaying the field and predefined ships),
but where should I put my game code like:

  • if key left pressed select one field left and display it
  • if a ship is placed then display the ship

Things like place a ship (switching between the fields) I can’t do in the display() function, but if a ship is placed it must be drawn by the display() function, right?

I don’t know where to put the game logic.

  • 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-28T01:22:23+00:00Added an answer on May 28, 2026 at 1:22 am

    What you are looking for is the basic, classic game loop. Effectively, your game runs in one giant loop. In this loop, you handle user input, react to the user input, run AI, and update the video/audio in response. This is, of course, a very simplified take on it, but it will suffice for Battleship.

    Conceptually, more or less:

    while(Game.IsRunning)
    {
        Input = GetInput();
        Game.Update(Input);
        Display(Game);
    }
    

    If you’re actually doing real-time as opposed to event-driven, then you need to make your updates take into account the time-passed since the last update, as well as player input. I’ll keep this short and limited to what you’re asking though.

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

Sidebar

Related Questions

I'm programming this game in OpenGL, mostly working inside an single EAGLView (I'm not
LATER EDIT: Please mention not only game programming books, but also more scientific/simulation oriented
Hello everyone I am interested in Java game programming, but I want to do
I'm new to game programming..What I want to achieve is an effect like bubbles
10 years ago I did some game programming and used OpenGL for the 3d
I'm fairly new to game programming (but not to programming) and I want to
Possible Duplicate: Game programming on Objective-C and linux I know that developing iPhone apps
I'd like to give Objective-C a try in game programming. The problem is I'd
For a multi-player programming game, I'm working on a background compilation server for Scala
I am programming a game using Visual C++ 2008 Express and the Ogre3D sdk.

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.