Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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: Making a new list with new objects every single frame on: 2013-11-03 13:52:21
I know this is a dead thread, but anyway.
Avoid doing new on android. Always use an object pool. Code is not complicated. Here is mine, that works well for mainly all cases :

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  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
class Bucket<T>
{
   private final ArrayListEx<T>   elements   = new ArrayListEx<T> ();
   private int                  usedCount;
   private final Class<T>         classOfT;

   Bucket(Class<T> classOfT)
   {
      this.classOfT = classOfT;
   }

   Bucket(Class<T> classOfT, int initialCapacity)
   {
      this ( classOfT );
      reserve ( initialCapacity );
   }

   final void reserve(int capacity)
   {
      for (int i = 0; i < capacity; i++)
         elements.add ( newT () );
   }

   final int capacity()
   {
      return elements.size ();
   }

   final int size()
   {
      return usedCount;
   }

   final T get(int index)
   {
      return elements.get ( index );
   }

   final T add()
   {
      if (usedCount == elements.size ())
         elements.add ( newT () );

      final T obj = elements.get ( usedCount );
      usedCount++;

      return obj;
   }

   final int remove(int index)
   {
      elements.swap ( usedCount - 1, index );
      usedCount--;
      return index - 1;
   }

   final int remove(T obj)
   {
      final int index = elements.indexOf ( obj );
      return remove ( index );
   }

   final void remove(ArrayList<T> list)
   {
      final int count = list.size ();
      for (int i = 0; i < count; i++)
         remove ( list.get ( i ) );
   }

   final void clear()
   {
      usedCount = 0;
   }

   private final T newT()
   {
      try
      {
         return classOfT.newInstance ();
      }
      catch (Exception e)
      {
         return null;
      }
   }
}


Example of use :

1  
2  
3  
4  
5  
6  
7  
Bucket<Firework> sprites = new Bucket<Firework>(Firework.class);
...
Firework f = sprites.add();
f.setPosition(...); // reset all you need cause we are using recycled instances
f.setColor(...);
f.setVelocity(...);
...


I'm using here a ArrayListEx instead of a ArrayList, it is just the same class with some additionnal methods that you will rewrite (I can only see the swap method here).

Using a pool is really performance friendly for a very little cost and almost no drawback (except maybe the quick 'swap with last' method I'm using for removal, that changes order, which sometime is important).

Cheers.
2  Game Development / Performance Tuning / Re: Fastest way to render 2D tiles on: 2013-11-03 13:24:40
VBO for everything !
You might want to take a look at the VertexBatch class of LibGDX for a good VBO example / code base.
3  Games Center / Showcase / The Colored Path on: 2013-07-11 18:19:13




Hi fellow game creator! I'm very excited, I’ve just release my latest (and first!) game on the Google Store.

The game was solely developed by myself, in two weeks, and features colorful graphical style in true HD (2560×1600 for Nexus 10 tablets).

It is made in Java(obviously) under Eclipse, using the middle-ware LibGDX, and Inkscape for the graphics.

The game is called ‘The Colored Path’ and it’s a puzzle game aiming casual players. Over 150 puzzle boards, featuring a mechanic that consists in reproducing a pattern by drawing a path, where crossing over the path produces different colors.

The game can be freely played from the Google Store. The game is complete, with no in app purchase. Only a thin, really really thin ad banner at top, wonderfully integrated (it shares the same color and theme than the game background).

I’m very proud ! Grin

Go get it ! It's free ! Thanks for your time and I look forward to hearing from you!

 Pointing
4  Discussions / General Discussions / Re: Why I'm coming back to java and sticking with it: Ouya on: 2012-11-09 17:31:49
Hi
We should not forget what their ultimate goal is, and it is to make money. Ouya is calling for indies to do the buzz. But it's basically just another platform that aim to put taxes on games sells, just like steam, xblive, facebook, etc.

And it seems obvious to me the reason why they don't want everybody/anybody to have their game ready for the launch. I would do the same to avoid having a game culture medium like the android market swamp.

Reminds me this : http://www.lostgarden.com/2011/03/gdc-2011-game-of-platform-power.html
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.

Riven (4 views)
2014-07-23 21:16:32

Riven (5 views)
2014-07-23 21:07:15

Riven (5 views)
2014-07-23 20:56:16

ctomni231 (40 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (30 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!