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

  • Home
  • SEARCH
  • 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 7534809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:07:33+00:00 2026-05-30T06:07:33+00:00

In my game project I am using MVC scheme. Model and View are completely

  • 0

In my game project I am using MVC scheme. Model and View are completely separated. View is driven by observer pattern. So when something happens on game entity(create, destroy, update,…) view will be notified thru listener. When new entity in model is allocated then i need to create proper viewmodel(EntityMesh).

  • EntityMesh is base for viewmodel
  • Game::Entity is base for model

for this example model derivation tree looks like this:

  • Game::Entity -> Game::PhysicalEntity -> Game::PhysicalGridEntity
  • Game::Entity -> Game::ActorEntity -> Game::FreeActorEntity

This is how i currently “solve” this problem…but in future i expect 30+ derivatives of Game::Entity and EntityMesh. And this is very ugly and non OOP design.

EntityMesh* WorldView::_translate(Game::Entity* const ent)
{  
    //TODO: finish translator...
    std::cout << "TRANSLATING!: " << typeid(ent).name() << std::endl;

    Game::PhysicalGridEntity* pgent = dynamic_cast<Game::PhysicalGridEntity*>(ent);
    if(pgent)
    {
        std::cout << "CREATING: PhysicalGridEntity" << std::endl;
        return new PhysicalGridEntityMesh(this, pgent);
    }
    else
    {
        Game::PhysicalEntity* pent = dynamic_cast<Game::PhysicalEntity*>(ent);
        if(pent)
        {
            std::cout << "CREATING: PhysicalEntity" << std::endl;
            return new PhysicalEntityMesh(this, pent);
        }
        else
        {
            Game::FreeActorEntity* faent = dynamic_cast<Game::FreeActorEntity*>(ent);
            if(faent)
            {
                std::cout << "CREATING: FreeActorEntity" << std::endl;
                return new FreeActorEntityMesh(this, faent);
            }
        }
    }

    return NULL;
};

any idea how to make this more clear and more OOP without mixing View and Model?

EDIT: Any hint what pattern to use would help 🙂

  • 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-30T06:07:35+00:00Added an answer on May 30, 2026 at 6:07 am

    First of all, you don’t have a controller component. Where is you business logic that connects model and view? Second, I’m not sure what you are trying to do with all these ifs, but maybe factory/visitor patterns will help you.

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

Sidebar

Related Questions

I am using SDL for the view parts of my game project. And I
I'm considering using Django for a project I'm starting (fyi, a browser-based game) and
I'm thinking about using PhysicsFS in my game engine project, but I'd like to
I am working on a game project using Microsoft XNA framework, although this question
I'm writing a platform game for my university project using the canvas element and
I'm working on an XNA game and I am using ViewPort.Project and ViewPort.Unproject to
I am working on a little pinball-game project for a hobby and am looking
We have a Silverlight 2 project (game) that will require a lot of character
I trying to complete a RPG game for a project, but have no idea
I have a game code (from ioquake3 project) that compiles part of gameplay binaries

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.