Jangaron - new browser-based lightcycle game

General Stuff about Armagetron, That doesn't belong anywhere else...
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

Tank Program wrote:That is awesome. What are the odds of playing full screen against an AI?
Full screen: just a configuration issue. I could also set up four view ports for four players if you like...
AI: No problem in principle, although I think for a browser based game, network play is more important than AI players. Maybe I can port some of the Armagetron AI code to JavaScript?
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

Jangaroo wrote:
Luke-Jr wrote:I'm more interested in Konqueror support than IE ;)
Error: http://www.wuenschenswert.net/jangaron/joo/joo.js: SyntaxError: Parse error at line 3
Error: http://www.wuenschenswert.net/jangaron/: ReferenceError: Can't find variable: joo
Strange... I would have thought that at least the syntax of JavaScript would be standardized. Let's see if I can figure that one out. Can you tell me your Konqueror version?
Okay, found out that Konqueror does not like constructs like

Code: Select all

return function() { return "foo"; };
but, unlike IE, Firefox, and Safari, insists on brackets around returned anonymous functions:

Code: Select all

return (function() { return "foo"; });
I am going to fix this and upload a new version soon!
Last edited by Jangaroo on Thu Jan 17, 2008 4:01 pm, edited 1 time in total.
User avatar
Z-Man
God & Project Admin
Posts: 11717
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

About the network code, we have a working php library for in our svn repository somewhere. But that's just the basic code, you'd need to look at the various WriteSync() messages to know what you need to read from the various message types, and the most difficult bit would be that you'd need to replicate all of those subtle cycle physics settings. Well, or just rely on dead reckoning, that should work to an extent. If you want to go down that road, of course we'll help you to the best of our abilities, but I don't think we'll be concerned too much about compatibility with your game in future versions; we've got enough to worry about staying compatible with our own previous versions.

Same goes for the AI, good luck with it :) It's quite a bunch of ugly code. We have two experimental scripting interfaces for AI, one for ruby and the other for io with a simple proof of concept AI written for each. it doesn't do much more than drive into the direction where there is most space, though.
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

To all the Konqueror fans:
Jangaroo wrote: Okay, found out that Konqueror does not like constructs like ...

I am going to fix this and upload a new version soon!
Grrr... just discovered that Konqueror does not support a feature I really need: you cannot determine the name of a function. :-( While Firefox supports this directly ( (function x(){}).name), I was able to build a workaround for IE by parsing (function x(){}).toString(). But in Konqueror, Function#toString() returns the whole source code of the function save its name!
Will have to find some other workaround or contact the Konqueror developers. Well, after all WebKit can do it, so why not KHTML?
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

Jangaroo wrote:To all the Konqueror fans:
Jangaroo wrote: Okay, found out that Konqueror does not like constructs like ...

I am going to fix this and upload a new version soon!
Grrr... just discovered that Konqueror does not support a feature I really need: you cannot determine the name of a function. :-( While Firefox supports this directly ( (function x(){}).name), I was able to build a workaround for IE by parsing (function x(){}).toString(). But in Konqueror, Function#toString() returns the whole source code of the function save its name!
Will have to find some other workaround or contact the Konqueror developers. Well, after all WebKit can do it, so why not KHTML?
How could it? A function itself has no name... it is assigned to a variable.

function foo() { return "bar"; } is the same as foo = function(){return "bar";}
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

Luke-Jr wrote:
Jangaroo wrote:To all the Konqueror fans:
Grrr... just discovered that Konqueror does not support a feature I really need: you cannot determine the name of a function. :-( While Firefox supports this directly ( (function x(){}).name), I was able to build a workaround for IE by parsing (function x(){}).toString(). But in Konqueror, Function#toString() returns the whole source code of the function save its name!
Will have to find some other workaround or contact the Konqueror developers. Well, after all WebKit can do it, so why not KHTML?
How could it? A function itself has no name... it is assigned to a variable.

function foo() { return "bar"; } is the same as foo = function(){return "bar";}
Theoretically, you are right, this is why I carnt blame the Konqueror developers. I use a trick to get a very neat JavaScript class / method notation. Instead of writing

Code: Select all

function MyClass() { ... }
MyClass.prototype = {
  foo: function(x) { return x+1; }
};
I have a runtime library that allows to write

Code: Select all

joo.Class.prepare(
"class MyClass",[
  function MyClass() { ... },
  function foo(x) { return x+1; }
]);
The library essentially takes a list of functions and assigns them as members. Like I said, in Firefox, IE, and Safari, you can determine the name of a function, which is something different than the name of the variable or field the function object is assigned to. For example, in Firefox, try

Code: Select all

var x = function y() { return "foo"; }; alert(y.name+" / "+x.name); 
The result is "y / y" (not "y / x"), so you see that the name of the "anonymous" function is kept in the function object.

I just find the new syntax more readable, and it is closer to the upcoming JavaScript 2 / ECMAScript 4. So this is why I need to find out a function's "definition" name, and this is why I was disappointed that only in Konqueror, it is not part of a function's toString(). I haven't checked Opera yet, will do so soon. If Opera also refuses, I have to change my JavaScript runtime library and use the "classic" syntax.
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

Or write your code to adhere to the standards anyway...
User avatar
DDMJ
Reverse Outside Corner Grinder
Posts: 1882
Joined: Thu Jun 08, 2006 12:15 am
Location: LA, CA, USA, NA
Contact:

Re: Jangaron

Post by DDMJ »

Jangaroo wrote:You can turn left and right and increase / decrease your speed.
The keys are:
Upper player (orange, "Tron"): Arrow keys.
Lower player (blue, "Flynn"): turn: A-D, speed: W-S
Space: pause game (nice for screen shots).
Maybe you should put the instructions somewhere on the page since I didn't read this and died everytime =/

Very nice game though.
Luke-Jr
Dr Z Level
Posts: 2246
Joined: Sun Mar 20, 2005 4:03 pm
Location: IM: luke@dashjr.org

Post by Luke-Jr »

Under Konqueror 4.0.0, it shows the cycles moving and such, but keypresses go ignored.

Either way, I still would suggest you stick to standards and not assume toString does something it's not defined as doing.
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

Luke-Jr wrote:Under Konqueror 4.0.0, it shows the cycles moving and such, but keypresses go ignored.
I had some problems to find a browser independent way of getting global key listeners to work in Firefox, IE, and Safari. Too bad Konqueror seems to have yet another conception of how to listen to key event globally, but this is not really Konqueror's fault, rather the spec of DOM events is a mess. Hopefully I can figure out that problem, too, but I currently do not have a Konqueror 4 for testing.
Luke-Jr wrote:Either way, I still would suggest you stick to standards and not assume toString does something it's not defined as doing.
This is what the ECMAScript standard (Ecma-262) says:
15.3.4.2 Function.prototype.toString ( )
An implementation-dependent representation of the function is returned. This representation has the
syntax of a FunctionDeclaration. Note in particular that the use and placement of white space, line
terminators, and semicolons within the representation string is implementation-dependent.
I do not rely on white space, line terminators, or semicolons, but would expect the function's name to be included in the "implementation-dependent representation". Since you say it runs under Konqueror 4, the developers seem to have agreed with that view in the meantime. Anyway, the standard is quite vague here.
The JavaScript code that is "prepared" through my runtime library is actually generated from another syntax by the Jangaroo compiler. This other syntax is as close to ECMAScript 4 as is currently possible. So it is quite easy for me to adapt the compiler to produce standard-compliant (or Konqueror-3-compliant :wink:) JavaScript code and recompile the whole Jangaron code so that it should run in Konqueror 3, too.
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

madmax wrote: Doesn't appear to work on Opera neither, works fine on Safari though.

Nice job! :)
madmax, thanx for the compliment and for testing with Opera! I installed Opera 9.25, made a few patches (Opera JavaScript has problems with assignments inside "with"!) and got it running. Unfortunately, Opera seems to try to optimize redraws, which ends up in a mess when using animated Slants (see screen shot). I'm afraid there is not much I can do about it, and Opera is not my main target browser. I guess it is enough of a challenge to make Jangaron run in FF, IE, Safari, and Konqueror... sorry :(
Attachments
Opera's interpretation of Jangaron: I never imagined one could draw such a mess with DHTML...
Opera's interpretation of Jangaron: I never imagined one could draw such a mess with DHTML...
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

Ah, yes, I just minimized a garbled Opera window and restored it, and everything was cleaned up. So definitely an Opera redraw bug. Too bad, seems to run fine otherwise, no probs with JavaScript or graphics besides the redraw problems. Maybe when Jangaron becomes famous :wink:, the Opera guys will fix that...
User avatar
Jangaroo
On Lightcycle Grid
Posts: 38
Joined: Mon Jan 14, 2008 5:02 pm
Contact:

Post by Jangaroo »

Tank Program wrote:That is awesome. What are the odds of playing full screen against an AI?
One more thing concerning full screen: Most browsers support a full screen or "kiosk" mode! In Firefox, you should first switch off all tool bars - IE takes care of this automatically in full screen mode. In both browsers, F11 does the job, and voila: full screen Jangaron! I could find no performance impact whatsoever, since the JavaScript part is the limiting factor, not the browser drawing code which is highly optimized.
User avatar
DDMJ
Reverse Outside Corner Grinder
Posts: 1882
Joined: Thu Jun 08, 2006 12:15 am
Location: LA, CA, USA, NA
Contact:

Post by DDMJ »

Quadruple post FTL; next time use the Image button ;).
User avatar
Rain
Round Winner
Posts: 300
Joined: Sat Apr 15, 2006 2:59 pm
Location: a random empty server playing with bots

Post by Rain »

he wasn't looking for a quick edit, but for an update, that needs a new post to be visible, in my opinion.
END OF LINE
Post Reply