There currently are two projects that I'm aware of that try to facilitate desktop/android development with one game codebase for both platforms. Others android specific, but alot of droid 2d/3d/modelloader etc projects on google code:
1. LibGDX:
http://code.google.com/p/libgdx/ (2D w/ GL context)
Uses jogl for the desktop impl.
blog:
http://apistudios.com/hosted/marzec/badlogic/wordpress/2. Scorpios: one of Nate's projects
http://code.google.com/p/skorpios/ (2D w/ GL context)
Uses lwjgl for the desktop impl.
3. jPCT-AE - an Android port of jPCT (3D)
http://www.jpct.net/jpct-ae/4. Ardor3D on Android (3D)
http://www.ardor3d.com/wiki/android_devA Couple
Android Specific:
Rokon:
http://code.google.com/p/rokon/ (2D)
http://rokonandroid.com/AndEngine
http://code.google.com/p/andengine/ (2D)
blog:
http://www.andengine.org/blog/Would be cool if the wonderful slick2d would be ported to android. Kev was first discouraged by floating point performance of android, but as he said targeting 2.0+ should be ok. Really seems so considering the capabilities of these new droid devices.
So let's make something. No reason why slick shouldn't be running on android.
I started a little android/desktop project. It borrows the GL abstraction layer from libgdx (i removed most of the ES specific methods)
It uses lwjgl for the desktop impl. Api similar to slick2d w/ xna stuff.
Troid:
http://code.google.com/p/troid/My Tube
http://www.youtube.com/user/droidgamersTypical game looks something like:
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
| public class Game1 extends Game { ..... public Game1 (String title){ super(title); }
public void init(GameContainer c) { tex = Content.getTexture("res/example.png"); flip = tex.flippedCopy(true, true); scaled = tex.scaledCopy(0.5f); sub = tex.getSubTexture(0, 0, tex.width/2, tex.height/2); anim = Content.getAnimation("res/homingmissile.png",64,64); anim.setPingPong(true); sheet = Content.getXMLSpriteSheet("game1/game1_pack.png", "game1/game1_pack.png.xml"); cannon = sheet.getSprite("cannon.png"); c.showDebug(true); }
public void update(GameContainer c, float delta) { .... }
public void draw(GameContainer c, Graphics g) { g.drawTexture(tex, 0,0); g.drawTexture(flip, 0,0); g.drawTexture(sub, 0,0); g.drawAnimation(anim, 100,100); g.drawString("Line 2\tLine 2\tLine 2\tLine 2", 100,500); }
public static void main(String[] args) { DesktopGameContainer gc = new DesktopGameContainer(); gc.setGame(new Game1("Game1 Test - Desktop")); gc.start(); } } |
The same code runs on both android and the desktop. Only difference being the 6 line launcer for android:
1 2 3 4 5 6
| public class TestsLauncher extends GameActivity { public void onCreate(AndroidGameContainer gc) { gc.setGame(new Game1("Game1 Test - Android")); gc.start(); } } |
As for screen size considerations, scaling the gl context should do the trick. Think that's how iphone games work on the ipad
Those other projects are alot more advanced than mine , but im trying to incorporate as much of slick's functionality as I can manage. If anyone with a phone can test out the demos that would be great. i don't have one.
Checkout the code. let me know how much it sucks. Did i mention i'm a gl n00b?
