2. Who am I
Daniele Montagni
Java developer, Android enthusiast
http://twitter.com/dmontagni
http://www.jugroma.it
3. What we’ve done
Gameset:
Tankattack is a turn-based strategy game. The setting is a fixed map and player can
control 2 tanks each game:
Goal of the game:
win the match by destroying all against player's tanks
4. How...
Architecture and frameworks:
• Android platform: 1.6 (2.3)
• Rokon game engine: 1.1.1 (2.0.3)
• Smack libraries: 3.1.0
Tools:
• Android SDK for Mac: 2.1-r5 (r8)
• Netbeans: 6.8 (IntelliJ 10 CE)
• Android plugin for netbeans
5. SDK Tools
Create your emulator through Android SDK and AVD manager
daniele@Daniele-Montagnis-MacBook~/android-sdk-mac_86/tools$./android
Starting Android SDK and AVD Manager...
6. Easy project setup
Create "android" type project into Netbeans
That has this structure
...than click "Run" project
7. Emulator & adb
This will run the
emulator and deploy
logcat through Netbeans show status:
8. Rokon
Rokon basics
public class TankAttack extends RokonActivity {
public void onCreate() {
createEngine(480, 320, true);
}
public void onLoad() {
...
Background background = new TileTextureBackground(atlas,
tileloader.getLayers());
...
Sprite tank = new Sprite(80, 180, spriteTexture);
Hotspot hotspotTank = new Hotspot(tank, 1);
}
public void onEvent(GameEvent event) {
rokon.addSprite(tank);
rokon.addHotspot(hotspotRedTank1);
}
public void onLoadComplete() {
rokon.setBackground(background);
rokon.addSprite(tank);
}
9. Smack
Smack basics:
ConnectionConfiguration connConfig = new
ConnectionConfiguration(host, port, service);
XMPPConnection connection = new XMPPConnection(connConfig);
connection.login(username, password);
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
xmppClient.setConnection(connection);
Message msg = new Message(to, Message.Type.chat);
msg.setBody(text);
connection.sendPacket(msg);
Type Format Sample
START START:[ROOM_ID]:[PLAYER_NUMBER] START:234523:1
MOVE 1:[XX]:[YY]:[ROTATION] 1:3:7:4
SHOOT 2:[SENDER]:[TARGET]:[DAMAGE] 2:1:3:500
ACK TRUE TRUE:[TANK_ID] TRUE:2
END GAME END:[ROOM_ID]:[PLAYER_LOSER_NUMBER] END:234523:1
10. Tips & Tricks
• Rokon is under development: things must be
done from scratch!
(ex. TileTextureBackground...)
• Android plugin for Netbeans is not stable
(build.xml must be modified...)
• For rapid development use Eclipse that is
supported by Android community:
http://developer.android.com/sdk/eclipse-adt.html#installing
...or IntelliJ Idea 10CE