...

View Full Version : Randomising Images within a table



baz7621
03-14-2004, 08:41 PM
Hiya just incase u havent read my prevous problem. I am creating a 4x4 sliding puzzle game in javascript. I have the script to check and swap the cells/tiles as required but now my problem lies in that i need for the user to click a button and it scrambles the images within the table. I managed to hash up some code to get it to scramble but it does work because after it scambles the user can not move any tiles and sometimes one or two of the images do not load. My code is here http://www.mikecotton.com/test.html if anyone coud help me modify the code i already have or create a better code it would be of much help

fanx

Garadon
03-14-2004, 08:54 PM
urs:
current_cell = parseInt(event.srcElement.parentNode.id.replace("cell", ""));

try:
current_cell = parseInt(event.srcElement.id.replace("cell", ""));

ohh and your shuffle don't update the location of the blank cell.

baz7621
03-14-2004, 09:05 PM
hi fanx for your input but with the code that u gave me it doesnt even let me move BEFORE i shuffle. At the moment with my code it does move before the shuffle just not afterwards

But you did point out a gud thing i dont update the blank cell variable in shuffle function but i have no idea on how to update :confused: any ideas?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum