1
\$\begingroup\$

I'm looking to port a JS web game to console (Nintendo Switch and PlayStation 5). With the WiiU, it had native HTML5 support. These are my current solutions:

  1. Built-in browser: Currently, the only way to run HTML5 games is a roundabout using the built-in browser; however, that circumvents proper account management that should go through Nintendo or Sony. Additionally, it's difficult for user navigation, and requires significant overhauling per device type.

    From what I've seen on the PlayStation Dev Portal, the PlayStation WebKit - JavaScriptCore might help. But the documentation is a bit lacking. It looks like I just compile it with CMake and juggle parts. Perhaps there is more documentation in another area of the portal that I missed.

  2. Wrap a browser: There is a subpar optimized way of porting using a browser then caching the game, but it seems like a very bad plan. There might be missing features because of how it calls. It would be better to just convert it over and optimize it per device.

  3. Translate JS to C++: I have an understanding of taking C++ to JS with WASM, but doing it vice-versa is daunting. Off the top of my head, I can only think of translate the entire codebase into C++ then massage the code until it works.

As far as I know, there is nothing like Cordova or MonoGame that does JS to C++.

I am wondering if there is an existing wrapper for JS to C++? If there is no tool, how would I start to create a wrapper?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

"How to translate JavaScript to C++" is a bit of an X-Y Question so I'm going to answer what you are actually trying to do, how to run a JavaScript game on Nintendo Switch / PlayStation 5.

I'm not sure why you think embedding a web engine is "a very bad plan" because there are commercial games out there that do it without issue, if you have tried it and there are issues that make that approach unviable please add them to the question, otherwise I think embedding a web engine is your best bet.

For example CrossCode is an RPG released on both the Nintendo Switch and PlayStation 5 that was made in JavaScript using Impact [dot] js using an embedded web engine. I don't know the exact web engine but I think it's Gecko.

\$\endgroup\$
-3
\$\begingroup\$

Crosscode is the only known game that was ported without rebuilding it. I watched the talk of the programmer guy who ported it. He is a genius and managed to build a javascript interpreter in C++ that was able to run this very game.

But there is NO WAY to wrap a javascript app in a browser. If you plan to port your game to Switch: Use an engine!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ "Crosscode is the only known game that was ported without rebuilding it." - Source? "He is a genius and managed to build a javascript interpreter in C++ that was able to run this very game." - I can't speak for the developer but there are plenty of JavaScript engines for C++, including Google's V8 engine - "there is NO WAY to wrap a javascript app in a browser" - Again source? There are plenty of JavaScript games that use an embedded browser. \$\endgroup\$ Commented Jun 28 at 21:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.