Skip to main content

News

Topic: embedding sphere into a browser (Read 16071 times) previous topic - next topic

embedding sphere into a browser
is it possible to embed a game that u make in sphere onto a webpage and have a visitor to the site download support for the game? u kno like a flash game...

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: embedding sphere into a browser
Reply #1

is it possible to embed a game that u make in sphere onto a webpage and have a visitor to the site download support for the game? u kno like a flash game...


Not currently. Eggbert had a way of downloading games to play on your computer, but it was by no means an embedded Sphere engine. I was going to do this but never got around to it.

In fact I'm waiting on pixi.js to have a bit more support (well fonts at least), and then perhaps I'll use that to make a webGL implementation of Sphere. With a JS to JS interface, rather than the C++ to JS interface of a desktop engine. Plus it would be supported on all OS's and mobile phones.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

Re: embedding sphere into a browser
Reply #2
Yeah, Sphere is JavaScript and when I heard the first time of HTML5 and all the stuff that comes with it, I was thinking about a HTMLSphere. Last week I tried to have a update/render loop running in HTML and Sphere using the same game scripts. It was working. Rectangle() was drawing a rectangle in my webpage and in sphere. The problem is that it requires the main game loop written in a specific way, which is not cool if you want to support already written sphere games. Also the MapEngine() call is a problem, because in Sphere it does not return as long the map engine runs... For performance reasons I want to use window.requestAnimationFrame(), but that stands against the way how sphere works with its FlipScreen() rendering...

Re: embedding sphere into a browser
Reply #3

Yeah, Sphere is JavaScript and when I heard the first time of HTML5 and all the stuff that comes with it, I was thinking about a HTMLSphere. Last week I tried to have a update/render loop running in HTML and Sphere using the same game scripts. It was working. Rectangle() was drawing a rectangle in my webpage and in sphere. The problem is that it requires the main game loop written in a specific way, which is not cool if you want to support already written sphere games. Also the MapEngine() call is a problem, because in Sphere it does not return as long the map engine runs... For performance reasons I want to use window.requestAnimationFrame(), but that stands against the way how sphere works with its FlipScreen() rendering...


so yes it could but it would require heavy modding?

personally i think the capability to put a sphere game into a browser like a flash game could really let sphere grow

Re: embedding sphere into a browser
Reply #4
I think that a solution like JavaSphere would be the best bet for that. Maybe even just a modified version of JavaSphere.

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: embedding sphere into a browser
Reply #5
The hardest part, really, about re-implementing Sphere for web usage seems to be recreating all the default map engine logic. Besides relying on a stable animation loop, it also assumes all the underlying pieces (and nothing more) are already taken care of, IIRC.

Re: embedding sphere into a browser
Reply #6
Haha, yes, the map engine ^^ Were there ever a running rework if it?

To be honest I do not really think the sphere map-engine is something I would port to html. I think it is not worth the effort. I would rather give radnens map editor the ability to export maps to json and create a new js based map engine, that can read those maps. it would then be usable in both environments...

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: embedding sphere into a browser
Reply #7

Haha, yes, the map engine ^^ Were there ever a running rework if it?

To be honest I do not really think the sphere map-engine is something I would port to html. I think it is not worth the effort. I would rather give radnens map editor the ability to export maps to json and create a new js based map engine, that can read those maps. it would then be usable in both environments...


You're right, an exporter would be a great idea. But, I won't make such an exporter until a new map specification has been made, and I've got a lot of other stuff to do as well.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

Re: embedding sphere into a browser
Reply #8
Of course this was not a direct feature request^^ don't worry :)

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: embedding sphere into a browser
Reply #9

The hardest part, really, about re-implementing Sphere for web usage seems to be recreating all the default map engine logic. Besides relying on a stable animation loop, it also assumes all the underlying pieces (and nothing more) are already taken care of, IIRC.

In my experience, another hard part is game loops themselves. Sphere games usually rely on some infinite while loop, while Javascript on the web doesn't work that way at all (it prevents the page from updating, ever). Unless worker threads could somehow fix this?

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: embedding sphere into a browser
Reply #10
There are a few HTML5 JS game engines that pull off the game loop portion easily, so I'm sure we can study one or two to see how it's done cleanly on the web.

Re: embedding sphere into a browser
Reply #11
Yes, worker threads I am already using in my experimental solution. With them the requirescript function is very easy to implement. They also solve partially the problem with that while loop as main game loop. But I think in the end there would be a solution that can not get best performance because we try to emulate spheres behavior. I think it will be much better to write games in a way that they are good on both platforms by providing a layer written in js that hides the differences of both platforms.

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: embedding sphere into a browser
Reply #12
Sounds like an idea, but you'd intentionally be breaking any backwards compatibility with existing Sphere games if you do that. It's a choice you could make, I suppose, though any existing games would have to be ported then.

Re: embedding sphere into a browser
Reply #13
I seriously think something like JavaSphere is the way to go. Would it be possible to embed the output of a locally running copy of Sphere into a webpage?

  • Mooch
  • [*][*][*]
Re: embedding sphere into a browser
Reply #14
I looked up Sphere again and re-registered to the new forums specifically because of Canvas, I was gonna make this exact topic. Perhaps with better grammar and spelling >_>

Actually, all I want is a JavaScript API based on Sphere. You know, like LimeJS, gameQuery, Cotton or whatever. I've been having trouble trying to learn how to make games in Canvas, and all those APIs suck. If I had these functions to work with, though, I'd be set.