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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:03:58+00:00 2026-06-13T18:03:58+00:00

I am writing a game in Java which is based on a grid top

  • 0

I am writing a game in Java which is based on a grid top down view. I am not very familiar with the JPanel paintComponent() and repaint() methods and I am having trouble creating a fast screen painting function.
Each tile is an object with a Tile.paintTile(g,x,y) to paint the tile at (x,y) on g. I want to find a nice way to paint only specific tiles, however I cannot find out how to do this.
I have a World class with a TileAt(x,y) to get the tile, but every attempt I have made has caused stuttering or thrown errors.
Any help is appreciated!
-Renmusxd

edit: what I tried:
I am not very used to Java graphics yet, I tried overwriting paintComponent and adding paintComponent(g,x,y) but it doesn’t like my not calling repaint. I no longer have the code because I substituted it with a paintAll version. Sorry.

  • 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-13T18:03:59+00:00Added an answer on June 13, 2026 at 6:03 pm

    Normally it is easier to just repaint the entire screen every time – this should be fast enough using Swing on most modern machines.

    If you really want to do partial updates, then the best approach is probably:

    • Create an offscreen BufferedImage, which should be the same size as your game display area (or slightly larger if you want to allow for scrolling)
    • Draw your tiles into this offscreen image.
    • When you repaint your view (i.e. in the paintComponent method) then just draw the whole bufferedimage onto the screen in one go.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a very basic Java game based on the idea of Theme
I am writing a game server for a turn-based game in Java. These are
I'm in a very early stage of writing a small music/rhythm game in Java
I am working on a tile based, top-down 2D game with dinamically generated terrain,
I'm writing a 2d Top-down RPG using the LWJGL alongside with Java 1.6. By
I'm writing a MUD (text based game) at the moment using java. One of
I am writing a game in Java, and need to have mouse interaction. I
So I am writing a game in Java, and I started out using the
I am writing a card game in java where I need to spread cards
I'm writing a simple game in Java and are trying to get the coordinates

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.