Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Randomising Images within a table

    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

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 any ideas?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •