Scripting layer for Android - LibGDX - javascript

I've been writing a full game engine on top of LibGDX for sometime now and had written almost every single game object in Javascript (I created a composite based game object system). For the JS interpretation, I used the Rhino engine which on my ubuntu system, works phenomenally well, however when I tried to run it on Android, I was not able to get it to compile at all and from what I HAD read, it's because Google didn't use a standard Java implementation that supported Rhino, but now I'm seeing the support with the SL4A project, however I was looking for a simple Rhino jar file that was compatible with Android but after looking through the downloads, all I found were APK files that did not appear to have the library and from what I have read, the APK is suppose to be a template project, but how can I use it with my existing code without a jar package? Maybe I'm totally missing the point?

It seems SL4A Rhino repository has all the necessary add-ons (among them rhino1_7R2-dex.jar) to get Rhino running on Android.

Related

How to write iMacros scripts in javascript using scripting interface and call those from batch files

Sorry this is a relatively simple question, but there's some confusion between the firefox javascript scripting interface and the scripting interface that comes with the enterprise version of iMacros.
Here's what I'm trying to do:
Make a javascript file which utilizes the enterprise version of iMacros' scripting interface. Not the one bundled with the firefox version.
Be able to use any browser via that scripting interface. This means using iimOpen("-fx") for firefox, -ie for IE, -cr for chrome, etc, using the command reference found here
Be able to call that javascript file from a .bat file so that I can automate it with Windows Task Scheduler
I've searched around a lot, and most questions are related to the firefox-specific scripting interface and are only for javascript/one browser. The few that are using the enterprise scripting interface don't have good answers/examples. I basically just want to have the shell of what I need to get started so that I can just start writing the actual script with iimPlayCode() calls. I'm new to javascript for scripting purposes, and most things I've done are using projects such as visual studio solutions, so I'm used to imports and such. For example, what do I need to define so that the script knows how to interpret iMacros commands? Usually that would be an import, but do I need an import for a script or is that built in somehow? Do I need a main or something similar? etc
There's this example on the iMacros wiki, but it's built like an html file that you have to click to start, and I don't think that'd work well with a batch file for scheduling. As far as I know, that's the only javascript example using the enterprise scripting interface.
System information:
Windows 10
iMacros 11.1 Enterprise
Latest Firefox/Chrome/IE

Is there a way run an HTML file in a Google Chrome "environment" without having it installed?

I'm making a game with HTML/CSS/Javascript because it's the code I'm most comfortable with at the moment. I'm only really doing this as an exercise in game development and plan to learn C# later. But for now that's what I'm using, and I have a question about it.
Obviously when making a website, you want your website to be compatible with all web browsers equally. Right now, I'm using Chrome to test/debug my game, and I've decided to develop this game with Chrome in mind. But not everybody has Chrome, and not everyone would want to download it in order to play my game.
Is there a way to run an HTML/CSS/Javascript file in a Google Chrome "environment" without having the actual browser installed? Just it's code engine and none of the rest of the browser.
I've been reading about their V8 Javascript engine that they use in Chrome, and am wondering if that is part of the answer I'm looking for. What I'd like to do is include this "engine" in an installer with my game files and have it install like any other game.
Hopefully this makes sense. This may not be possible/exist, but if someone knows something I don't or an point me in the right direction, that'd be amazing. Thanks!
You could look into Node-webkit which essentially allows you to write desktop applications in html/css/js. When you distribute your game along with your node webkit executable, it is always run in the same environment. You can see some cool examples on their demos and examples page.
Usually a common path to convert web application to native desktop applications is to use a "thin" browser as app container and ship it.
A lot of current applications out there are using this trick (Spotify, Slack, etc...) and it works pretty well.
I've read of some people using the CocoonJS game engine framework and successfully ship it with this techniques.
To most famous wrappers, that I know are node-webkit or electron (AKA atom-shell).
Once you include your game in either one of those you can just "compile" it (it is not a real compile, but just to give you an idea) and ship it: with some tricks it is also possible to publish it in the Mac/Win app stores.
In case you want to focus on mobile instead, there are similar frameworks but I don't really know which are the most common.
Note: if you're using fancy WebGL or very advanced stuff these tools may have some issues sometimes.
So essentially you want to install the JS engine to use it with any browser? In this case, the answer is: nope. Browsers act different, they don't have a standard interface, nor have this "swapping" capability in mind.
In case you'd be asking for an embedded browser inside an app... well, isn't that worse than installing Chrome? You may embed webkit/V8, but it's a hard way and you'd know programming.
So simple answer is: you'd make it compatible for at least the evergreen browsers (Chrome / Firefox mainly). Or reduce your target to webkit based only browsers (or in your case V8, i.e. Chrome, Chromium and the forks).
If you want that your game is only for chrome, because you read V8 documentation, you can create it as an extension. There'sn't other way to install your JS, because browser interpret javascript, not compile it. And the docs you need is found at: https://developer.chrome.com/extensions/getstarted

Packaging node-webkit App

https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps
While packaging my node-webkit app for windows using the steps given in the above link I could not find how to avoid readability of the resulting executable from the merge by archiving software, such as WinZip. EXCERPT(from link above): "The resulting executable from the merge will still be readable by archiving software, such as WinZip."
Is it possible to avoid readability by the archiving apps?
Any help is appreciated!
Fundamentally, running node-webkit is similar to running in a browser, so just as you can't hide your webpage source, you can't truly hide your HTML and CSS in such a way that it can't be read, because it needs to be read by node-webkit at runtime.
The situation is almost the same for Javascript code, with one exception. V8 (the javascript engine in Chrome) provides a "snapshot" capability, which sort of compiles your Javascript into a sort of bytecode that V8 understands. Nwsnapshot is available for node-webkit, which will allow you to avoid shipping your JS code (or at least some of it). However, this option is still experimental, and in fact there is a problem in version 0.8.* of node-webkit (referred to as v8 in the wiki, but not to be confused with the V8 js engine), though it should be working again now in v9. Details can be found here if you're interested:
https://github.com/rogerwang/node-webkit/wiki/Protect-JavaScript-source-code-with-v8-snapshot
Also be aware that it can have performance impacts, if that matters for your application.
You could also make an exe file.
See "Step 2b: Alternative way - Making an executable file out of a .nw file" from the link you provided.

What is the most normal way to deliver a ClojureScript desktop application

I have a desktop application written in Clojure that suffers greatly from JVM startup time and is a really good fit for ClojureScript. It is delivered as a jar file for the JVM, what is the equivalent for ClojureScript/JavaScript?
The deployment rules for regular javascript apply. There's nothing wrong with just sending the user the optimized .js file emitted from clojurescript's compiler. Usually this means double clicking the script or running from command line as if it were python or ruby.
Can you do Desktop Development using JavaScript?
For windows machines, you have Windows Script House http://msdn.microsoft.com/en-us/library/9bbdkx3k(VS.85).aspx
If you run a *nix you can use Node.js http://nodejs.org/
Note: You may need to lookup tips for getting google's closure library to work with node.js via https://github.com/hsch/node-goog if you will depend on it.
Or something like this? https://github.com/maccman/macgap

Building a Windows app w/ embedded browser & JavaScript 'hooks'

I built a PHP / JavaScript website for a customer. Then they asked me to replicate it except as a standalone Mac application. I did this with an app that combined an embedded web server, PHP, and 'WebView' - a Cocoa-ish version of the WebKit web browser that I can embed in a standard app window. This all worked great - I got to reuse 10,000+ lines of PHP/JS code, which saved months off of re-implementing it all again in 'native' code.
Now they want a Windows equivalent. I'm reasonably confident I can get PHP and the web server to work. And I know embedding basic IE functionality is pretty easy.
However...in my Mac setup, WebView (via the windowScriptObject stuff) gave me the ability to call JavaScript methods from C++. For instance, I might call a JavaScript method from C++ to update the screen. Likewise I could set things up so that a JavaScript call in the browser could trigger a C++ method - I used this, for instance, to let a user click 'BROWSE' and pick a file path using a real, standard file browser.
So my question is, is there a Windows-based embedded browser setup that would let me interact with JavaScript in this same way?
(the JavaScript <--> WebKit interface is described in much better detail here: http://lipidity.com/apple/javascript-cocoa-webkit/)
Maybe try using something like Appcelerator Titanium so you'll be ready when your client says they want it to work on Linux, or iPhone, or Android.
Quoting Wikipedia: "Appcelerator Titanium is a platform
for developing mobile and desktop
applications using web technologies.
[...] Support for standards-based web
technologies: HTML, CSS and Javascript
on all platforms along with PHP,
Python and Ruby for desktop platforms.
Integrated support for popular
JavaScript and AJAX Frameworks
including jQuery, YUI, MooTools,
Scriptaculous and others."
Sounds like a perfect tool for the job.
When you embed the Web Browser Control (IE), your application code can simply call execScript (http://msdn.microsoft.com/en-us/library/ms536420(v=vs.85).aspx) on the window object. You can have your script call out to the application by using the window.external object from the script, and by using the ObjectForScripting (or C++ equivalent) from the application.
maybe Qt will be good for your case, also you have QtScript and can inject javascript with evaluateJavaScript
I found a great example on the web for invoking JS in my embedded browser from C...basically using COM-ish methods that let you get a DISPID from a script object, and then using the Invoke() method with that. This works great.
But it turns out I need to also call C++ funcs from my JS code. It appears this is possible, and after hours of messing around I think I almost had it - it's like the above in reverse - you create a COM object, then hook it to the browser's script object - but in the end I could not close the deal - I kept getting "library not registered" errors. Honestly I don't know COM well enough to do this right.
So then I, for the heck of it, tried building my first C# app. In about 20 minutes I had an app running with a browser where I could both invoke JS inside of it and have the browser invoke C# methods. Geesh. I'm a believer in .NET after this experience, and a confirmed non-believer in 90's Microsoft technology.
In the interest of completeness, I'd like to mention my Windows port of WebKit, which includes the various cross-layer features of WebKit on the Mac.
I posted some example code showing how to embed WebKit in a native WinAPI application, complete with JavaScript->C++ and C++->JavaScript examples.
The example is a tiny test case for a much larger application using embedded WebViews for major UI components. I can confirm that what you are doing is not only possible, but a great way to build an application.

Categories