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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:44:34+00:00 2026-06-11T13:44:34+00:00

I am using slick for java since a few days and got a serious

  • 0

I am using slick for java since a few days and got a serious problem.
If i run a completely empty apllication (it just shows the fps) with a solution of 800×600 i get a fps count between 700 and 800.
If I now draw an array with 13300 entries as a grid of green and white rectangles, the fps drop to something around 70.

With more entries in the array it becomes really slow.
For example in a solution of 1024×768 and an array with 21760 entries the fps drop to 40.

How i draw a single entry:

public void draw(Graphics graphics){
    graphics.setColor(new Color(getColor().getRed(), getColor().getGreen(), getColor().getBlue(), getColor().getAlpha()));

    graphics.fillRect(getPosition().x, getPosition().y, getSize().x, getSize().y);

    Color_ARGB white = new Color_ARGB(Color_ARGB.ColorNames.WHITE);
    graphics.setColor(new Color(white.getRed(), white.getGreen(), white.getBlue(), white.getAlpha()));
}

And this is how I draw the complete array:

public void draw(Graphics graphics) {
    for (int ix = 0; ix < getWidth(); ix++) {
        for (int iy = 0; iy < getHeight(); iy++) {
            getGameGridAt(ix, iy).draw(graphics);
        }
    }
}

In my opinion 21760 is not that much.
Is there anything wrong with my code or is slick just too slow to draw so much rectangles?

  • 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-11T13:44:36+00:00Added an answer on June 11, 2026 at 1:44 pm

    You only want to draw rectangles that are on the screen. If your screen bounds go from 0 to 1024 in the x direction and from 0 to 768 in the y direction, then you only want to loop through rectangles that are inside those bounds and then only draw those rectangles. I can’t imagine you are trying to draw 21760 rectangles inside those bounds.

    If you are, then try creating one static rectangle and then just try drawing that ONE in all of the different positions you need to draw it at rather than creating a new one every time. For example, in a game I am making, I might have 1000 tiles that are “grass” tiles, but all 1000 of those share the same static texture. So I only need to reference one image rather than each tile creating its own.

    Each rectangle can still have a unique state. Just make your own rectangle class and have a static final Image that holds a 5*5 image. Each rectangle will use this image when it needs to be drawn. You can still have unique properties for each rectangle. For example, private Vector2f position, private boolean isAlive, etc

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

Sidebar

Related Questions

I've been using the following web development stack for a few years: java/spring/hibernate/mysql/jetty/wicket/jquery For
I just started using MigLayout for SWING in Java and I'm really liking it
I'm using the Slick java game lib and I've used the Slick implementation of
I'm attempting to play with graphics using Java/Slick 2D. I'm trying to get my
How to export to runnable java file with eclipse using slick and lwjgl (Light
I have a java game using lwjgl and slick-util. It works perfectly on my
It's been a couple of years since I've done any Java work, my last
I've just started using maven for trying to build a multi module project. Everything
i want to protect my Java product by using some USB-based authentication and password
I have an XML file which stores content which is displayed using a Java

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.