Hello everyone,
I am a student and I am working on creating my first game. The engine that I am using is called J Monkey and is a java based engine. This allows android applications to be created from the code written. However I am unsure how this might effect my desire to release it onto the Ouya console. I would like to believe that it might be generated as an Android application and then transferred over to Ouya, however I do not know if this can be done.
If anyone can help me by clarifying this issue it would be greatly appreciated.
Thank you for your time and have a nice day
Answers
Guessing that you can import jars, you should be able to import the OUYA SDK and get access to the gamepad data etc.
Though it is Eclipse based, you might also want to peruse the blog and forums at the libgdx project: http://libgdx.badlogicgames.com/
They are putting in specific OUYA stuff, but, only as optional.
Well, there are plugins people have developed and released on the Asset Store, such as Gamedraw and ProBuilder, that try to handle 3D modelling (I won ProBuilder in a contest, and I must say it feels a lot like blocking things out in Hammer, and then adding mesh props and decals and other stuff... it's pretty nice).
Let me just say that while the free version can be a bit off-putting in terms of what it doesn't support, the pro version is totally worth it.
You get some pretty badass graphics and animation technology with Pro, such as Light Probes (essentially you can fake environment shadows (or even global illumination) on characters with almost no impact on the GPU, and you can even inject your own values into these calculations for stuff like muzzle flashes and explosions)
Unity Pro has builtin occlusion culling, pathfinding (using Recast, the same engine integrated with Unreal Engine 3), and Unity 4 also introduced Mechanim for character animation (whereas previously we had a pretty standard animation system, now Mechanim gives you blend trees and state machines for your animations, and also lets you pretty easily retarget your animations for humanoid characters, a lot like Unreal)
I would highly recommend Unity.
My advice would be to start developing your game now, on Unity Free (as I am doing) and then later either pay for Pro ($3,000 total for Pro and Android Pro), or possibly even start a kickstarter campaign and pay for it that way.
It's a lot more expensive, but it also looks to offer many more features than JMonkey does.
To throw out some example games, the games Shadowgun, Shadowgun: DeadZone, and Dead Trigger were all built on the Unity engine.
Sorry for the double post...
/**
* First create an object in one of the Source Packages to hold data shared across the app
* In this case, I've created a controller class to record key presses
*/
public class Controller {
/**
* Take out the lock on this object. No input can be received until this lock is released
*/
public static final AtomicInteger lock = new AtomicInteger();
private int deviceId = -1;
/**
* Was O button pressed down
*/
private boolean O_Down = false;
/**
* Left Stick position on X axis
*/
private float LS_X = 0;
/**
* Left Stick position on Y axis
*/
private float LS_Y = 0;
/**
* Right Stick position on X axis
*/
private float RS_X = 0;
/**
* Right Stick position on Y axis
*/
private float RS_Y = 0;
public void addKeyDownEvent(int keyCode) {
synchronized(lock){
switch (keyCode) {
case OuyaController.BUTTON_O:
O_Down = true;
break;
// .... etc
}
}
}
/**
* Records the positions of the left and right sticks when a
* {@link MainActivity#onGenericMotionEvent(android.view.MotionEvent)}
* is triggered <p> Note: Calls static methods of {@link OuyaController}
*/
public void updateSticks() {
sticksCentred = true;
OuyaController ouyacontroller = OuyaController.getControllerByDeviceId(deviceId);
if (ouyacontroller != null) {
LS_X = ouyacontroller.getAxisValue(OuyaController.AXIS_LS_X);
LS_Y = ouyacontroller.getAxisValue(OuyaController.AXIS_LS_Y);
RS_X = ouyacontroller.getAxisValue(OuyaController.AXIS_RS_X);
RS_Y = ouyacontroller.getAxisValue(OuyaController.AXIS_RS_Y);
} else {
return;
}
if (!isStickNotCentred(LS_X, LS_Y)) { // see ODK samples for where to get this method
LS_X = 0;
LS_Y = 0;
} else {
sticksCentred = false;
}
if (!isStickNotCentred(RS_X, RS_Y)) {
RS_X = 0;
RS_Y = 0;
} else {
sticksCentred = false;
}
}
}
Obviously, you can call the static OuyaController methods from anywhere, but you won't know when to call them. Rather than simply polling them every time the game loops, you can wait until they are pressed/moved, as per the code in my earlier post: http://forums.ouya.tv/discussion/comment/3528/#Comment_3528
However, you need some way that both the Main class and the AndroidMainActivity class are using the same instance of Controller (or whatever object you use):
public class Main extends SimpleApplication {
/**
* Note: Player is just a simple object I just made up to represent a player
*/
ArrayList<Player> players = new ArrayList<Player>();
/**
* Adds a player to the game to be associated with the specified controller
*
* @param controller the controller used by the player
* @return true if the player object is successfully added to the game
*/
public boolean addPlayer(Controller controller) {
synchronized (players) {
if (init) {
Player nPlayer = new Player(controller, "Models/test_box/test_box.j3o");
players.add(nPlayer);
return true;
}
}
return false;
}
}
Then in AndroidMainActivity
public class MainActivity extends AndroidHarness {
/**
* Sparse array is a special type of hashmap that comes with android
* Each Controller object in the array is mapped against a unique int
* In this case, we use the deviceId as the int
*/
SparseArray<Controller> controllers = new SparseArray<Controller>();
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
int controllerId = event.getDeviceId();
boolean handled = OuyaController.onGenericMotionEvent(event);
Controller controller = getController(controllerId);
controller.updateSticks();
return handled || super.onGenericMotionEvent(event);
}
/**
* Gets the controller object for the device or creates a new controller
* object if one does not already exist (and maps it)
*
* @param deviceId the id of the device associated with the controller
* @return the controller object associated with the deviceId or null if
* deviceId is invalid
*/
private Controller getController(int deviceId) {
Controller controller = controllers.get(deviceId);
if (controller == null) {
if (deviceId < 0) {
// no device id? Should probably throw an error here
return null;
}
controller = new Controller(deviceId);
// This next line is the important line, where we get the Main activity as an object in our
// AndroidMainActivity, and can pass the controller object across
// Now there is a shared object, the two classes can communicate between each other
if (((Main) this.getJmeApplication()).addPlayer(controller)) {
// only add the mapping if the player using the controller is successfully created
controllers.put(deviceId, controller);
}
}
return controller;
}
}
Website