Advertisement

Suggestions for Interfacing between a Browser Game and a Local Engine

Started by May 02, 2020 02:35 PM
5 comments, last by Tilea 4 years, 6 months ago

Hi there.

So for the past year and a half, I've been developing increasingly complex projects using the Twine/SugarCube development platform with the heavy use of JavaScript. However, I've started to find myself missing some of the more advanced features of a full programming language such as C# (e.g. interfaces and out parameters). I've been looking into ASP.NET as it seems to be an interface between C# and browser-based technologies, but I find myself having a very hard time parsing the tutorials/documentation. The primary focus of ASP.NET seems to be working with a backend server and databases, and that's way more than I need and a bit beyond my current level.

What I want is to create the “engine” of the game in a language such as C#, then use HTML/CSS/JavaScript to actually create the user experience, but I don't want a backend server involved in it. I'd like it all to run as a stand-alone application on an individual's computer, preferably not even requiring an Internet connection. I'm getting the sense that this is a very niche aim, but perhaps I'm not looking in the right places?

Could anyone give me a little direction/make some suggestions? And in case you are wondering why I'm so set on a browser-based UI, it's due to accessibility concerns. I'm blind and I know how to make webpages usable by myself and other people with disabilities. So far, every other game development engine I've come across relies very heavily on a GUI and strictly graphical components, which not only makes them impossible for me to use, but would make the game impossible to test/play.

None

I did not try this with ASP.net, but you should be able to run a server program on your PC and connect to localhost in the browser.

Advertisement

ASP.net is very much designed for web pages, you can run a standalone process, e.g. use Kestrel on ASP.NET Core, but it's still a server, your JavaScript runs in whatever web browser the user has and will communicate over HTTP (http://localhost), you could maybe use a websocket as well.

JavaScript can go a long way though, consider using a “compiler” like Babel to gain access to features not yet available in all browsers. Or one of the languages like CoffeeScript or Typescript.

You can use Electron to take HTML/CSS/JavaScript program and run it as a standalone desktop application. https://www.electronjs.org/

@SyncViews I've come across mentions of some of those you listed, though I've never gotten a good answer as to what they are or what they are for. I'll look into them again now that you've given me a more narrowed list (there's so much out there). My main worry is that developing a large game with a lot of data and procedural generation in a scripting language might end up being very inefficient and would run very sluggishly, but that's just an assumption on my part.

As to ASP.NET, it really does look like what I'm specifically asking for here, but could anyone point me to some tutorials or teaching tools that are less… verbose than those on Microsoft Docs? Those and the tutorial on TutorialsTeacher pack so many specialized words into a definition, often using terms to define themselves, that I find myself unable to parse a lot of what is being explained. I have a basic idea of what it is and how it's meant to work, but actually making any use of it is beyond me at the moment. I'm sure I could get a handle on it as i have other languages; I just need something less dense to learn from.

None

Something else I just found in the pro-electron solution, since they are running as a native program, you can use native modules, like node.js. This gives you access to the NPM modules you can't use in a web browser (because they need unsafe API's, like local filesystem stuff, or because they rely on native code).

So if you wanted to optimise something with native code yourself, you also then have the option to write your own module.

Tilea said:
My main worry is that developing a large game with a lot of data and procedural generation in a scripting language might end up being very inefficient and would run very sluggishly, but that's just an assumption on my part.

Well you can look at other HTML 5 games to see what is possible. Anything Single player or graphics intensive is going to be doing a lot of that in the browser/locally.

Tilea said:
As to ASP.NET, it really does look like what I'm specifically asking for here, but could anyone point me to some tutorials or teaching tools that are less… verbose than those on Microsoft Docs?

It's a pretty massive subject. I would avoid all the HTML/CSS/JavaScript aspect of ASP.NET, your not making a website with separate pages, so write your HTML/CSS/JavaScript as a “single page app” / “normal game”, and just drop the final “index.html”, “app.js”, etc. in the web directory.

There going to steer you to using a database. Again it's really not designed for what you are talking about at all. It is often desirable for websites to have many separate processes, for reliability and scalability, so that means no objects/memory shared between requests ("stateless"), they read/write everything to a database generally. Again not really what you want, Kestral can be run as a single process, then it is C#/.NET, so if you make a Singleton/global, and access that from two different requests, it will be “the same object”.

I am not really sure how much value your going to get out of a full web platform really, and your still at the mercy of the users browser.

Yes, the capabilities of each browser and version are always a challenge when developing anything for the web, but at the moment it really is the platform I know best and the most accessible to a screen reader. I suppose what I mainly want is a way to take some of the burden off runtime processes. Using just JavaScript means that the game basically has to rebuild itself every time it's opened or even every time a page is refreshed. But, as I said, I'm not familiar with Electron or the other technologies you mentioned, so I'll look into those and see if I can't wrap my head around what I need. (Being self-taught means I usually need to find explanations to explain explanations to explain explanations. lol)

None

Advertisement

@SyncViews I've only just started looking into it, but it does look like Electron might be a really good option. I'll need to learn Node.js first as it uses a lot of the same script, but so far that hasn't been too bad. Thanks a lot for your help. :D

None

This topic is closed to new replies.

Advertisement