Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [LWJGL][Slick2d] How can I combine the forces?  (Read 719 times)
0 Members and 1 Guest are viewing this topic.
Offline Jacob Pickens
« Posted 2014-05-16 21:22:30 »

Rayvolution has found a nice way to get the best of both worlds when it comes to LWJGL and Slick2D. How can you combine LWJGL with Slick2D? How can you use the simplicity of slick with LWJGL?

I'd like to keep the simplicity of Slick rendering to an extent but have the extra features that LWJGL brings to the table. Is that possible?
Online BurntPizza
« Reply #1 - Posted 2014-05-16 21:25:55 »

If you have a project setup in eclipse with slick, just type "import org." and the autocomplete shows all the lwjgl packages. They're included with slick, you use them like anything else. Why is this a question?
Offline Jacob Pickens
« Reply #2 - Posted 2014-05-16 21:27:28 »

I honestly didn't know. Tongue Does any of it interact with say the Image class in slick? I figure since slick is built on lwjgl it will work but...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Rayvolution

JGO Kernel


Medals: 208
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #3 - Posted 2014-05-16 21:38:01 »

I honestly didn't know. Tongue Does any of it interact with say the Image class in slick? I figure since slick is built on lwjgl it will work but...

When you're in eclipse and you select what to "import", just make sure you pick slick's Image library, and not LWJGL's. As far as using both Slick and LWJGL's side by side in the same class, I'm honestly not sure how you'd go about that. (But I'm also not entirely sure why you'd want to. Tongue )

(EDIT: Just realized I'm a dummy, LWJGL doesn't have an Image class in the first place, so this situation would never happen. My guess is the closest LWJGL equiv. is probably one of the "Texture" classes, but I'm unsure.)

Really though most of the stuff you'd want to access in LWJGL is probably the static getters/setters like GL11.glBlendFunc() and Display.getWidth()/Height(), Slick does a pretty decent job of wrapping everything else LWJGL does (for 2D games anyway).

I'd be careful though, because you may find yourself doing things directly in LWJGL that Slick can already handle, and while there's really nothing wrong with doing it, it may make your code really confusing if you have several classes mixing and matching LWJGL and Slick2d together. I really try to avoid using LWJGL directly as much as I can personally. I only go to LWGJL if I absolutely can't do it in slick2d, like my resizable window (while the game is running) that Slick doesn't support for some odd reason.

My advice would be to exhaust all options of doing it in Slick2d before you go to LWJGL, you'll be surprised to find out that Slick (as well as LibGDX) can handle a lot of very specific aspects of LWJGL. Of course, I guess the plus side is learning LWJGL instead is probably massively more beneficial than Slick2d or LibGDX in the long run. But most of what you'll be doing is LWJGL is just boilerplate stuff Slick/Lib do anyway.

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline Jacob Pickens
« Reply #4 - Posted 2014-05-16 21:40:13 »

Ok to be honest, all I want to do is 2D lighting and shadows and those sexy blendy things that puppygames does. How and what do I use to do that?
Online BurntPizza
« Reply #5 - Posted 2014-05-16 21:47:00 »

Ok to be honest, all I want to do is 2D lighting and shadows and those sexy blendy things that puppygames does. How and what do I use to do that?

Google around for "lwjgl 2d shadows" and "lwjgl additive blending." We have told you these terms before.
Offline Rayvolution

JGO Kernel


Medals: 208
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #6 - Posted 2014-05-16 21:53:08 »

Ok to be honest, all I want to do is 2D lighting and shadows and those sexy blendy things that puppygames does. How and what do I use to do that?

That's where GL11 comes in. This code doesnt support colored lighting, it's just for basic alphamap lighting, but it'll get you going in the right direction.

It's a blend of Slick2d and LWJGL.

1  
2  
3  
4  
5  
6  
7  
   g.clearAlphaMap(); //Clear the AlphaMap in Slick2d
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); //Set drawing suitable for alpha maps
  lightSky.draw(0,0,lightLevel); //Huge black image that covers your entire screen, lightLevel is a Color() that changes alpha levels (IE: Color(1f,1f,1f,0.5f) is half opacity);
  //LIGHTS YOU WANT TO RENDER HERE. All lights should be BLACK where you want the light to be and TRANSPARENT everywhere else
  GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_DST_ALPHA);
   g.fillRect(0, 0, Display.getWidth(), Display.getHeight()); //Cover the whole screen with a black rectangle
  g.setDrawMode(Graphics.MODE_NORMAL); //draw mode reset in Slick2d.


Note: under fillRect you probably want to make your own int variables that are set to Display.getWidth/Height instead. That'd be a more proper way of doing it.

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline AppleSauce
« Reply #7 - Posted 2014-05-19 02:57:13 »

I'm mainly using lwjgl. Could I download the full slick2d jar and use the gamestates, along with the lwjgl rendering? That would make certain tasks very easy.
Online BurntPizza
« Reply #8 - Posted 2014-05-19 03:44:00 »

I'm mainly using lwjgl. Could I download the full slick2d jar and use the gamestates, along with the lwjgl rendering? That would make certain tasks very easy.

Yes.                                     


Offline Rayvolution

JGO Kernel


Medals: 208
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #9 - Posted 2014-05-19 04:29:25 »

I'm mainly using lwjgl. Could I download the full slick2d jar and use the gamestates, along with the lwjgl rendering? That would make certain tasks very easy.

Yes.                                     




Hell, you could probably use LibGDX and Slick2d together if you wanted (why, I have no idea).

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline AppleSauce
« Reply #10 - Posted 2014-05-19 13:20:00 »

REALLY! I had no idea. I thought lwjgl was just lwjgl and you could only use slick_util textures. Thanks a bunch! Grin
Online BurntPizza
« Reply #11 - Posted 2014-05-19 13:48:56 »

REALLY! I had no idea. I thought lwjgl was just lwjgl and you could only use slick_util textures. Thanks a bunch! Grin

LWJGL is just openGL + java to interface with it, slick and libGDX are both LWJGL + more stuff on top.
(Technically libGDX also has a JOGL backend, but LWJGL is usually preferred)
Offline AppleSauce
« Reply #12 - Posted 2014-05-20 14:04:53 »

Could I use slick to load images by doing somthing like
1  
img = new Image("res/theimg.png");
?
Can I also use the gamestates from slick when coding in lwjgl?
Offline Rayvolution

JGO Kernel


Medals: 208
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #13 - Posted 2014-05-20 17:40:06 »

yes, and yes.

Although I personally feel you should use one or the other, using both is kinda awkward. Really, even though Slick2D is "dated" people have the misinformation that makes it inferior (I blame the young mentality of "It's old so it's junk, only new things are good!"). Keep in mind though, you can't just slap LibGDX on top of Slick and make an awesome game. If anything, that will just over complicate the process and make things worse for you.

That would be like trying to make a car run with a diesel and gasoline engine at the same time. Can you do it? Probably with enough work.. but why would you? Just pick the one that has the benefits you want (Lib's More native Android support, or Slick's StateBasedGame support for example) and go with it!

My reasoning for sticking with slick is I know enough programming to force slick to do what I want anyway, and I love it's StateBaseGame system. I also have no plans what so ever to get into the mobile market, so Lib's native android support is irrelevant to me.

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!