Mobile Apps & Games Show Cases

The Fruity Bang Game – How To

Introduction:
Our game is developed with 3D graphics and shall be played in Android mobile devices. We choose jMonkeyEngine game engine to develop our game because it supports 3D and can be integrated with Android. JMonkeyEngine has many advantages and disadvantages for 3D game Android development.

Advantages:
JMonkeyEngine (JME) can be used to develop games on multiple platforms, including Windows and Android. 3D models can be designed with external 3D tools and imported to JME with ease. Plus, animations of the models, which are created easily in external 3D tools, are automatically imported to JME together with the models. Sounds are imported and played in JME within a few steps and a few lines of code. In addition, JME provides some APIs to detect collisions therefore we do not need to implement some of collision logics when using JME on desktop game. However the APIs do not work well on Android platform which is discussed below. Moreover, JME also provides IDE which is a variant of Net Beans IDE. One of the most important features is that it is free and open source.

Disadvantages:
Although JME supports for 3D game developing, it has several serious bugs.
First, sometimes the editor of the IDE and the compiler do not work with each other. Sometimes, when we change the code and save then run, the IDE actually compiles the previous version of the code.
Second, JME does not provide a proper way to optimize the resources in order to improve performance which is essential on mobile devices.
Third, JME does not support well with Android.
• JME does not fully support touch events, sensors.
• JME does provide an AndroidHarness class to communicate with Android Activity but it has limitation. For instance, it does not have run-time communication between Android and JME.
• JME supports native physic which is a default physic but it is in developing process. The other physic (jPhysic – default physic of desktop) causes extremely low performance and sometimes causes bugs.
• JME on Android is run on jar file which may reduce performance.

Requirements:
System requirement:
Minimum: Android API level 14.
Preferred: NVIDIA Processor with GPU support

Steps:
Below is part of our code for collision detection between the main character and the worm:

private void wormAndSa() {
        for (int i = 0; i < WORM_POS.length; i++) {
            if (WORM_POS[i] != null) {
                if (WORM_POS[i][1] != null) {
                    Worm worm = (Worm) WORM_POS[i][1];
                    if (!worm.isDead()) {
                        Vector3f saPos = (Vector3f) SA_POS[0][0];
                        Vector3f wormPos = (Vector3f) WORM_POS[i][0];
                        float x = Math.abs(saPos.x - wormPos.x);
                        float z = Math.abs(saPos.z - wormPos.z);
                        if (x <= (PLACE_HOLDER / 2) && z <= (PLACE_HOLDER / 2)) {
                            if (!sa.isDead()) {
                                sa.die();
                            }

                        }

                        byte xW = (byte) Math.round((-wormPos.x / PLACE_HOLDER + MAP_WIDTH - 1) / 2);
                        byte yW = (byte) Math.round((wormPos.z / PLACE_HOLDER + MAP_HEIGHT - 1) / 2);
                        if (POSITIONS[xW][yW][0] == RUBY) {
                            Ruby rub = (Ruby) RUBY_POS[xW][yW][0];
                            POSITIONS[xW][yW][0] = EMPTY;
                            bullet.getPhysicsSpace().remove(rub.getControl(CharacterControl.class));
                            bullet.getPhysicsSpace().removeAll(rub);
                            rub.detachAllChildren();
                            rub.removeFromParent();
                            rubies.remove(rub);
                        }

                        if (POSITIONS[xW][yW][0] == FRUIT && isBoss) {
                            Fruit fruit = (Fruit) BOMB_POS[xW][yW][0];
                            fruits.remove(fruit);
                            POSITIONS[xW][yW][0] = EMPTY;
                            fruit.detachAllChildren();
                            bullet.getPhysicsSpace().remove(fruit);
                            fruit.removeFromParent();
                        }
                    }
                }
            }
        }
    }

Reference:
• For reference, please contact us:
o Dam Hong Linh: s3372757@rmit.edu.vn
o Lu Hai Thong: lthong90@gmail.com

Standard