Me & My Shadow Web Port

Me & My Shadow Web Port

Postby kripken » 27 Mar 2012, 01:18

I took the Me & My Shadow code and compiled it from C++ to JavaScript, here is a demo:

http://syntensity.com/static/mams/mams.html

Will take a few seconds to download and decompress the code + data.

That's the 0.3 release with one bugfix (the menu issue I reported here a few days ago) and some modifications to remove MD5 hashing and other stuff to make the download smaller. Code is here: https://github.com/kripken/meandmyshadow.web

My motivation for doing this was to test Emscripten (open source C++ to JS compiler I work on) on an SDL game. When I saw the 0.3 announcement (I hadn't heard of Me & My Shadow before) it looked like a perfect candidate :) Happily it was pretty easy to port. Looks like it runs pretty well too, basically the SDL commands become native HTML canvas operations which most browsers hardware accelerate these days.

If there is interest in the Me & My Shadow project in running on the web, I can clean up my code and provide a patch. I think it could be cool, imagine if we had a website where you could create and upload levels easily, and pick and play other people's levels as well just by visiting a link.
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Re: Me & My Shadow Web Port

Postby acme_pjz » 27 Mar 2012, 04:21

Wow, it's amazing :cool: Although downloading contents takes a few minutes due to slow web connection, and the game runs a bit slowly...

BTW If we want to running the game on the web, how do we handle user profiles?
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: Me & My Shadow Web Port

Postby acme_pjz » 27 Mar 2012, 04:22

And if you want to try some crazy one, try The Legend of Edgar viewtopic.php?f=22&t=26 http://sourceforge.net/projects/legendofedgar/
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: Me & My Shadow Web Port

Postby kripken » 27 Mar 2012, 05:30

The speed the game runs depends on the browser and if it uses hardware acceleration, I think. Which browser and OS are you on? And what graphics card?

Over here, in Firefox nightly, linux, some nvidia card, it looks like it runs at about the same speed as the natively compiled game.
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Re: Me & My Shadow Web Port

Postby kripken » 27 Mar 2012, 05:36

Legend of Edgar looks cool, thanks. Not sure I'll have time soon for another game port, but I'll add that to the list of possibilities when I do (another option is SuperTux).
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Re: Me & My Shadow Web Port

Postby odamite » 27 Mar 2012, 10:57

Hello kripken,

Wow, this is just awesome... I didn't know that something like this could be even done! Congratulations on the port and Emscripten itself! They're both just great. :D

But I'm afraid that I've found some problems:
  • Game is a little slow even with Linux, hardware acceleration (nvidia card) and Firefox 11. Even slower when dimming is used and text is rendered (not so sure about this one)
  • Game crashes when there should be a listbox (see Addons or key configuration dialog)
  • No custom fonts (not a big deal..)
  • Some GUI elements aren't working (like some message dialogs, text fields)
  • No music/sound

On the whole your port is very good. The gameplay itself works which is the most important thing. I think we can host/link it on the official website. Keep it up :)
User avatar
odamite
 
Posts: 166
Joined: 16 Jan 2012, 16:28

Re: Me & My Shadow Web Port

Postby TheAncientGoat » 27 Mar 2012, 11:31

Works at basically native speed for me on Arch, Chrome 18. Awesome work Kripken!

Hmm, the switch on level 16 doesn't seem to work
User avatar
TheAncientGoat
Community Moderator
 
Posts: 518
Joined: 27 Dec 2009, 19:06

Re: Me & My Shadow Web Port

Postby ctdabomb » 27 Mar 2012, 13:35

this is totally awesome!!! though the fonts were a bit messed up and it took a while to load(ubuntu 9.10 i think) but the game wasn't slow at all though level loading i had to double click to play because the message didn't pop up after the first click. ;)
kripken {l Wrote}:Legend of Edgar looks cool, thanks. Not sure I'll have time soon for another game port, but I'll add that to the list of possibilities when I do (another option is SuperTux).

supertux would be sweet(its the game i work on) :D
Some people are like slinkies... not really good for anything, but you still can't help smiling when you shove them down the stairs.
ctdabomb
 
Posts: 1075
Joined: 13 Dec 2011, 21:21
Location: halfway there

Re: Me & My Shadow Web Port

Postby acme_pjz » 27 Mar 2012, 13:35

Hi kripken,

I'm using Firefox 11, Windows XP SP3 32-bit, graphics card Nvidia 9300M GS

kripken {l Wrote}:... (another option is SuperTux).


Unfortunately, newest version of SuperTux uses OpenGL for drawing... and I don't know if your cross-compiler can handle OpenGL (WebGL)...
Some of my open source games on GitHub
User avatar
acme_pjz
 
Posts: 665
Joined: 10 Dec 2009, 15:32
Location: PeeKing, China

Re: Me & My Shadow Web Port

Postby ctdabomb » 27 Mar 2012, 13:47

acme_pjz {l Wrote}:Unfortunately, newest version of SuperTux uses OpenGL for drawing... and I don't know if your cross-compiler can handle OpenGL (WebGL)...

they was an option to use SDL instead of OpenGL, but that is currently broken and no one has bothered to fix it. (this is a bit off topic and should be moved to the supertux forum if we want to continue it)
Some people are like slinkies... not really good for anything, but you still can't help smiling when you shove them down the stairs.
ctdabomb
 
Posts: 1075
Joined: 13 Dec 2011, 21:21
Location: halfway there

Re: Me & My Shadow Web Port

Postby Tedium » 27 Mar 2012, 15:26

:( I didn't for me. I'm using firefox 10.0.2 on linux. FF crashes after decompressing.
User avatar
Tedium
 
Posts: 122
Joined: 19 Oct 2011, 10:40

Re: Me & My Shadow Web Port

Postby kripken » 27 Mar 2012, 15:51

Fonts are incorrect, yeah. I don't parse the fonts from the game into a web-compatible format, I just render the browser's arial font. So it looks weird ;)

There is a bug with the switch in level 16, I saw that too. Might be related to the fact that other stuff isn't saved either, if you finish a level then it forgets and only lets you start level 1 from the menu. Maybe I messed something up when I disabled some of the file stuff?

No sound, yeah. I haven't implemented SDL sound in emscripten yet.

About the speed, seems fast in newer browsers (FF14, Chrome 18), slower in older ones (FF11). Crashes for me on Chrome 18 at about level 10 though. And Opera can't load the game for some reason.

Some GUI elements crash. They do synchronous updates, which are impossible in JS. We would need to make them async (like I made the main game loop) for them to work.

Most of this stuff is fixable. If we want to finish this port and get it all working then let's do it! :) I posted about it now because I thought it was enough to show that it's even possible, and because the rest of the stuff would be much easier to do with the help of someone that knows the game code (like why the switch on level 16 turns but doesn't move anything).
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Re: Me & My Shadow Web Port

Postby MCMic » 27 Mar 2012, 17:10

This is amazing :-o
User avatar
MCMic
 
Posts: 723
Joined: 05 Jan 2010, 17:40

Re: Me & My Shadow Web Port

Postby Edward_Lii » 27 Mar 2012, 17:45

Hello kirpken,

First of all I want to say this is amazing! :D
Most of the things have already been pointed out in this thread (fonts, sound/music, etc...)

kripken {l Wrote}:If there is interest in the Me & My Shadow project in running on the web, I can clean up my code and provide a patch. I think it could be cool, imagine if we had a website where you could create and upload levels easily, and pick and play other people's levels as well just by visiting a link.
...
Most of this stuff is fixable. If we want to finish this port and get it all working then let's do it! :) I posted about it now because I thought it was enough to show that it's even possible, and because the rest of the stuff would be much easier to do with the help of someone that knows the game code (like why the switch on level 16 turns but doesn't move anything).

There's definitely interest in this port, it can be used for a lot of things.
We should keep the desktop version as our base but the web version can be used for testing before users download, showing replays, showing level(pack)s, etc..
My only concern is that a lot of users will still use an older browser and by running this version could get a wrong impression of the game (slow/not working).

Anyway, keep up the good work, if you've got questions about the code just ask on the forums or on our irc channel (#meandmyshadow at freenode). ;)
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Me & My Shadow Web Port

Postby kripken » 27 Mar 2012, 18:32

Edward_Lii {l Wrote}:There's definitely interest in this port, it can be used for a lot of things.
We should keep the desktop version as our base but the web version can be used for testing before users download, showing replays, showing level(pack)s, etc..
My only concern is that a lot of users will still use an older browser and by running this version could get a wrong impression of the game (slow/not working).

Anyway, keep up the good work, if you've got questions about the code just ask on the forums or on our irc channel (#meandmyshadow at freenode). ;)


Cool, would be great if you or others are interested to work with me to finish this port.

First thing that would be great is if someone could take a look at the diff on src/* that I did,

https://gist.github.com/2218214

I mainly removed code like md5 hashing, but I'm worried I broke something because (1) finishing levels doesn't make them startable, only level 1 is startable, and (2) the switch on level 16 gets pushed down, but nothing happens.

If nothing looks wrong in the diff, any tips regarding what we can do to debug those issues would be great.
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Re: Me & My Shadow Web Port

Postby Edward_Lii » 27 Mar 2012, 18:45

Hello kripken,

kripken {l Wrote}:I mainly removed code like md5 hashing, but I'm worried I broke something because (1) finishing levels doesn't make them startable, only level 1 is startable, and (2) the switch on level 16 gets pushed down, but nothing happens.
If nothing looks wrong in the diff, any tips regarding what we can do to debug those issues would be great.

There's nothing wrong with the diff. ;)

The first issue is probably caused by the fact that the progress isn't really stored in memory but loaded each time the level select menu is visited.
I think this can be avoided by commenting the lineloadProgess(s1) in LevelSelect.cpp:215.

Not sure what is causing the second issue though. :think:
The switch should broadcast an event to the other blocks and if the moving blocks receive that event message they should start moving.
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Me & My Shadow Web Port

Postby kripken » 27 Mar 2012, 23:57

Thanks for the tips Edward, I'll check that stuff out soon I hope.

Meanwhile I got sound effects to work. So far only in Firefox, I don't see how to play them in Chrome - the Audio elements are created from binary data, and Chrome lacks Blob constructors which are necessary to set mimetypes on object URLs.
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Re: Me & My Shadow Web Port

Postby kripken » 28 Mar 2012, 02:23

Also added music support now. (Like sound effects, it works in Firefox but I don't know how to get Chrome to run it. I asked on Twitter and one of the Google people pinged a colleague of his that might be able to help.)
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Re: Me & My Shadow Web Port

Postby Edward_Lii » 04 Apr 2012, 17:35

Hello kripken,

The web port also crashes Firefox for me, I though this was because of an older version of FF (11.0).
But recently I updated Firefox to version 12.0 and it still crashes, while on a different machine runs fine (also FF 12.0).

So after some more testing I think the web port crashes when using a 64-bit version of FF.
The machine it worked on was running 32-bit openSUSE and FF 12.0.
On my 64-bit system I downloaded a 32-bit FF binary and it worked flawless.

Hope you will be able to fix this.
From,
Edward_Lii
User avatar
Edward_Lii
MnMS Moderator
 
Posts: 777
Joined: 20 Dec 2010, 16:46

Re: Me & My Shadow Web Port

Postby MCMic » 04 Apr 2012, 18:50

Edward_Lii {l Wrote}:Hope you will be able to fix this.

Sounds more like it's a Firefox problem, maybe you should report a bug.
User avatar
MCMic
 
Posts: 723
Joined: 05 Jan 2010, 17:40

Re: Me & My Shadow Web Port

Postby kripken » 05 Apr 2012, 04:03

Edward_Lii {l Wrote}:Hello kripken,

The web port also crashes Firefox for me, I though this was because of an older version of FF (11.0).
But recently I updated Firefox to version 12.0 and it still crashes, while on a different machine runs fine (also FF 12.0).

So after some more testing I think the web port crashes when using a 64-bit version of FF.
The machine it worked on was running 32-bit openSUSE and FF 12.0.
On my 64-bit system I downloaded a 32-bit FF binary and it worked flawless.

Hope you will be able to fix this.


64-bit builds are considered experimental I believe. But if that is a build from mozilla.org than it should auto-submit a crash report. You can see them in about:crashes afterwards. If you get that, would be interesting to see a link to those.
User avatar
kripken
Syntensity Moderator
 
Posts: 52
Joined: 12 Jan 2010, 13:45

Who is online

Users browsing this forum: No registered users and 1 guest