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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:20:33+00:00 2026-05-27T15:20:33+00:00

I hope this makes sense. I’m using Java with the Slick2d library, that probably

  • 0

I hope this makes sense.
I’m using Java with the Slick2d library, that probably doesn’t matter though.

My problem is, I’m trying to render multiple rectangles and strings from the same sub class, but when I do, only the last one actually renders.

Here the code in my Entity class:

public class Entity {

    public static String name;
    public static int health, x, y;

    public Entity(String n, int h, int posx, int posy) {
        name = n;
        health = h;
        x = posx;
        y = posy;
    }

    public static void render(Graphics g) {
        g.drawString(name, x-20, y-16);
        g.drawRect(x, y, 16, 16);
    }

}

And here is how I’m trying to call it from my main class:

public void render(GameContainer gc, Graphics g) throws SlickException {
        new Entity("Monster1", 100, 400, 200);
        new Entity("Monster2", 100, 500, 200);
        Entity.render(g);
}

What am I doing wrong? Please keep in mind I’m still new to java, so it will most likely be a really obvious problem.

  • 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-27T15:20:33+00:00Added an answer on May 27, 2026 at 3:20 pm

    problem is that you should not use the static variable modifier. Remove it in all three places within the entity class and then use your new entity class as follows.

    Entity m1 = new Entity("Monster1", 100, 400, 200);
    m1.render(g);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this makes sense... It doesn't only apply to c#, but that is
Hope this makes sense, I am using Titanium mobile to build an iPhone app.
I hope this makes sense. I have a Windows Phone 7 app that is
I hope this makes sense. I have a ASP.NET web application that uses Entity
Hope this makes sense... Is there a simple way to return a set of
I am just getting started with expression trees so I hope this makes sense.
hope to get some help here because this is something that really makes me
I hope this makes sense. I have created several WPF User Controls. The lowest
i hope this makes sense for you, i get confused. let me know if
I have an issue with jQuery and Safari (5.03). Hope this makes sense. I

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.