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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:02:35+00:00 2026-05-25T10:02:35+00:00

I have a game using the LWJGL and Slick2D made in Java. I recently

  • 0

I have a game using the LWJGL and Slick2D made in Java. I recently added this code to get if a pixel is empty:

for (Entity e : onscreenents)
    if (e.getBlockID() == 1 || e.getBlockID() == -2)
        for (int x = e.getX(); x < e.getX() + 18; x++)
            for (int y = e.getY(); y < e.getY() + 18; y++)
                if (x > 0 && y > 0 && x < empty.length && y < empty[x].length)
                    empty[x][y] = false;

This code seems to run fine in the Run mode of Eclipse but when I start the program in the Debug mode of Eclipse, the game runs really slowly and is very glitchy. Removing this block of code makes the debug mode run as smooth as the Run mode.

Does anyone know why this is happening and if it is my fault or not? It would really help 🙂

  • 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-25T10:02:36+00:00Added an answer on May 25, 2026 at 10:02 am

    These may help:

    Speeding up Tomcat in debug mode with Eclipse IDE

    Why does Java code slow down in debugger?

    Why does the debugged program slow down so much when using method entry debugging?

    If you really do need performance improvements, then bmargulies comment is valid. Try moving the invariants out of the loop(s) so they are only calculated once.

    So move e.getX() and e.getY() calls above the for loops so they are called only once and save them in local vars. Same with empty.length (if these doesn’t change with each loop iteration that is).

    And possibly even save empty[x] into a local variable as array item dereferencing is slower than local variable access.

    You also do a test for x>0 and y>0. If you’re only interested in +ve values, then you could test e.getX()+18 and e.getY()+18 to see if they are +ve before the loops, as you may not even have to perform them. (e.g. if e.getX()+18<=0 you don’t have to do the x loop. Same for y)

    Beware of premature optimisation though.

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

Sidebar

Related Questions

I have a java game using lwjgl and slick-util. It works perfectly on my
I have made a multiplayer game using the GameKit Framework where 2 iPhones/iPods can
I have a game site developed using flash and php. The php code contains
I have made a game using HTML5 Canvas Element, Javascript for facebook. You can
I have made a snake game using javascript and HTML5 Canvas element. It can
i have made a game using html5 , now i want users to put
I'm developing a game in Java using LWJGL. Along with the main game, I'm
I have my own game engine using C++ and OpenGL, but I have models
I have a simple tank wars style game using the allegro open source library.
I'm working on a game (using Ruby) and planning to have it available in

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.