Closed Thread Icon

Topic awaiting preservation: September 20lines Javascript Contest - Sir Issac - Entries (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=23152" title="Pages that link to Topic awaiting preservation: September 20lines Javascript Contest - Sir Issac - Entries (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: September 20lines Javascript Contest - Sir Issac - Entries <span class="small">(Page 1 of 1)</span>\

 
kastner
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 09-02-2004 00:04

This month's theme is: Sir Issac (Physics!)
You can make anything you like, as long as it has some sort of physics engine running.
You can make a game of plinko, a skateboarding game or even a model of the universe

The entries belong in this thread, the comments in September 20lines Javascript Contest - Sir Issac - Comments

quote:
a code monkey said once:
As usual, the main rule is to make your script in 20 lines of (effective) code.
Comas shouldn't be used to execute several instructions on the same line
See the code sample below to illustrate the basic rules :

code:
<script type="text/javascript">

/* */ document.body.onclick = function()
/* */ {
/* 01 */ val = prompt( 'enter a number' );
/* 02 */ for( i=0; i<10; i++ )
/* */ {
/* 03 */ alert( stupidFunction( val, i ) )
/* */ }
/* */ }

/* */ function stupidFunction( a, b )
/* */ {
/* 04 */ return a>b?a:b; // I said it was a stupid function
/* */ }

</script>



The document.body.onclick = function() does not count as a line as it's not some effective code and the function call could be put in the BODY tag ( or anyother HTML tag ).
The declaration of the stupidFunction() does not count either for the same reasons.
The coma in the line /* 03 */ is ok, since it simply separates the parameters of a function.




I'm really looking forward to seeing what people will come up with, and I hope this will bring out some crazy cool stuff due to the very "loose" nature of this challange.

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 09-14-2004 00:33
quote:
kastner said:
You can make a game of plinko, a skateboarding game or even a model of the universe



universe has style.
so here is my first try at these 20 liners:

http://www.embege.com/asylum/starfield.html
should be running in mozzy and opera.


(and here is a flash version which runs a bit smoother.
http://www.embege.com/flarimen/swf/classicstarfield.swf
use arrow keys to navigate and +/- to change speed)




(Edited by GRUMBLE on 09-14-2004 00:52)

smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 09-14-2004 20:17

the flash one is nice - any chance of you posting the AS - is it a twenty-liner too?

SCRWD//MULTIMEDIA PORTAL

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 09-14-2004 21:27

thanks. the starfield alone could be a 20liner i think, because its the very same code as in the javascript. but together with the interactivity its a lot of more lines.

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-15-2004 10:45

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

shingebis
Obsessive-Compulsive (I) Inmate

From: UK
Insane since: Aug 2004

posted posted 09-23-2004 23:40

I was going to make a fully-fledged pinball game, but I only got seven lines in before it tied my brain in knots. Check out the source, you'll understand.

Perpetual Motion Pinball

Ray Norrish
Nervous Wreck (II) Inmate

From:
Insane since: Sep 2004

posted posted 09-24-2004 03:19

grumble: starfield doesn't work : XP SP1 IE6

Line 25: char 11: invalid arg

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 09-25-2004 13:42

Here's my entry for the physics 20-liner JS competition.

http://www.soterm.com/dan/bodyOnSurface.html

I was originally going to do a lens effect in JS, but after many hours of trying, conceded that browsers simply cannot handle the number of individual DIVs I was needing to create for a decent effect (a 100x100 image takes up 10,000 pixels - way too many to run even vaguely smoothly).

After that, my thoughts went onto a pendulum, missile / bullet trajectory, newtons cradle, and magnetic forces... But all ideas went out the window in favour of my final entry "Body sliding on a surface".

It started life as a pendulum effect, but after a night out with a Maths lecturer friend of mine, it kind of morphed (not in 20 lines ;o) into what you see now. I tried to tart it up with an animated GIF of a ball rolling clockwise / counter-clockwise, but the graphic seemed to "stick" fairly regularly, so I removed it.

The demo is interactive, so you can click anywhere on the trail (surface) to start the ball (body) from that point. Starting at 0 pretty much gives no movement at all. Unfortunately, due to rounding errors (and possibly a few errors in the formula), the height of the body will creep higher and higher, and eventually fall off of the trail (and probably throw a JS error). It takes so long for this to happen (many iterations) that I have decided not to fix it.

Enjoy the countless hours of watching the red dot go back and forth. And for fun, why not try changing the value of gravity from 1 to 10 or so (last parameter in the 16th effective line). Changing it to 100 will show the body sliding off the surface after about 3 iterations or so.

Dan

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 09-25-2004 13:50

One thing I forgot to mention:

It works in IE and Firefox. It seems to crash Safari dead, and I have no idea why. I've not tested it in any other browsers.

In Firefox, moving the mouse over the trail will not show you any details in the status bar unless you have enabled that option in the Advanced scripting preferences. IE shows it just fine, however.

Dan

« BackwardsOnwards »

Show Forum Drop Down Menu