Jump to content

View more

View more

Image of the Day

Triangles!  
(Mostly)
#jimmyandthepulsatingmass #screenshotsaturday #screenshot #rpg #rpgmaker https://t.co/6Kch8UgOcw
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Slick2D on a JPanel

2: Adsense

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   

1998
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.

#2 PsychotikRabbit   Members   

175
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.