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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:21:57+00:00 2026-06-18T04:21:57+00:00

I am trying to create a game with multiple levels (10 at the moment).

  • 0

I am trying to create a game with multiple levels (10 at the moment). I create a class for each level however this would be very, very tedious if more levels were to be added. My question is, how can I reuse a layer/class to have all levels of the game? The only difference for each level is the number of targets and the positions of the targets. Other than that, everything is pretty much the same.

  • 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-06-18T04:21:58+00:00Added an answer on June 18, 2026 at 4:21 am

    Make a class called something like LevelLayer which implements all of the logic from one of the levels. Now, create a new class called Level1Layer which implements LevelLayer.

    Now progressively move code that is specific to level1 from LevelLayer into Level1Layer until LevelLayer contains only code that is useful to all levels.

    Now create a Level2Layer that inherits from LevelLayer. Note that suddenly most of the code for this level is already done and can be called via the methods on the base class (LevelLayer).

    By doing this iteratively you end up with a base class (LevelLayer) which consolidates all of the code to do with being a generic level, with the specific code for each level being hived off in a class corresponding to the particular level.

    Note that after a while you should have gotten to a point where code that both level1 and level2 needs is in LevelLayer, and code and data that only level1 needs is in Level1Layer and code that only level2 needs is in Level2Layer.

    After a while you may find that all of the levels differ only by a particular data item (e.g. an int array containing the map). In this case you may want to create a class that takes this data item via the constructor (or deserializes it from a file, the path of which is supplied to the constructor) which implements LevelLayer.

    At this point you will be able to spend most of your time editing the data files (the “level” files) rather than code.

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

Sidebar

Related Questions

I'm trying to create a game similar to this (Note:When you click 'play', there
In this game, I am trying to have multiple lasers spawn at given coordinates,
I am trying to create a Flash application(more like a game) where a user
I am trying to create a game on the iPhone, however I am running
OK so at the moment I am trying to create an Android Game, I
So, im trying to create a pacman game in SFML, i created a class
I am trying to create a game for iPhone, iPad and Android in unity3d.
I'm trying to create a game save system which involves saving a score for
I am trying to create a game server, and currently, I am making it
I'm sort of new to c++ and i'm trying to create a game. I

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.