Skip to content

Instantly share code, notes, and snippets.

@videlais
Created March 21, 2014 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlais/b7e9cce3a2a3ee38c755 to your computer and use it in GitHub Desktop.
Save videlais/b7e9cce3a2a3ee38c755 to your computer and use it in GitHub Desktop.
Prototype code for getting Twine working on the Ouya
<!DOCTYPE html>
<html>
<head>
<title>Twine Testing</title>
<script src ="js/CocoonJSExtensions/CocoonJS.js"></script>
<script src ="js/CocoonJSExtensions/CocoonJS_App.js"></script>
<script src ="js/CocoonJSExtensions/CocoonJS_App_ForCocoonJS.js"></script>
<script src="js/gamepad.js"></script>
<script>
var cursorSpeed = 5;
CocoonJS.App.onLoadInTheWebViewSucceed.addEventListener(function()
{
CocoonJS.App.showTheWebView(0, 0, window.innerWidth, window.innerHeight);
setInterval(pollCode, 1000 / 60);
});
CocoonJS.App.loadInTheWebView("ouya.html");
function pollCode() {
if (Gamepad.moved(0, "LEFT_X") > 0 && Gamepad.moved(0, "LEFT_X") <= 1.2) {
CocoonJS.App.forwardAsync("moveDiv(" + cursorSpeed + "," + 0 + ")");
}
if (Gamepad.moved(0, "LEFT_X") < 0) {
CocoonJS.App.forwardAsync("moveDiv(" + -cursorSpeed + "," + 0 + ")");
}
if (Gamepad.moved(0, "LEFT_Y") < 0) {
CocoonJS.App.forwardAsync("moveDiv(" + 0 + "," + -cursorSpeed + ")");
}
if (Gamepad.moved(0, "LEFT_Y") > 0 && Gamepad.moved(0, "LEFT_Y") <= 1.2) {
CocoonJS.App.forwardAsync("moveDiv(" + 0 + "," + cursorSpeed + ")");
}
}
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment