Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Slick2D on a JPanel


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 minibutmany   Members   -  Reputation: 1674

Like
0Likes
Like

Posted 23 December 2012 - 09:23 AM

Hi,

I'm working on a 2D platform game. I was foolish and used java2d graphics, but now that I face some slight performance issues I want to move over to Slick instead. The way that I have it set up is a JPanel on it's own thread is constantly updating graphics while the JFrame that it sits upon handles keypresses, and has the main game loop. I only want to re-write the rendering class for slick, but keep the rest of my code the same. How do I get slick to act like java 2d and paint to a JPanel?

Would It be easier to just reformat my whole project to work with Slick windows?


Edited by minibutmany, 23 December 2012 - 09:31 AM.

Stay gold, Pony Boy.

Sponsor:

#2 PsychotikRabbit   Members   -  Reputation: 171

Like
0Likes
Like

Posted 23 December 2012 - 05:49 PM

Slick does provide a render, update and init method in the BasicGame class. In the render method there is two given parameters (GameContainer gc, Graphics g). The Graphics object seems to provides similar drawing method as java2d graphics. I beleive you can adapt easily your rendering class to use Slick 2D engine with that Graphics.

Here's an example of how to draw a rectangle in the Slick2D engine :

 

public void render(GameContainer gc, Graphics g) throws SlickException {
        g.drawRect(0,0,20,20);
    }





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS