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:
-
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/
-
Scorpios: one of Nate’s projects http://code.google.com/p/skorpios/ (2D w/ GL context)
Uses lwjgl for the desktop impl.
-
jPCT-AE - an Android port of jPCT (3D)
http://www.jpct.net/jpct-ae/
-
Ardor3D on Android (3D)
http://www.ardor3d.com/wiki/android_dev
A 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 ;D http://www.youtube.com/user/droidgamers
Typical game looks something like:
public class Game1 extends Game {
.....
public Game1 (String title){
super(title);
}
public void init(GameContainer c) {
// Texture2D
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);
// Animation
anim = Content.getAnimation("res/homingmissile.png",64,64);
anim.setPingPong(true);
// XML SpriteSheet
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:
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? ;D