Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Performance Tuning / Re: libGDX rendering performance on: 2013-06-27 21:01:39
Hm thank you for the link but I guess caching is no solution to my problem.

The tiles (and that's why I choosed 6x6 for them) are part of a dynamic sandgame style map.
That means each tile could interact with each other tile at any given moment.
2  Game Development / Performance Tuning / Re: libGDX rendering performance on: 2013-06-27 20:39:01
Of course all (all tiles) batch.draw() calls are called between batch.begin() / batch.end().
3  Game Development / Performance Tuning / libGDX rendering performance on: 2013-06-27 20:12:01
Hi there,

I am currently developing a game where I need to render a lot of dynamic small tiles.
One tile is 6x6px targeting a resolution of 1024x768 resulting in a tile-count of 170x128=21760 tiles.

On the desktop I get a decent framerate of 400fps whereas on my test device (acer a500 tegra2) I only get about 20fps :/.

Keeping in mind that the gamelogic, ki, etc. is excluded in this test, I would be happy with a framerate of about 50fps on the tablet.

I am only! rendering tiles that are visible and there are no unnecessary texture binds involved.

Here is the code that is called for each tile:
1  
2  
3  
4  
5  
   @Override
   public void renderTile(short tileId, int screenX, int screenY) {
      batch.setColor(tileProvider.getTile(tileId).color);
      batch.draw(tileTexture, screenX - tileMap.getTileSize(), screenHeight - screenY - tileMap.getTileSize());
   }


Is there any chance to improve this?

Thanks in advance Smiley
4  Discussions / General Discussions / Re: Managing gamestates and entities, singletons on: 2013-04-12 12:33:50
Quote
Who actually unit-tests game code anyway?
Well I hope some people do Smiley

Quote
And what makes unit-testing a singleton particularly difficult?
When it comes to unit testing you need a clearly defined state of the class you want to test.
When not using a singleton, a simple
1  
new Foo();
provides you a fresh instance and a clean state.

But how can you ensure that for a singleton?
By definition there is only one instance of it and you can not be sure that it's state is what you expect it to be which makes testing it very very hard and error prone.
So your only chance would be to implement a method to reset the state of your singleton which again is error-prone.
5  Discussions / General Discussions / Re: Managing gamestates and entities, singletons on: 2013-04-11 23:10:49
You should avoid singletons wherever you can.
The singleton is reasonable called an anti pattern.

How would you unit-test a singleton?
6  Discussions / General Discussions / Re: why are people trying to use Java2D to make games? on: 2013-04-11 22:54:15
I just started to port a game from Flash to Java and when I started to port the code I already knew that the rendering part should be separated as much as possible (which it should be anyway) so I could decide later wheter to use Java2D, opengl, a printer or whatever.

So in my opinion the question about wheter to use Java2D to make games or not should be wheter or not to use Java2D for the rendering.
Java2D is not about game programming, it is about image processing (which it seems to do very well).

It is perfectly valid to use Java2D for your rendering.
And if you have separated the rendering from the rest of the game it should be no problem to switch from the Java2D API to some OGL API.
Same applies for the inputs btw.
7  Java Game APIs & Engines / Java 2D / Re: Event handling on: 2013-02-22 09:16:14
Thank you very much BoBear2681,
so basicly I need to implement the Observer Pattern by myself given the interface provided by Java.
While this is exactly what I have been looking for, I wonder why(if) there isn't any implementation but only the private field :/.
However, this helped me a lot Smiley
8  Java Game APIs & Engines / Java 2D / Event handling on: 2013-02-21 20:26:51
Hi,

I am actually not sure if this is the right place for my question but I probably will notice if not.
I come from an ActionScript background and am now dealing with Java to which I would like to port some graphical stuff I have made in "Flash" before.
The rendering is no problem for me at all but which makes me some headache is the way events are handled in Java because I have some swing gui that interacts with my model.

For instance given a custom GUI component (which extends JPanel) is composed of two other GUI components:JLabel and JButton.
If the user clicks on the JButton instance I would like to now the state of the JLabel (from a parent component which instanciated my custom component) without nowing much about the custom component (loose coupling).

So imho it would be the best solution to forward the new state(in this case it is the String of the label) as part of the custom event.

In ActionScript I couldy easily dispatch an custom event like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
class MyCustomComponent extends Sprite {
  private const myButton : MyButton = new Button();

  public function MyCustomComponent() {
    myButton.addEventListener(MouseEvent.CLICK, onButtonClick);
  }

  private function onButtonClick(event : MouseEvent) : void {
    dispatchEvent(new CustomEvent("change", "new string"));
  }
}


Another GUI component could handle events of MyComponent like this:
1  
2  
var myCustomComponent : MyCustomComponent = new MyCustomComponent();
myCustomComponent.addEventListener("change", onCustomComponentChange);


In onCustomComponentChange I then could handle the changed state of the component.

So how is this solved "correctly" in Java?

Unfortunately it seems that I can not dispatch custom events that forward objects to the listener.
I thought about some objective c delegate solution:
1  
myCustomComponent.delegate = myDelegate;

where the delegate needs to implement some component specific callbacks.
But this smells boilerplate.

Maybe I have missed something fundamental?

Thank you for your time, any help is appreciated Smiley
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (73 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (164 views)
2014-04-08 23:06:04

tom_mai78101 (260 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!