Closed Thread Icon

Topic awaiting preservation: April 2005 - 20 lines JavaScript contest - Sliding Puzzle (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=25413" title="Pages that link to Topic awaiting preservation: April 2005 - 20 lines JavaScript contest - Sliding Puzzle (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: April 2005 - 20 lines JavaScript contest - Sliding Puzzle <span class="small">(Page 1 of 1)</span>\

 
BillyRayPreachersSon
Bipolar (III) Inmate

From: London
Insane since: Jul 2004

posted posted 04-03-2005 16:28

This month's challenge is to make a sliding puzzle - of the type shown here:

http://images.google.co.uk/images?q=sliding+puzzle

There are many versions of this classic game around, a lot of them quite bland... so see if you can think of an interesting twist to enhance gameplay in your version (whether it be a graphical change, or a change to the gameplay itself... or anything )

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.




Dan

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 04-03-2005 17:01

cool idea!

Tao
Maniac (V) Inmate

From: The Pool Of Life
Insane since: Nov 2003

posted posted 04-03-2005 17:40


Ok, I know this is not at all what was required but I just couldn't resist.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 04-03-2005 17:53



Tao
Maniac (V) Inmate

From: The Pool Of Life
Insane since: Nov 2003

posted posted 04-03-2005 18:05

heh

BabyJeffy
Obsessive-Compulsive (I) Inmate

From: London, England
Insane since: Feb 2005

posted posted 04-05-2005 01:43

Well... I couldn't hold back and put together my entry today:

http://www.soterm.com/jeff/slidingpuzzle.html

There are a few things I would change (and may) if I were to start again, but I enjoyed solving how to solve the game logic. If I took out some of the practical code (don't detect game end, don't let game start once it's finished etc) I could shave maybe 4 lines off it... but I'm happy at 20 lines without it being impossible to figure out what I am doing.

Cheers for the challenge!
Jeff

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-05-2005 02:42

BabyJeffy: not bad, but it has the problem that it's not always solveable. For instance, I got a configuration which I managed to get to

1 2 3
4 5 6
8 7

and there's no way through any amount of block sliding that that can be solved.


 

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 04-05-2005 02:47

Slime: don't explain your last comment - it might give something about my one - it's famous if you know your sliding pzzles

Meh, one day I'll have a website worth seeing...honest

BabyJeffy
Obsessive-Compulsive (I) Inmate

From: London, England
Insane since: Feb 2005

posted posted 04-05-2005 15:38

Slime - I had noticed this as well... and I had been working on finding a fix for some time before I thought I'd just it anyway.

After a lot of "fiddling" with randomisation code, I decided to completely ditch the way I was randomising the game. In so doing, I rewrote the code (as you do) and actually ended up with a solution that was only 16 lines! With all those extra lines I had available, I managed to produce a much superior solution.

http://www.soterm.com/jeff/slidingpuzzle.html

The most ovbious difference with this version is that it now uses images (instead of text) on each game "tile". My "interesting twist" is that a random image is used for every game (there are currently 3 images to choose from so you may need to start several games to get to play them all).

I've run it successfully on Safari 1.2.4, Firefox 1.0.2, IE 5.2 (MacOSX), IE 6, Firefox 1.02 (Windows).

One thing I noticed when testing IE in Windows: if you have the browser set to "check for new versions of stored pages: every visit to the page" then the browser slows right down as it draws images (as backgrounds). The default setting for IE will not cause this to happen. If you have changed the default setting, you can change it back (if you want) by choosing: Tools/Internet Options/General Tab - Settings Button

Anyway, great challenge - hope to see some more entries soon!

Jeff

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 04-05-2005 16:36

BabyJeffy: very cool - nice code!

Unfortuantely, I hadn't seen your latest one when I started coding mine, so there are certain similarities (but that was going to happen anyway...)
So....here we go:

http://www.wraypa1.f2s.com/wrayal/20liner/tile/20LineShift.html

Once again, lame graphics - sorry!

Slime: btw, I know you said you've given up JS, but might we see an entry from you for old times' sake?

Wrayal

Meh, one day I'll have a website worth seeing...honest

(Edited by wrayal on 04-05-2005 16:41)

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 04-13-2005 00:37

*bump*

Qb : 20 lines 'sliding puzzle'


I only made 2 levels, and the enemies move really too rarely ( if they move at all ). But I'll make much more levels and will try to boost the enemies a bit until the end of april.

The goal of the game, is to remake the pattern visible on the mini-map.

Hope you'll like it.



(Edited by poi on 04-13-2005 00:38)

Iron Wallaby
Paranoid (IV) Inmate

From: USA
Insane since: May 2004

posted posted 04-13-2005 15:21

Wow, poi, that's great.

Needs more levels. Very fun to play, though! Cute graphics as well.

---
"Consider a simple room with only four walls, a ceiling and a floor. Can you see it in your mind?s eye? You better not be able to; I haven?t specified a light source yet." - Paul Nettle

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-01-2005 15:09

Sorry I didn't get anything better produced this month - Just as I was starting on some more interesting stuff, I found French oral sneaking up on me, which ate up all my time. Still can't wait to hear the winner *looks in poi's direction*

Wrayal

BillyRayPreachersSon
Bipolar (III) Inmate

From: London
Insane since: Jul 2004

posted posted 05-03-2005 14:04

Well done to everybody who entered - I had much fun playing... er... testing each entry

As Wrayal has guessed,, the winner for this month is poi with his very nice sliding puzzle cum arcade game.

Now... what will this month hold for us, I wonder?

Let the games begin!
Dan

Suho1004
Maniac (V) Mad Librarian

From: Seoul, Korea
Insane since: Apr 2002

posted posted 05-03-2005 16:06

Wow... I don't wander into this forum very much, but excellent stuff, guys! I am consistently amazed at what you do with 20 lines...

Think we could take over the world with 200?

___________________________
Suho: www.liminality.org | Cell 270 | Sig Rotator | the Fellowship of Sup

Iron Wallaby
Paranoid (IV) Inmate

From: USA
Insane since: May 2004

posted posted 05-03-2005 17:00
quote:
Suho1004 said:

Wow... I don't wander into this forum very much, but
excellent stuff, guys! I am consistently amazed at what you do with 20
lines...

Think we could take over the world with 200?


If I'm allowed to use both JS and Perl with those 200, then yes, definitely.

---
Website

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-03-2005 18:17

[edit] oops - double post.... :/ [/edit]

(Edited by wrayal on 05-03-2005 18:18)

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-03-2005 18:17

IW: wouldn't put it past you ;p

Congrats to poi! Now, let's hear the next subject

I swear...one of these days I'll have a good idea...then I might win something! Mwa-ha-ha-ha!</manicLaughing>

Wrayal

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 05-03-2005 23:21

Thank you guys.
Gosh I was away the last WE of april and didn't managed to make more levels. I have to correct this mistake.

Let's move on to May 2005 - 20 lines JavaScript contest - Asteroids

« BackwardsOnwards »

Show Forum Drop Down Menu