I have been researching current web technologies such as java script, ruby/rails, python, ajax, html5, etc for an upcoming project (day job). It has occurred to me that capabilities such as html5's canvas, java script's interval timer and asynchronous request, and a little help from the server via PHP, Python, Ruby or C that it ought to be possible to implement some sort of runtime game engine that could run in a browser.
As a mater of intellectual curiosity I would be interested in discussing this possibility and it's pro's and con's with those of you who are more familiar with the specific tech involved. We can use AGS as a common basis for the discussion since we are all very familiar with it and it's capabilities.
Let's limit ourselves to the technical issues. This far removed from being a practical suggestion for AGS and talking about practical, logistical, political, and other aspects would be uninteresting and counter-productive at this point.
I have a superficial knowledge and a naive point of view at best but here is what I think I know about all this:
HTML5- HTML5 has a canvas element that allows one to draw and do other sorts of graphical manipulations. It supports bit map and SVG images. I don't know the full extent of it's capabilities or how they would compare with what Allegro offers.
- HTML elements (especially <div> and <span>) can have background images and can be dynamically moved around, animated and generate events in response to user interaction.
Java Script
- JS can be used to perform graphical operations such as moving and animating sprites on the HTML5 canvas element.
- JS has an interval timer that can be used trigger a game scan event.
- JS can respond to user clicks on various document elements by running event handler and event listener functions.
- S can parse and extract info from specific elements in an XML/HTML document
- JS can asynchronously request additional information from the server and then update the current browser window without reloading the entire thing.
Basic Engine Design
- Client Side - Nearly all of the engine would execute on the client side. The server would only be needed to download the required JS and HTML/XML game files. Perhaps it would also be needed to work around client side limitations (SAVE GAMZE come to mind).
- Elements - For each game element (i.e. characters, objects, hotspots, etc) there would be corresponding HTML elements so that events could be generated.
- Game Scan - Items requiring periodic execution could be handled using the JS setInterval() functionality. Event handlers are natively e
executed asynchronously so they it's not necessary to implement a polling scheme here to implement them. If synchronism is required/desired it could be implemented by having the asynchronous event handlers sleep until the occurrence of a game scan.
- Animation - Animation could be achieved using the above mentioned setInterval(). Animation frames and loops for a given entity could be stored in a single file. An animation procedure would just display different portions of the file for each loop/frame.
- Sounds & Video - I don't know much about this except that HTML5 now has native support for video. I think the same element can also be used to play audio and that there are other legacy methods.
- Built-in Functions - It's possible to create objects in JS so it ought to be possible to implement most AGS built-in functions in JS. AGS uses managed objects so there may need to be a JS method of unloading unused objects to prevent memory leaks.
- Game Script - JS has a very similar syntax and capabilities as AGS script with a few differences that would appear to be easily translatable from one language to another.
- Main Game Files - The main game files would consist of an XML/HTML file that would provide a basic DOM structure for the game and contain links to the required java script libraries and global game items such as character and inventory item graphics, sounds, etc, etc. It would also contain a link to a java script equivalent to AGS's global script.
- Room Game Files - The room files could be an XML/HTML file that contains room specific definitions and links to a java script equivalent to AGS's room script and links to room specific items such as object, background, and other graphics, sounds, etc. The room XML file would be loaded by asynchronous request (AJAX) and then used to update the current browser screen.
- Game Data - JS uses loosely typed variables which seem like they are capable of supporting all of AGS's data types. The problem is that JS running in a browser does not have file I/O capability. It would seem like the server would need to create a session for the player and keep track of persistent room data so that if a player interacted with a room, left and then returned the room would be in the same state as when the player left. In this case SAVE GAME could be implemented as a download/upload of the session file. This file could be in the form of a JS script file so restore game could just be a load and execute of the save game file? The down side of course is that the server has to consume some CPU resources executing code; the upside is that people will need to access the website if they want to play.
- Performance - Obviously if someone has a 386 desktop and a dial-up modem they wouldn't be pleased with the performance of such a game engine. However with broadband and Multi-Ghz/GB machines it's not clear if performance would be an issue or not. I suppose it would be highly dependent on the actual implementation of the JS components. I would be surprised if loading of the game and graphical files were a problem in this respect. My gut feel is that JS execution may be a problem.
That's all I can think of right now. I'd be interested in what other people think about this. What are the potential problems and their potential solutions? What other better ways are there of implementing such an engine? If it were possible how useful or widely used would it be? AZny other related ideas?
Let's just have an interesting conversation about teh tech .... ;)
I would keep everything but saves on the server side and just process mouse clicks. But to re-make the engine in those technologies would require much much much coding. Or even mucher! Or even the muchest!
EDIT:
and seriously...It's much better to just run the game on the server and send the rendered frames to the user just like microsoft and others are planning to do lately.
RickJ, I'm glad you're actually putting this into discussion. First, I think, without wanting to kill anyone's dream, that it would require someone to actually port/transform AGS. But if we think very simple, I think in a very short period of time, it can be done.
Also just noticed the part of your post, that includes what I've said, so I'm going to draw a line and actually get on with details.
Literally:
HTML 5
Seems very useful, if indeed it ends up equally or even more flexible than Allegro. I think it can also provide more abilities and functions to AGS.
JS
This is actual the core of your ideas, and to no wonder. JavaScript pretty much dominates the whole internet nowadays, on the sector of flash based applications.
BED
I don't think it's a bad thing to have savegames on the client side. I'm not sure however how parts of the code that run from the server side, would actually help out performance. On a room change it's like okay to load the individual room script. It should be noted that module scripts and global script should run on the client side, otherwise it would seriously mean a waste in performance.
Also, I'm not very familiar, so I'm actually wondering on two other things: D3D capabilities and performance with the equivalent Drawing Surface and Dynamic Sprite functions on JS and HTML 5.
Check out http://code.google.com/p/js-gam/
There was another javascript proof of concept called "Nature Boy" with a doom sprite walking around a desktop but I can't find it again...
That's an exciting idea! :D
Well, very well put outlines there. AGS has no native network support, and hence it does not need to communicate to a server. Running something like this entirely client-side would be a great performance improvement actually. Todays JavaScript interpreters are quite good, and can do pretty amazing things even on low-end computers; It could work, absolutely. I'm not familiar with HTML 5, but I do know it's still in development. It will take some time before all browsers support it and all of it's features.
About save games: it is perfectly possible to generate a downloadable game state XML file, but I would offer the possibility to store it server-side too. Not because it would mean people have to login or something, but mostly because not all users will understand what a XML file is, and how it relates to the game. Server side will be more convenient for a lot of folks I expect. That will be the only thing that needs to communicate with the site after the game content has been downloaded, well that's not so bad. You could also generate high-scores and achievements in that fashion. But I would still allow the possibility to store it in a XML file, for the more experienced users that like to play it completely offline.
Quote
... But to re-make the engine in those technologies would require much much much coding. Or even mucher! Or even the muchest!
It's given that a lot of work goes into making a runtime game engine (and even more in the IDE part of it) and that some languages are easier to work with than others. The JS language has a syntax similar to C/C++ and Java and seems to be much more forgiving in many respects than either of the other two. So I am curious as to why it would be so much more work in JS?
Quote
and seriously...It's much better to just run the game on the server and send the rendered frames to the user just like microsoft and others are planning to do lately.
Again I curious, in what way would it be better? The obvious down side is that it would not scale as well and consume much more server resources. Performance would be held hostage by server/ISP/Internets response. If I understand correctly a rendered screen would be downloaded every 40ms or so which would require much greater bandwidth.
Quote
I don't think it's a bad thing to have savegames on the client side. I'm not sure however how parts of the code that run from the server side, would actually help out performance.
It's preferred to keep save games on the client side. The problem is that browsers will not allow JS to do file I/O on the client side. So on a room change any room variables that need to be persisted will have to be sent to the server and stored in a session file. If the player re-enters that room then the data will be sent back to the client. If the player does a save game then the server will write the session data to a file and the client will perform a download operation.
Quote
On a room change it's like okay to load the individual room script. It should be noted that module scripts and global script should run on the client side, otherwise it would seriously mean a waste in performance.
Right, that's what I intended to say in the first post. Sorry if it was confusing.
Quote
Also, I'm not very familiar, so I'm actually wondering on two other things: D3D capabilities and performance with the equivalent Drawing Surface and Dynamic Sprite functions on JS and HTML 5.
I believe the HTML canvas element is 2D only. I don't think there is anything in HTML or the Canvas element that gives access to lower level drivers or optimizations. So I guess it would be up to the specific browser to take advantage of things like D3D. I don't know any more than you and am mostly guessing.
The advantage of having some game logic on the server side is that it can be used as copy protection and prevent cheating by reverse engineering. The disadvantage is that you need a working connection to play. Maybe a way in which the connection was only used rarely (savegames, changing chapters, changing rooms) might be best?
In theory it's a great idea - HTML5 should, at some undetermined time in the future (it has been a slow process) gain support from all the main browsers, including smartphones etc. That near-universal support would be a fantastic way of easily distributing games to the broadest spectrum of people.
In practice, I can't help but feel that writing an engine of that size and complexity in Javascript would be an absolute nightmare. It's hard enough in a proper language. Even with the original source code, it would take an incredible amount of dedication and perseverance on behalf of the coder.
A lot of people are hoping that HTML5 will render RIA plugins (Flash, Java, Silverlight, Unity etc) obsolete, and I can understand the reasons for wanting reliance on proprietary technology removed. But to be honest, I just can't see HTML5 & Javascript replacing the functionality and level of quality these plugins provide anytime soon.
Firefox 3.5 supports OGG video in HTML video element. You can see a short demo at the link below (if you have firefox of course). It's my understanding is that it's a problem of politics rather than implementation. It's also my understanding that Firefox and Safari are going ahead with implementation even though proprietary vendors don't want to agree.
http://en-us.www.mozilla.com/en-US/firefox/3.5.8/firstrun/
As follow-up to this discussion I found this video lecture about the capabilities of HTML 5. It answers some of the questions that came up in this thread. So for anyone interested please feel free to enjoy:
http://developer.yahoo.com/yui/theater/video.php?v=neuberg-html5
This might not fit into your discussion but you could give this a look if you are looking to put your games in a browser. Works well :)
http://www.osakit.com/
InsertCoin25
Quote from: InsertCoin25 on Thu 12/08/2010 02:26:06
This might not fit into your discussion but you could give this a look if you are looking to put your games in a browser. Works well :)
http://www.osakit.com/
InsertCoin25
Seems totally interesting as a matter of fact I'm checking this out. Thanks a lot for that link!! :D
(I know this is an old quote but anyway)
QuoteGame Script - JS has a very similar syntax and capabilities as AGS script with a few differences that would appear to be easily translatable from one language to another.
The main problem would be transforming "blocking"/"synchronous" functions to "non-blocking"/"asynchronous" ones. For example, the AGS script:
function myfunc()
{
player.Say("Hi there!");
npc.Say("Hello!");
Wait(40);
player.Say("Well... goodbye.");
}
...now, the player.Say() call may take several seconds to complete. But that isn't allowed in Javascript - if code takes too long to complete, the whole browser/tab can hang, or it will pop up a message saying something is taking too long to complete. So you would need to find a way to transform "blocking" to "nonblocking". In Javascript you can pass around functions like variables, so you can pass a function that says what to do once an action has been completed:
function myfunc()
{
player.Say("Hi there!",
function() {
npc.Say("Hello!",
function() {
Wait(40,
function() {
player.Say("Well... goodbye.");
});
});
});
}
Ugly! And also, what do you do if myfunc() wants to return a value...? And how do you deal with while() { } loops...? ;D
Not an impossible problem to overcome, probably, but a pretty big hurdle.
Like others I agree that it's very (too much) ambitious to start a new engine from scratch.
I'd recommend to put more work into converters, like the limited one that exists for XAGE. It'd be cool if a game could be easily exported by its maker, to be played in other, stable engines targetting other platforms.
For instance:
- a web browser (using, for example, the engine shown earlier in this thread),
- Flash (with Lassie),
- XBox (using XAGE),
- etc.
RickJ On HTML5:
QuoteI don't know the full extent of it's capabilities or how they would compare with what Allegro offers.
Hey Rick, I'v done some research into HTML5 (I've been developing in it lately) and tracked this down:
http://code.google.com/p/quake2-gwt-port/ (http://code.google.com/p/quake2-gwt-port/)
HTML5 is
VERY powerful indeed. I have very little doubt it could be used as a SCUMM interpreter or a platform for our AGS games.
Cheers,
Sparky.
Quote from: Dualnames on Thu 12/08/2010 02:47:04
Quote from: InsertCoin25 on Thu 12/08/2010 02:26:06
This might not fit into your discussion but you could give this a look if you are looking to put your games in a browser. Works well :)
http://www.osakit.com/
InsertCoin25
Seems totally interesting as a matter of fact I'm checking this out. Thanks a lot for that link!! :D
I tried a lot to make this work, but the program always ended up crashing on me, and I had to re-type everything again and again.
If anyone managed to make this work, or does in the future, show us and tell us how. ;)
Quote from: subspark
HTML5 is VERY powerful indeed. I have very little doubt it could be used as a SCUMM interpreter or a platform for our AGS games.
HTML 5 is powerful but like mOUXX said. If we're gonna take lots and lots of trouble to export a game into some other platform, it's not ideal. Not to be the asshole,but we all rather script our own engine than bother to do the same amount of work to covert our AGS game to another platform.
It would actually be better if CJ handed off the source to someone to build an interpreter in something like Flash since it's so widely used. I'd actually be all behind this and would love a crack at such a project since I've been itching to make the move to web-based games in actionscript but just haven't had enough of an excuse. It would be lovely to be able to host ags games directly through web apps so people could either play them virtually on my site or download them to play locally. Now, I probably wouldn't use it for large games, but for short games it's a great way to get people playing your stuff without much hassle. A quick trip to kongregate.com should convince anyone of this...I've wasted so many hours at that site!
I'm with progz on this one.
I'm afraid when it comes to short games the browser is where it's at and where it will stay.
Although maybe HTML5 would be a better renderer.. i hate flash.
I must agree with Calin. Flash is sliding down the www gurgler.
Cheers,
Sparky.
I've been working on a prototype of a port of the AGS demo game in Flash. (Sorry HTML5 fans.) It's not based on any official AGS code, so it won't be compatible with existing compiled game formats and would need a special editor plugin to export a game (which I haven't made, this is a hardcoded demo specific to the game). There's only one room and the inventory GUI doesn't work so far:
http://octospherics.com/toolbox/Loader.swf
flash has the very serious problem of not being able to catch right clicks.. i guess you could emulate it with ctrl-click or something.
Yeah, that is a problem that would need to be overcome on a game-by-game basis. Flash also won't let you reposition the mouse or restrict it to a section of the screen, although thankfully those AGS features are rarely used. (Also, personally I stop normal HTML/JS pages from overriding the right-click context menu behaviour too, with the advanced JS settings in Firefox, because of crappy sites that abused it to pop up "DON'T STEAL FROM ME!!!", so for me HTML5 would have the same problem...)
One cool thing that Flash can do: since version 10, it is capable of dynamic audio generation. What that means is that Flash programs can support music formats that weren't built in, like .MOD:
http://www.photonstorm.com/flod (pure-Flash .MOD player)
I've also seen a work-in-progress one for .XM which was already close to completion. Because of these I'm sure a .MIDI one would be possible too, although I haven't found one yet.
The right click issue is a pain :( but the rest looks splendid!
I'd be very interested in a web-browser port, either Flash or combination of html5 or JavaScript, as long as it works ;D I think HTML5 also has a lot of potential, but is yet to mature, so maybe in the future. JavaScript would be a lot of work I guess.
Hey that looks pretty cool Denzil!
On a semi-related note, I wonder if anyone's working with porting to Silverlight?
Sparky.
XAGE is silverlight compatible.
Quote from: Calin Leafshade on Fri 20/08/2010 09:34:43
XAGE is silverlight compatible.
As of a few minutes ago, XAGE now runs natively on Linux too:
(http://i360.photobucket.com/albums/oo42/clarvalon/XNA%20-%20PnC%20Engine/XAGEUbuntu2.png) (http://i360.photobucket.com/albums/oo42/clarvalon/XNA%20-%20PnC%20Engine/XAGEUbuntu2.png)
Coming Soon: AGS games, playable on a microwave (http://www.handlewithlinux.com/linux-washing-cooking) near you.
That reminds me i should send you the stablest of versions of HHGTG. But I always forget it. ;)
Nice work peoples!! Wow we're really starting to branch AGS out now aren't we!
QuoteXAGE is silverlight compatible.
Thats right I forgot.
Coolies.
Quote from: clarvalon on Sat 21/08/2010 03:02:51
Quote from: Calin Leafshade on Fri 20/08/2010 09:34:43
XAGE is silverlight compatible.
As of a few minutes ago, XAGE now runs natively on Linux too:
(http://i360.photobucket.com/albums/oo42/clarvalon/XNA%20-%20PnC%20Engine/XAGEUbuntu2.png) (http://i360.photobucket.com/albums/oo42/clarvalon/XNA%20-%20PnC%20Engine/XAGEUbuntu2.png)
Coming Soon: AGS games, playable on a microwave (http://www.handlewithlinux.com/linux-washing-cooking) near you.
How far you into completing the engine? I would love to use this.
Bearing in mind that I stated XAGE was 70% complete back in 2008, it's fair to say that providing workable estimates is not my forté. I have a bad habit of adding new functionality and new platforms rather than focusing on polish and regular releases (my SpecialLadyFriend rather sardonically accused me of planning to add support for unicorns). Plus I have young, growing family and other burdens commitments so I'm a bit like Vince Twelve but without the chronic insomnia.
Life story aside, the engine is stilll undergoing some large changes in terms of handling interface. I'm using Ben's ! to help me iron out a few issues before returning to Time Gentlemen, Please. XAGE will be a lot closer to v1.0 after I'm done with those.
So Clar, from what I understand, XAGE is its own Game engine, yet you can convert AGS Games to XAGE and play it on several systems?
Yep, that's right.
I've started my own JavaScript library (MIT License) for bitmap mask-based path finding which might be a useful component to anyone interested in doing a point and click adventure game, or game engine, in JavaScript/HTML5.
Here is a simple demo (should work in recent versions of Firefox, Chrome, Opera):
http://mbpf.googlecode.com/svn/trunk/js/test/mbpf-html5-test-simple.html (http://mbpf.googlecode.com/svn/trunk/js/test/mbpf-html5-test-simple.html)
Hey! Neato pathfinding. :)
Sparky.
Incidently, have you talked to the people behind sarien.net? They have somehow brought the old Sierra games, like Space Quest, Police Quest and King's Quest to the web. These games are not built in AGS, of course, but the functionality requested is almost the same. Unfortunately the games are still buggy, I haven't been able to access the inventory, for example, but it's there. As far as I can tell (http://sarien.net/about), there is still a lot of manual work to do to convert a game, but maybe they have some ideas about what not to do.
One neat thing is game save, which is solved by asking the user to bookmark the saved page, the url of which has a special hash added to it when requesting a save, like "http://sarien.net/spacequest2#fDExNCw1MiwwLDAsMHwwLDUsMSw... "
Another thing is the multiplayer functionality, however limited to online chat with the other players in the room at the time.
Not a lot has been covered concerning that project over here, but a search for "sarien" on the forums givs this hit: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37556.0
Quote from: subspark on Tue 17/08/2010 23:40:37
RickJ On HTML5:
HTML5 is VERY powerful indeed. I have very little doubt it could be used as a SCUMM interpreter or a platform for our AGS games.
Actually, there is already someone working on a SCUMM interpreter in JS (mostly based on the ScummVM code), proving it's feasible - I tested it and basically, it works :)
https://github.com/mutle/jsscummvm
Just found a new open source mobile development framework but haven't had a chance to check it out yet. It looks promising and may be relevant to this thread. Thought I'd share.
http://www.phonegap.com/
Also for those interested in flash, right-click was intercepted via AS3 a fair few years back.
Go splat your rat over here:
http://www.uza.lt/rightclick/ (http://www.uza.lt/rightclick/)