OZONE Asylum
Forums
DHTML/Javascript
20 Liners - July 08 - Your favorite video game
This page's ID:
30391
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Sweet! [i]Really don't worry about the line count. It's ALWAYS possible to gain something somewhere.[/i] FWIW I counted 22 lines in your script:[code]// pseudo code /* 01 */ variables initialization /* 02 */ onkeydown if /* 03 */ onkeydown if statement /* 04 */ onkeyup if /* 05 */ onkeyup if statement /* 06 */ init_level if#1 /* 07 */ init_level if#1 statement /* 08 */ init_level if#2 /* 09 */ init_level if#2 statement /* 10 */ init_level setTimeout /* 11 */ start_level if#1 /* 12 */ start_level if#1 statement /* 13 */ start_level if#2 /* 14 */ start_level if#2 statment /* 15 */ animate if /* 16 */ animate if statement /* 17 */ animate else /* 18 */ animate else statement /* 19 */ move statement /* 20 */ test statement /* 21 */ walk statement /* 22 */ update statement[/code]But many/most of the [i]if, statement[/i] and [i]if, statement, else, statement[/i] can be combined in a single line. For instance the keydown/keyup handling can be a one liner. See how I did in [url=http://www.p01.org/releases/DHTML_contests/files/20lines_castle_wolfenstein/]Castle Wolfenstein[/url]. You also be lazy as I've been about the new level "screen" and use an [i]alert( 'Yay for level #'+ level )[/i] which allow you to use a single [i]setInterval( updateGame, delay );[/i] instead of juggling with a [i]setTimeout[/i] and a [i]setInterval[/i] as you do now. I could provide the skeleton of a game if you want. HTH [url=http://www.p01.org/][sigrotate][img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_love.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_love_small.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_charly.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_dk.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_reason.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_galaxy.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_neon88x31.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_teapot.png[/img][/sigrotate][/url]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »