Topic: 20 Liners - January 08 - Dynamics (Page 3 of 4) |
|
---|---|
Paranoid (IV) Inmate From: Switzerland |
posted 01-28-2008 14:57
(very quick one : ALL browsers with Canvas violate the spec in one or many ways, see tech notes of a very nice Canvas game engine called "canvex") |
Paranoid (IV) Inmate From: Norway |
posted 01-28-2008 19:19 |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-28-2008 19:20
Theory confirmed. code: true?(([1,2,alert("asd")])[3]):alert("bla");
code: false?(([1,2,alert("asd")])[3]):alert("bla");
|
Paranoid (IV) Inmate From: Norway |
posted 01-28-2008 20:14 |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-28-2008 20:16
3-4 days to go ... plenty of time ... don't be shy |
Paranoid (IV) Inmate From: Umeå, Sweden |
posted 01-28-2008 21:11
quote: Well, most of your 20 liners seem to have something to do with graphics. I'm not a graphics guy. In fact, I know pretty much nothing about rendering and image manipulation. I can write a state machine parsing code into a tree structure (probably needing more than 20 lines unless the grammar is dead simple, though , and a code generator transforming it to byte code, and an interpreter executing the byte code, but I wouldn't know where to start, what to do or how to do it when it comes to rendering something. And even if you had a challenge that fit me, it's not likely I would have the time to cook something up and polish it. |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-28-2008 22:17
obviously not for the challenge ... just fooling around |
Paranoid (IV) Inmate From: Norway |
posted 01-28-2008 22:36 |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-28-2008 22:50 |
Paranoid (IV) Inmate From: Norway |
posted 01-28-2008 23:00 |
Obsessive-Compulsive (I) Inmate From: Toronto |
posted 01-29-2008 06:55
OK, here's my first contribution to something like this, ever |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-29-2008 08:50
Definitely something original in the context of 20 liners! Doesn't look too dark to me. |
Paranoid (IV) Inmate From: Norway |
posted 01-29-2008 09:21
Neat. |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-29-2008 10:39
poi: thx, backface culling did it |
Paranoid (IV) Inmate From: Umeå, Sweden |
posted 01-29-2008 10:57
quote:
code: conditionexpr ? truthypathexpr : falsypathexpr If you try to use statements of any kind in any of the expressions, you will find the code gives a syntax error. |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-29-2008 12:12
try code: true?alert("asd"):alert("bla");
code: var a = 0; 1==2?alert("true"):(a=2); alert(a); |
Paranoid (IV) Inmate From: Norway |
posted 01-29-2008 12:58
Arthurio: which is the normal behavior of the ternary operator, as Liorean said: code: condition?expressionIfTrue:expressionIfFalse; Of course expressionIfTrue and expressionIfFalse can include function calls and even code blocks, but it must be a single statement/expression ( which can include , ). |
Obsessive-Compulsive (I) Inmate From: Toronto |
posted 01-29-2008 18:32
Arthurio: Thanks for the suggestion about the ternary conditional operator instead of ifs. Is there a way I could capture mouse position without wasting too many lines? |
Nervous Wreck (II) Inmate From: Toronto |
posted 01-29-2008 18:38
Make that 16; I should probably have counted the "g = { ..." as well. |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-29-2008 18:56
quote:
|
Paranoid (IV) Inmate From: Norway |
posted 01-29-2008 20:32
MaGnA: Nice optimizations. code: Array.prototype.every = Array.prototype.every||function( callback, that ) { for( var i=0; i<this.length && callback.call( that||this, this[i] ); i++ ); return i==this.length; } This at least makes the script work in Opera 9.5, but thows in IE7. Will try to figure why. code: element.onmousemove = function( event ) { var event = window.event||event; window.mouse = { x:event.offsetX||event.pageX, y:event.offsetY||event.pageY, b:event.which||event.button?true:false } } Where element is an overlayed element on top of the area you want to capture the mouse. |
Paranoid (IV) Inmate From: Norway |
posted 01-29-2008 21:09
Got it. IE7 doesn't like: code: foo( undeclaredVariable=expression ) To get the script to work, declare k, ci and d or place them in the g global game object to not loose any line |
Paranoid (IV) Inmate From: Umeå, Sweden |
posted 01-29-2008 21:34
quote: Which consists of three expressions. A function call is not a statement, it's an expression. code: true?true:return false;
code: if(true) true; else return false;
|
Paranoid (IV) Inmate From: Umeå, Sweden |
posted 01-29-2008 21:58
quote: And on ES4 track, and supported by WebKit. quote: Strange. It works well enough in IE7 when trying to analyse it like this: code: var a=[]; alert(1+' '+Array.prototype.every); Array.prototype.every = function( callback, that ){ alert('every!\n'+this.length); for( var i=0; i<this.length && callback.call( that||this, this[i] ); i++ ); return i==this.length; } alert(2+' '+Array.prototype.every); [0,1,2,3,4,5].every(function(x,y){alert([x,y]);a.push(x+':'+y);return true;}); a.join('\r');
quote: JavaScript being Mozilla's version of ECMAScript, I'd say Mozilla is the standardising organisation. They're driving the ES4 process, too, so expect JavaScript1.6-1.9 additions to be included in the ES4 standard library. quote: You're not alone. |
Paranoid (IV) Inmate From: Norway |
posted 01-29-2008 22:08
The lack of every method was not the only breaking in IE7. IE7 also chocked on undeclared variables. See my previous post. |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-29-2008 22:25
liorean: ok thx for the explanation |
Paranoid (IV) Inmate From: Norway |
posted 01-29-2008 23:18 |
Nervous Wreck (II) Inmate From: Toronto |
posted 01-29-2008 23:22
quote:
|
Paranoid (IV) Inmate From: Norway |
posted 01-29-2008 23:41 |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-30-2008 00:04
Still just fooling around... |
Nervous Wreck (II) Inmate From: Toronto |
posted 01-30-2008 06:55
poi: I've incorporated your every() and (uninitialized = expr) fixes. The code size gone up to 19 lines now. I guess I won't bother trying to add mouse support now |
Paranoid (IV) Inmate From: Norway |
posted 01-30-2008 09:21
Arthurio: looks like you're having fun. Keep going |
Paranoid (IV) Inmate From: London |
posted 01-30-2008 11:05
I've been following this thread fervently guys, it's been one of the best 20 liners in Years! Well done all. |
Paranoid (IV) Inmate From: cell 3736 |
posted 01-30-2008 15:35
1 day left ... plenty of time |
Nervous Wreck (II) Inmate From: Toronto |
posted 01-30-2008 21:43
quote:
|
Paranoid (IV) Inmate From: Norway |
posted 01-30-2008 22:21
I believe we have a winner. code: #preload { position:absolute; top:0; left:0; overflow:hidden; width:0; } This way the content to preload is not visible but browser still load the resources in the children elements. |
Paranoid (IV) Inmate From: Norway |
posted 01-31-2008 21:59
What about a trip to Castle Wolfenstein in 14 lines ?
|
Paranoid (IV) Inmate From: cell 3736 |
posted 01-31-2008 22:21
*poking server* what is the time? |
Nervous Wreck (II) Inmate From: Toronto |
posted 01-31-2008 22:40
poi: Just as I was planning to add keyboard support... Tsk tsk tsk... Even if I add VR helmet support, mine won't approach the coolness of what you've got here. Awesome last minute entry! |
Nervous Wreck (II) Inmate From: |
posted 01-31-2008 23:20
Poi -- Very compact and quite speedy too -- wish we could get rid of that fisheye, though! (I'd poke it myself, but I never quite have the time XD) I need to download Opera to try your other entry... |
« Previous Page — 1 2 [3] 4 — Next Page »