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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:38:18+00:00 2026-05-26T06:38:18+00:00

I’m building a small video game. I’m trying to do good oop/design. I have

  • 0

I’m building a small video game. I’m trying to do good oop/design.

I have a map object and a camera object. These are both created in the ‘world’ object.

There is a problem though. In the map I render and update everything. For performance reasons I only want to update/render what is only on the player’s screen.

The camera object has this information – but the map object can’t get to it.

There is a couple ways I could get this information, but wanted to get an option on how to do it.

  • 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-26T06:38:19+00:00Added an answer on May 26, 2026 at 6:38 am

    The OO principle that is probably most pertinent here is the Single Responsibility Principle.

    Consider these statements of responsibility:

    • The Map object is responsible for holding the layout of the world
    • The Camera object is responsible for maintaining a viewpoint that is used to observe the world

    Given that, having the Map be responsible for rendering what’s on-screen is clearly outside its jurisdiction.

    You should probably have a WorldRenderer, which should take in both a Map and a Camera in order to render a screen.
    While we’re on the subject of good design, you might also want to make the WorldRenderer immutable in nature – it will take in a Map and Camera upon construction, and from that point on, those references can’t be changed, e.g.:

    public class WorldRenderer {
        private final Map map;
        private final Camera camera;
        private final List<LightSource> lightSources;
    
        public WorldRenderer(Map map, Camera camera, List<LightSource> sources) {
            this.map = map;
            this.camera = camera;
            this.lightSources = sources;
        }
    
        public void render() {
            Viewport viewport = camera.getViewport();
            Map submap = map.getVisibleMapFor(viewport);
            Scene litScene = applyLighting(submap); // using lightSources
            renderScene(litScene);
        }
    
        private void renderScene(Scene scene) {
            ...
        }
    }
    

    … you might have noticed that the example provides some light sources as well. Again, that’s using SRP to decouple the rendering process from its component elements.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.