Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Organized Structure of Rendering in Different Game "States" (LWJGL)  (Read 5391 times)
0 Members and 1 Guest are viewing this topic.
Offline nhmllr

Senior Member


Medals: 1
Projects: 3


slow and steady...


« Posted 2012-06-01 05:23:38 »

Hello! I am very new

There are three game "states" (stored as an enum) in my game. The overworld (where the player walks around) the battlescreen (where the player fights enemies) and the inventory
I am trying to organize this as nealty as possible

In my "GameDisplay" class (which makes the game window, which I have successfully done) I made a method called "render()" which is called in the game loop

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
private void render()
   {
      switch(state)
      {
      case OVERWORLD:
         overworld.render();
         break;
      case BATTLESCREEN:
         battlescreen.render();
         break;
      case INVENTORY:
         inventory.render();
         break;
      }
   }


I like to think that I can handle each state in a separate class/object, but I'm not sure I can. I just tried to load textures
 Here is the "overworld" class

Here it is:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
public class Overworld {
   
   private int[][] dungeonMap;
   
   public Overworld()
   {      
      final Texture blueWallTex = loadTexture("BlueWall");

      DungeonGenerator dungeonGenerator = new DungeonGenerator(10,20,3);
      dungeonMap = dungeonGenerator.getDungeonMap();
   }
   
   public void render()
   {
      //to be implemented
  }
   
   private Texture loadTexture(String key)
   {
      try
      {
         return TextureLoader.getTexture("PNG", new FileInputStream(new File("res/"+key+".png")));
      } catch (FileNotFoundException e)
      {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }
     
      return null;
   }

}


I shouldn't have a problem so early on in the coding process, but I do.
The program spits a stack trace back at me, specifically:

"Image based resources must be loaded as part of init() or the game loop. They cannot be loaded before initialisation."

Is there a way to combat this? I really want to handle each game "state" in a different class, but it won't seem to let me do that without creating a new display in each object, which seems silly.

Any ideas? Thank you
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-06-01 05:40:07 »

Exactly as the stack trace says, you cannot load images before OpenGL is loaded. You are loading the images in the constructor of your class.

Now I'm assuming you use Slick2D, so I suggest you create an init() method in all your states that you call from the init() method of your main class.

Offline davedes
« Reply #2 - Posted 2012-06-01 16:51:38 »

If you're using Silck2D, it has utilities for states and such.
If you're using only Slick-Util, and you want to do things from the ground up, then you'll need to write your own states. It's relatively simple to do with classes.

The basic idea:

Your Game class has a list of GameState objects, and keeps track of which one it's currently showing. Depending on your game, you may want to load all the state's resources during the init() of your game (like Slick2D). Or you might want to load and destroy resources as you enter/exit states (i.e. only keeping what's necessary in memory). The Game class simply renders/updates whatever current GameState is selected.

How you decide to organize this is up to you. Maybe you'll use enums? Or maybe you'll use generic objects, to allow for an infinite number of states?

Maybe you'll want a single game state to hold multiple "screens" -- i.e. an InGameState which holds different "screens" for each level, or a MainMenuState which holds "screens" for options, help, credits, etc. It all depends on the complexity of your game and how you'd like to implement it.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2012-06-01 17:36:05 »

Hi

Actually, I have already implemented something very similar, it looks like what davedes suggests but in more general as I use states to handle the weapons too. I use Fettle API which is really a tiny and simple API to create state machines. I don't directly store the states, I store the transitions between them. I can detect whether I enter a state or whether I get out of another one. Each time I go to another state, I hide all others and I show only this one. Each state is bound to a controller that updates the model (think about MVC) and renders the view(s). You can put some memory managements in transitions as davedes suggests, for example to destroy direct NIO buffers. I use a kind of task manager to handle the progress of loading, some states are then only used to display a progress bar and load all data for the next one. My source code does not explicitly rely a lot on a specific binding so you might be able to reuse it. If you already use Slick2D, you don't need my help, ra4king's suggestion is more appropriate in this case.

Offline nhmllr

Senior Member


Medals: 1
Projects: 3


slow and steady...


« Reply #4 - Posted 2012-06-01 21:11:10 »

A few things:
1. I've never touched init() ever, this is a application, not an applet, so I don't use init(), right?
2. I'm using Slick-Util and not Slick 2D, but I could install that if necessary
3. Which opengl initializations does it want? I've made another class that makes a blank window, and it uses these initializations

1  
2  
3  
4  
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,GameDisplay.DISPLAY_WIDTH,GameDisplay.DISPLAY_HEIGHT,0,1,-1);
glMatrixMode(GL_MODELVIEW);


But when I simply paste this in front of my texture-loading code (in the constructor or Overworld) I get a "null pointer exception" on "glMatrixMode(GL_PROJECTION)"

Is what I'm trying to do even possible? The Display is handled by a completely different class (the one that calls Overworld)

I don't know if it's necessary, but I'll paste that class here in case it's important
As is, it correctly makes a black window
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
public class GameDisplay {
   
   final static public int DISPLAY_WIDTH = 600;
   final static public int DISPLAY_HEIGHT = 400;
   
   //The states the game can be in
  /*private static enum State
   {
      OVERWORLD, BATTLESCREEN, INVENTORY;
   }
   private State state = State.OVERWORLD;*/

   
   //Making an object for each of the states the game can be in
  //Overworld overworld = new Overworld();
  //BattleScreen battlescreen = new BattleScreen();
  //Inventory inventory = new Inventory();
 
   //Constructor
  public GameDisplay()
   {
      try
      {
         Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH,DISPLAY_HEIGHT));
         Display.setTitle("Dungeon Crawler");
         Display.create();
      }
      catch (LWJGLException e)
      {
         e.printStackTrace();
      }
           
      //OpenGl Initializations
     glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(0,DISPLAY_WIDTH,DISPLAY_HEIGHT,0,1,-1);
      glMatrixMode(GL_MODELVIEW);
     
      //The Loop that runs the window
     while(!Display.isCloseRequested())
      {
         Display.update();
         Display.sync(30);
         
         //render();
     }
     
      Display.destroy();
   }
   
   /*private void render()
   {
      switch(state)
      {
      case OVERWORLD:
         overworld.render();
         break;
      case BATTLESCREEN:
         battlescreen.render();
         break;
      case INVENTORY:
         inventory.render();
         break;
      }
   }*/

}

Offline Sickan

Senior Member


Medals: 9



« Reply #5 - Posted 2012-06-01 21:19:44 »

If you haven't already, add to the rest of your imports. That should solve some of your problems.
1  
import static org.lwjgl.opengl.GL11.*;

You might want to set vsync on insted of using Display.sync().

So,
1  
2  
3  
4  
Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT);
Display.setTitle("Dungoen Crawler");
Display.setVSyncEnabled(true);
Display.create();

Then you can increase Display.sync() to somewhere higher than 60, like 75, to cover for computers that are a little older and don't support vsync.


1) The init() function should contain the code you need to initiate OpenGL and the display window. It has nothing to do with applets except naming the method the same.

2) If you want to use Slick2D you will have to discard all that code that you have there and follow the tutorials offered on the Slick2D website. Slick-util works fine for writing LWJGL applications, however.

Slick2D is easier and more Java2D like, but if you are a beginner in Java game programming you REALLY should just stick to Java2D.

3) You might also want to enable transparency with the following before the rest of your OpenGL initialization code.

1  
2  
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


Other than that it looks pretty good.
Offline nhmllr

Senior Member


Medals: 1
Projects: 3


slow and steady...


« Reply #6 - Posted 2012-06-01 21:47:19 »

That import had been there. It really just doesn't seem to want to accept the opengl initializations I put in the Overworld class (in the constructor)
(Also thanks for the vsync and transparency tips, I put them in)

Is there another way anyone knows of to separate the rendering of the display in different classes?
Offline davedes
« Reply #7 - Posted 2012-06-01 21:51:39 »

A few things:
1. I've never touched init() ever, this is a application, not an applet, so I don't use init(), right?
2. I'm using Slick-Util and not Slick 2D, but I could install that if necessary
3. Which opengl initializations does it want? I've made another class that makes a blank window, and it uses these initializations
1. Generally "init()" is a method you define that loads images, sounds, setups up orthographic projection, and so forth.
2. Slick-Util is a small subset of Slick2D. It's basically a couple of core classes extracted from the full library. If you want to keep learning OpenGL, stick with Slick-Util, or use another library like LibGDX. If your main goal is to just make a game, then you might find it easier to use Slick2D, LibGDX or another high-level library.
3. Game states has nothing to do with OpenGL initialization. It's just a matter of object-oriented design: moving what you have now (a switch statement) into classes.

You should also enable texturing: glEnable(GL11.GL_TEXTURE_2D) before rendering.

And regarding your game loop, it looks a little empty. Why 30 FPS cap? I'd suggest reading up on the basics:
http://www.koonsolo.com/news/dewitters-gameloop/
http://gafferongames.com/game-physics/fix-your-timestep/

Quote
but if you are a beginner in Java game programming you REALLY should just stick to Java2D.
Nah, I disagree. IMO Java2D is much harder to use than Slick2D for a beginner. And aside from the obvious performance gains of using Slick2D (OpenGL vs software rendering*) you also get a lot of features related to game development, which obviously Java2D does not include. Things like game states (hence this thread), Tiled integration, bitmap fonts, themable UIs, basic pathfinding utilities, OGG decoding/streaming, etc.

[size=8pt]* You can enable hardware acceleration in Java2D with a JVM switch. Unfortunately, it's unreliable -- some users report a decrease in performance, others report no change, etc.[/size]

Offline Sickan

Senior Member


Medals: 9



« Reply #8 - Posted 2012-06-02 08:28:40 »

Quote
but if you are a beginner in Java game programming you REALLY should just stick to Java2D.
Nah, I disagree. IMO Java2D is much harder to use than Slick2D for a beginner. And aside from the obvious performance gains of using Slick2D (OpenGL vs software rendering*) you also get a lot of features related to game development, which obviously Java2D does not include. Things like game states (hence this thread), Tiled integration, bitmap fonts, themable UIs, basic pathfinding utilities, OGG decoding/streaming, etc.
Slick2D has a lot of code that you don't understand until you've gained a bit more experience. Java2D, on the other hand, is simple and easy to understand from the start. Slick2D may have better performance, but it doesn't really matter at beginner stage. With Java2D, you just need some imports to be set up, but with Slick2D you have to download LWJGL, tell it where it has its natives, and then download Slick2D and install it. There are also a lot more tutorials on Java2D, compared to Slick2D which has only a handful to a dozen tutorials.

Overall Java2D is better for when you're just starting out.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #9 - Posted 2012-06-02 11:18:05 »

Quote
but if you are a beginner in Java game programming you REALLY should just stick to Java2D.
Nah, I disagree. IMO Java2D is much harder to use than Slick2D for a beginner. And aside from the obvious performance gains of using Slick2D (OpenGL vs software rendering*) you also get a lot of features related to game development, which obviously Java2D does not include. Things like game states (hence this thread), Tiled integration, bitmap fonts, themable UIs, basic pathfinding utilities, OGG decoding/streaming, etc.
Slick2D has a lot of code that you don't understand until you've gained a bit more experience. Java2D, on the other hand, is simple and easy to understand from the start. Slick2D may have better performance, but it doesn't really matter at beginner stage. With Java2D, you just need some imports to be set up, but with Slick2D you have to download LWJGL, tell it where it has its natives, and then download Slick2D and install it. There are also a lot more tutorials on Java2D, compared to Slick2D which has only a handful to a dozen tutorials.

Overall Java2D is better for when you're just starting out.
Exactly! This (and the reason that there are more graphical features in Java2D than Slick2D) is why I still say Java2D is the perfect beginner playground.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline deathpat
« Reply #10 - Posted 2012-06-02 12:02:38 »

Hi,

I think your problem here is that you instanciate your state classes in the attributes declaration which happens before the GameDisplay constructor is called ... you should do this in the GameDisplay constructor after the init of the Display instead.

so just declare your attributes :
1  
2  
3  
   private Overworld overworld;
   private BattleScreen battlescreen;
   private Inventory inventory;


and then in the GameDisplay constructor, instanciate them just before your game loop.

work in progress : D A E D A L U S
Offline nhmllr

Senior Member


Medals: 1
Projects: 3


slow and steady...


« Reply #11 - Posted 2012-06-02 15:19:52 »

Thank you! Looking back on it, it seems so obvious. I don't even need any opengl initialization code in the Overworld class

Thanks to everybody too, I'm looking into all of your suggestions
Offline davedes
« Reply #12 - Posted 2012-06-02 18:16:52 »

Java2D, on the other hand, is simple and easy to understand from the start. Slick2D may have better performance, but it doesn't really matter at beginner stage. With Java2D, you just need some imports to be set up, but with Slick2D you have to download LWJGL, tell it where it has its natives, and then download Slick2D and install it. There are also a lot more tutorials on Java2D, compared to Slick2D which has only a handful to a dozen tutorials.

Overall Java2D is better for when you're just starting out.
It all depends on what degree of "beginner" we're talking about here. Something simple like tic-tac-toe doesn't require a game loop, and in that situation I can understand Java2D/Swing.

But when it comes to sprite rendering and a game loop, things that even basic games (pong, space invaders, asteroids) will want to utilize, Java2D will only complicate a beginner's life.

Offline sproingie

JGO Kernel


Medals: 202



« Reply #13 - Posted 2012-06-03 16:18:52 »

I see beginners doing android games all the time, and that requires even more setup than LWJGL.  Seriously, adding a single native library is not the high barrier to entry people some people think it is.

One real problem with OpenGL development in general is the error messages, or the lack thereof.  Setup instructions really should be using the debug library for development (I'm guilty of this too, but the debug lib isn't even in maven repos, so I can't do much about it in my instructions).
Offline Sickan

Senior Member


Medals: 9



« Reply #14 - Posted 2012-06-04 18:29:25 »

I see beginners doing android games all the time, and that requires even more setup than LWJGL.  Seriously, adding a single native library is not the high barrier to entry people some people think it is.

One real problem with OpenGL development in general is the error messages, or the lack thereof.  Setup instructions really should be using the debug library for development (I'm guilty of this too, but the debug lib isn't even in maven repos, so I can't do much about it in my instructions).

The people who begin Java games with Android are probably writing a lot of code that they don't understand, just like those that start with Slick2D.

And no, adding a native library isn't much. But it's yet another step you have to make to set up your project to even BEGIN to write your code. And a lot of the motivation from writing games, at least for me, is the instant results.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #15 - Posted 2012-06-04 18:43:14 »

If enabling a single plugin or pasting in a pom snippet or configuring a system property sucks all the energy out of your project, your motivation is even more tenuous than mine.  Sorry, but I'd point at things like lack of good documentation as barriers to entry, not basic setup steps shared with nearly every other library in existence.

Offline Sickan

Senior Member


Medals: 9



« Reply #16 - Posted 2012-06-04 18:50:12 »

Okay, okay. Nevermind. The setup thing was a bad point.

I still think that Java2D is better for beginners than Slick2D, and so far you have only disproven my arguments without coming with any of your own.

I have to say that I'm happy I can even have this much of a discussion. There is no such thing on the Minecraft forums, except for things like how much $s graphic cards cost. And I'm not going to buy a new graphics card soon.
Offline davedes
« Reply #17 - Posted 2012-06-05 02:45:32 »

I still think that Java2D is better for beginners than Slick2D, and so far you have only disproven my arguments without coming with any of your own.
Ok then, let's use a practical example. I dare you to come up with something this simple and beginner-friendly without using Slick2D. Smiley

Task: Allow user to move a sprite smoothly across the screen at 60+ FPS -- if it hits the left or right bounds of the window then play a sound.

What does it test? Game loop, input handling, image loading/rendering, and sound loading/playback. All the functions you need to make a great 2D game.

Slick Code

Your turn. Smiley

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #18 - Posted 2012-06-05 02:47:59 »

How will a beginner learn how to make game loops with Slick2D? Boiler-plate isn't always bad you know. Java2D is super simple and beginner friendly yet forces them to learn basic structures.

I win. Let's end this argument. Grin

Offline davedes
« Reply #19 - Posted 2012-06-05 03:02:29 »

As a beginner, 99% of the game loops that you will be copy + pasting will go right over your head. Roll Eyes

Who cares if they don't learn game loops on their first game? They will learn it when they are ready -- assuming they even want to learn it! You can write games without having to learn how to write the perfect game loop, in the same way that you can use a JFrame without knowing exactly what is going on under the hood.

ra4king -- where is the "super simple" and "beginner friendly" Java2D code which produces the test I asked for? Wink

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #20 - Posted 2012-06-05 03:58:00 »

Enjoy: http://www.java-gaming.org/?action=pastebin&id=103 Smiley

Offline davedes
« Reply #21 - Posted 2012-06-05 18:19:55 »

No input handling. Tongue But even so, I'd say it proves my point -- Java2D is less beginner friendly.

You should post that to the "game loops" thread since the code examples there are lacking (yours is nice and compact, self-contained, uses proper game loop, and uses buffer strategy).

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #22 - Posted 2012-06-05 18:48:06 »

Need input handling? That's only a couple lines or so. Either way, that also proves my point that all the boiler plate is necessary to learn the basic game loop and organization of code. Otherwise, they end up with a super compact set that only does things, while they don't themselves learn. If you want results without caring about code, go with Slick2D fine, but I care about learning my way to the results.

Anyway, input handling: http://www.java-gaming.org/?action=pastebin&id=106

Offline davedes
« Reply #23 - Posted 2012-06-05 23:27:53 »

1  
[code]





Quote
(Java2D) is necessary to learn the basic game loop and organization of code
I'll reiterate what I said before...
- You don't need to know how to write a game loop in order to make a game. There are thousands of Unity, Flash, etc. game developers who have probably never written their own game loops from scratch -- and maybe they will never need to.
- Slick reduces this type of boilerplate and "low level" coding for the sake of simplicity and ease of use. Along the same vein, Java2D's Graphics allow you to use matrix transformations (rotate/scale/translate) through a high-level interface. You can "scale" the view without understanding exactly how the matrix math works, and without having to write your own matrix math boilerplate.
- Many beginners will copy-paste code without fully understanding what it does. This is especially true on their first couple projects -- you just want something up and running. You have time to learn about matrix math, game loops, VBOs, etc. later in life. Smiley

Lower level knowledge is always good to have, but it's not necessarily the best place for a beginner to start, nor is it needed to make good games.

Quote
they end up with a super compact set that only does things
Did you mean "super compact code that does exactly the same thing"? Grin


EDIT: for some reason JGO keeps wrapping my post in 'code' tags.. odd.[/code]

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #24 - Posted 2012-06-06 06:42:02 »

If you want results without caring about code, go with Slick2D fine, but I care about learning my way to the results.
Smiley

Offline davedes
« Reply #25 - Posted 2012-06-06 16:10:09 »

This might blow your mind: you can write your own game loop in Slick. Shocked

I agree that re-inventing the wheel can sometimes help you learn better practices, but most beginners (and experts alike) are not looking to re-invent the wheel. That's why high level classes exist: JFrame, ArrayList, Graphics2D, BufferStrategy, java.util.Properties, etc.

And to say that all Slick users don't care about code... that's a ridiculous statement.

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 77
Projects: 15


★★★★★


« Reply #26 - Posted 2012-06-06 17:10:29 »

Slick2D has a lot of code that you don't understand until you've gained a bit more experience. Java2D, on the other hand, is simple and easy to understand from the start. Slick2D may have better performance, but it doesn't really matter at beginner stage. With Java2D, you just need some imports to be set up, but with Slick2D you have to download LWJGL, tell it where it has its natives, and then download Slick2D and install it. There are also a lot more tutorials on Java2D, compared to Slick2D which has only a handful to a dozen tutorials.

Overall Java2D is better for when you're just starting out.
I'd disagree with the above, IMO its actually harder to get started writing Java games with Java2D than with Slick2D/LibGDX.

Some reasons are as follows:

  • Slick2D is designed specifically for games while Java2D is not.
  • To use Java2D you not only have to learn its API but also either AWT or Swing (or both) windowing API's.
  • With Java2D you have to write your own game loop and timer code while Slick2D comes with a built in tried and tested framework that provides both.
  • Java2D on recent OS X Java releases is pretty much dead performance wise, especially the all important active rendering.
  • Java2D's many different rendering pipelines lines provide very inconsistent performance and stability while Slick2D's one should be pretty much consistent.
  • JavaSound which you'll most likely use if you are avoiding natives is pretty crap for games while Slick2D's OpenAL backend is fast and provides low latency sound that is suitable for games while also providing support for formats like Ogg and XM.
  • Slick2D's built in framework and game focused API's mean you need less Java code than to do the same thing in Java2D.
  • Ask anyone that has done serious game development with Java2D, you need to jump through all sorts of hoops to get performance and smoothness out of it for fast games (like managing your own bufferstrategy for double buffering while this is done by default for Slick2D) and in the long run it is a dead end for games as you'll likely hit some sort of performance limit.
  • Slick2D is just a light wrapper around LWJGL and you can easily drop down to the lower level OpenGL API if you like (I even occasionally use it for prototyping 3d stuff as the framework is nice and fast for getting stuff up quickly).
  • Performance is much better on Slick2D and you can throw all sorts at it (including images with lots of transparency) before you need to worry about performance, not so with Java2D as it has a lower limit which can be hit much more easily thus causing frustration and less productivity.
  • Slick2D has a strong gaming focused community around it and thus easier to get game related help for it while Java2D's game community is more scattered.
  • Java2D, AWT and Swing are pretty much legacy API's at this stage with Oracles engineers and resources having been moved to their successor/replacement, JavaFX. Soon these old API's will be moved to some JDK module for backward compatibility only where they'll be left to slowly die. Smiley

As for the LWJGL step you don't have to download it separately, it comes with the Slick2D download bundle and is a simple 2 step process to set up (do note that Java2D/AWT also have natives, its just that they are added to classpath by default, for now Smiley).
Offline sproingie

JGO Kernel


Medals: 202



« Reply #27 - Posted 2012-06-06 18:09:56 »

I agree with most of the points above, though I'd take issue with a couple.  You learn Swing, period, and when you want clicky button UI elements or other Swing things, the integration is nice to have.   Not that a swing UI is all that desirable for games, but it suffices for learning projects.  Similarly, you already have a game loop dealing with your input, so it's really just a matter of scheduling redraws, which is hardly rocket science.

Performance-wise however ... java2d is a dead end.  Worse than a dead end, a tarpit.  JavaFX could be promising, but I think it's not going to be til jdk8 that it will ever feel really "official", and maybe not even then.
Offline Cero
« Reply #28 - Posted 2012-06-06 18:10:45 »

I'd disagree with the above, IMO its actually harder to get started writing Java games with Java2D than with Slick2D/LibGDX.

Agree on Slick2D and your arguments for it.
Libgdx not so much.
You have to have knowledge of graphics programming before using Libgdx.
Like whats a power of 2 texture, and why cant I just load any image.
Whats a spriteBatch or textureAtlas; why are these things needed or at least so very encouraged.

My time in Slick told my everything I needed to know; but our game still uses Slick and still loads some images which are not power of 2...

bottom line: Slick is very easy to use, but performance gets questionable when the project gets bigger, if you dont develop your opengl skills.
Libgdx is better designed but harder to use. It's understandable because it has a heavy focus on android, and performance is very important there.

Of course its all better than java2D by far. Especially when Slick2D's API is so easy and straight forward and familiar to Java2D users.

Offline ra4king

JGO Kernel


Medals: 345
Projects: 3
Exp: 5 years


I'm the King!


« Reply #29 - Posted 2012-06-06 18:13:18 »

Ok fine I concur on your posts, but I'm quite stubborn on my stances too Tongue

Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

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

BurntPizza (9 views)
2014-09-21 00:34:41

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

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

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (96 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
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!