A small RTS game

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

A small RTS game

Postby Andy-Freak » Sun May 16, 2010 9:24 pm

Hi
i want to develop a small RTS game for android. Now i want to know which way i should go.
The game should be in 2d and would probably have a lot of sprites.
Also it will be quiet cpu intensive because i think, that things like pathfinding with A* or other AI stuff needs a lot of power.
I can see 3 possibilities:
-Code the game in Java and painting on a canvas ( best compatibility, but bad performance? )
-Coding the game in Java but painting with openGL ( more powerfull for a lot of sprites? )
- Coding the hole game in C++ and native OpenGL an just handeling input with Java ( best performance? )
What to you thing is the best way for a 2d RTS?
Also I think I would need a tutorial how to use the 2d opengl with c++.
How do you code your 2d games?

Andy
Andy-Freak
Freshman
Freshman
 
Posts: 2
Joined: Sun May 16, 2010 9:14 pm

Top

Re: A small RTS game

Postby impi » Mon May 17, 2010 8:31 pm

-Code the game in Java and painting on a canvas ( best compatibility, but bad performance? )


It can work, if you are drawing your map to an buffer, this limits the size to small maps and you will not be able to draw many sprites... ~20 sprites i would say with all this ai stuff going on.

But no blending, no cool effects, and you will be memory limited. Remeber you only have 16MB with android 1.6 (i think with 2.1 you got 24mb, but im not sure)

-Coding the game in Java but painting with openGL ( more powerfull for a lot of sprites? )


Is a lot more powerful, and i think you game then is cpu bound

- Coding the hole game in C++ and native OpenGL an just handeling input with Java ( best performance? )


i would not recommend that way, i would just write some heavy duty functions in c for performance, and use them through the JNI... the A* for example
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Re: A small RTS game

Postby Andy-Freak » Mon May 17, 2010 9:18 pm

Ok thank you for the answer.
Why wouldn't you recommend the third way?
Is there a very small android java opengl tutorial for 2d (I think I just need very few functions)?
How would you draw the map with opengl?
Also use some buffers (split the map in sections which are pregenerated? )
or render the map in realtime (every tree and hill splitted in small tiles)?

Thank you
Andy
Andy-Freak
Freshman
Freshman
 
Posts: 2
Joined: Sun May 16, 2010 9:14 pm

Re: A small RTS game

Postby impi » Mon May 17, 2010 9:34 pm

Im struggling with opengl too at the moment (see my glColor4f issue thread :(), but i managed to get 60 fps with my tilemap finally.

I made one big vertexgrid holding 6 vertices for each quad (2 triangles), with width/height for this.
This vertex grid is textured and is drawn strip-wise.

mapHeight (actually 32x32 on 480x320 = 10 Strips) = -> 10 glDrawArrays calls and using gltranslatef for the scrolling.

Using vertexbufferobjects, if the device supports it, this is an HUGE benefit for this static maps.

This works pretty well, and this is not optimized at all, im using floating points, im using no indices, no triangle_strips. so there is a lot of optimization that can be done there, but im at 60 fps with 2 layers (so 20 glDrawArrays with alpha)

with ~40 enemies on the screen (using the drawtex extension for the enemies) i'm at ~50 fps (G1 device).

Actually i don't know the performance on an milestone or droid with bigger resolutions and other graphics chips, but this as i mentioned, there is a lot of optimization that can be done for this.

I think it would be more problematic if you would like to add animated water or something else.

I dont recommend the C-way, for 2 reasons:
reason 1: writing java code is faster development. Yeah C is waaay faster, but you can write easily the main code in java and go to C for the heavy duty functions, after you examined them with traceview or your own profiler. But thats your choice anyway (it is the fastest way you can go)

reason 2: android 2.2 comes with an JIT-compiler, this will speed up java up to 4-5 times. And then writing native code for 2d games is not more nessesary. (of course, not all devices will get the update, but i hope that the majority of the devices will get this update at some time)
impi
Developer
Developer
 
Posts: 29
Joined: Wed Apr 28, 2010 11:17 pm

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests