Skip to main content

News

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

0 Members and 1 Guest are viewing this topic.
Re: embedding sphere into a browser
Reply #30
Typed arrays are pretty useful for that sort of thing.

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: embedding sphere into a browser
Reply #31
@Metallix & @Radnen - do you want a web-sphere repo officially created and Radnen can write the 'pixi' branch while Metallix write the 'threejs' branch?

(edit - created web-sphere repo; also added DaVince so he can get his CanvasSphere stuff onto it as 'canvas' branch or something; enjoy!)
  • Last Edit: May 13, 2013, 03:59:54 pm by N E O

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: embedding sphere into a browser
Reply #32
Sweet a question and it's answer. I don't know how far along I can get but I'll see about pushing to the branch.

@alpha123: nice! But that's not where I'm stuck with binary files. I'm stuck pulling an image out of a file to be used elsewhere in the code.
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

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

(edit - created web-sphere repo; also added DaVince so he can get his CanvasSphere stuff onto it as 'canvas' branch or something; enjoy!)

That's awesome, but I'd rather contribute to other implementations since CanvaSphere was basically crap. Also, I think I lost the code, anyway.

Re: embedding sphere into a browser
Reply #34
Small update: I just had a while( true ) game loop running in the browser :) Web workers are doing the trick ^^

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: embedding sphere into a browser
Reply #35
Do you mind if I steal your idea? :)
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 #36
Its on github in three-sphere branch :) Go for it!

But I am still not sure if that is the way to go... if you remove the Delay() in the main loop it was blocking my chrome sometimes. Web workers do not support a sleep method :/ That means Delay is currently implemented like you would do it in Sphere 1.6 causing a high CPU usage...

Re: embedding sphere into a browser
Reply #37
I do know that Chrome's V8 has a way of properly sleeping. It might be exposed to script in Chrome (or similarly other browsers) in a browser specific way.

Re: embedding sphere into a browser
Reply #38
It's not exposed to JS as far as I know, although you could probably cook something up involving setTimeout or possibly requestAnimationFrame.

Re: embedding sphere into a browser
Reply #39
Yes, there are currently ways to "sleep" for an amount of time, but no method actually will work like the Delay(ms) function which should return only after that time. At least we have while( true ) that is not blocking the browser ^^ A sleep function would be a nice addition but is not required to emulate the old sphere.

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

Small update: I just had a while( true ) game loop running in the browser :) Web workers are doing the trick ^^

Freakin' awesome. :)

Re: embedding sphere into a browser
Reply #41
I commited a version that renders two rectangles on the canvas. For that while true problem we should maybe introduce an optional game_update function next to the default game function every sphere game needs. Old sphere games can have their while loop in the game function, but new games should use the game_update function to be nicer to the CPU.

old:
Code: (javascript) [Select]

function game() {
    while( true ) {
        // render
    }
}


new:
Code: (javascript) [Select]

function game() {
    // init
}
function game_update() {
    // render
}

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: embedding sphere into a browser
Reply #42
FYI Radnen, I just tried the demo app from your link on my HP Touchpad tablet running Android (unofficial Cyanogenmod 10) and the 'touch' event doesn't register as a 'click' event and 'swipe' doesn't analogue to arrow keys or anything like that. For the web engine we may want to consider handling tablet/smartphone input methods as well as standard inputs.

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

FYI Radnen, I just tried the demo app from your link on my HP Touchpad tablet running Android (unofficial Cyanogenmod 10) and the 'touch' event doesn't register as a 'click' event and 'swipe' doesn't analogue to arrow keys or anything like that. For the web engine we may want to consider handling tablet/smartphone input methods as well as standard inputs.


Good thing to add, will get to it when I can.
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

  • Rukiri
  • [*]
Re: embedding sphere into a browser
Reply #44
I personally do not think this is a good idea, unless you're talking about sphere 2.0, sphere is ancient.
If you want to develop games for the web try out stencyl, wait for 3.0 though as Haxe will be the default language.