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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:52:49+00:00 2026-06-13T12:52:49+00:00

I am trying to do some tests on 2D game-programming by trying out different

  • 0

I am trying to do some tests on 2D “game”-programming by trying out different concepts to approach both designing and visualizing the environment.

In my baby-steps I went to go with Swing and using a JComponent’s paintComponent() method to retrieve a Graphics2D object that I then use to visualize my game board.

It works quite well but I got to the point where I need to repeatedly check my whole game-model and update the view, basically once every 1/10 second something can change.

I paint the visuals by calling repaint() on my JComponent to cause a complete update of the view: I check every tile my game board has for information and paint that tile according to this data, for every tile on the board. But as I approach about 1000 – 4000 tiles that need to be painted, I come to the point where the painting of the whole view takes more than 100ms and thus a constant lag occurs when doing anything.

Now for the question(s): I am looking for a way, or opinions, on how to improve the performance of this approach. As not every tile on the board changes every “tick” I do not need to “repaint” this tile. But on the contrary, moving the visual area (camera offset) changes the position of every tile on the screen, so it would need to be repainted at a different position. Also, the later implementation of “would be” animations would need a constant update of the visual area, regardless of “happenings” or not. When looking at 3D games with high quality graphics (or even simple ones like minecraft) running at > 30 FPS, I am wondering weather or not I should immediately switch to OpenGL before running into even more problems graphics wise, or are there ways to improve the performance with algorithms checking for the right kind of changes both in the view and the model?

  • 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-13T12:52:50+00:00Added an answer on June 13, 2026 at 12:52 pm

    Declare a 2 dimensional array of boolean for each tile, and an int variable keeping constants of the change, updating them on every change, e.g.:

    public void updateTiles(){
    
        if(changeType == NO_CHANGE){
            //do something
        }
        else if(changeType == BOARD_MOVED){
            repaint();
        }
        else if(changeType == TILE_CHANGED) {
            for(int i = 0; i < changeList.length; i++) {
                for(int j = 0; j < changeList[i].length; j++) {
                    if(changeList[i][j]) {
                        repaint(i * TILE_SIZE, j * TILE_SIZE, TILE_SIZE, TILE_SIZE );
                        changeList[i][j] = false;
                    }
                }
            }
        }
    
        changeType == NO_CHANGE; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying some multiplayer game ideas out at the moment and am trying to
I'm trying to test out some different methods of drawing to a Canvas, without
I'm trying to retrofit some tests using Test::More to legacy code and I've bumped
Im trying to write some unit tests for a couple of merthods that are
I'm trying to write some Mspec tests against some EF4 objects. However they are
I'm trying to run some unit-tests for NxBRE before I start referencing it's implementation
I am trying to write some unit tests and I was wondering if there
I am trying to write some integration tests for some SQL server stored procedures
At the moment I'm trying to build some integration tests for an android project.
I develop some unit tests with trying to connect to the Derby internal database

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.