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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:47:32+00:00 2026-05-31T11:47:32+00:00

Another quick question if anyone is up to it. I have this code: for(int

  • 0

Another quick question if anyone is up to it. I have this code:

        for(int cy = 0; cy < 3; cy++) {
            for(int cx = 0; cx < 3; cx++) {
                for(int y = 0; y < 16; y++) {
                    for(int x = 0; x < 16; x++) {
                        g2D.drawImage(Tiles.tileImages.get(C0.chunk[x][y][cx][cy]), 
                                C0.cX[cx][cy] * cspcr + (blckspcr * x) + width - pXspcr,
                                C0.cY[cx][cy] * cspcr + (blckspcr * y) + height - pYspcr + (int)(24.25 * zoom),
                                    blckspcr, blckspcr, null);
                        if(C0.chunk[x][y][cx][cy].equals("a05")) {
                            g2D.drawImage(Tiles.treetop, 
                                    C0.cX[cx][cy] * cspcr + (blckspcr * x) + width - pXspcr,
                                    C0.cY[cx][cy] * cspcr + (blckspcr * y) + height - pYspcr + (int)(24.25 * zoom) - blckspcr,
                                    blckspcr, blckspcr, null);
                        }
                    }
                }
            }
        }

but my problem is, it creates an incredibly large amount lag in my application. Is there any way where I could avoid using the large amounts of loops I have or possibly speed it up? The image it is drawing first is grabbing blocks from chunks in a 4D array of strings and gets images from a hashmap based on the string and then it draws the image using a bunch of numbers. If anyone can help I would greatly appreciate it. Thanks!

  • 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-31T11:47:33+00:00Added an answer on May 31, 2026 at 11:47 am

    You need to store your data in a different way (a 4D array is almost always a bad idea).

    You can begin replacing those 4D array of strings by maybe a hash if its fits your usecase (then you’d only have one loop).

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

Sidebar

Related Questions

Another quick question here, I have this code: string sa[6] = { Fort Sumter,
Another question related to this one . I have a List<SortableObjects> that is the
I have a quick question about Java synchronization. Please assume the following code: public
Quick question regarding EventHandlers in C#, let's say we have the following code: MyObject.MyEventHandler
I have another quick question about SQLAlchemy. If I have added a query_property [1]
Quick question I currently have a small bit of code that is pulling comments
Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
Another basic Rails question: I have a database table that needs to contain references
Hey guys, quick question, I have a link when clicked drops down a list.
another quick question, I want to make simple console based game, nothing too fancy,

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.