Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 48

Thread: [DHTML] Cross-Browser Snake

  1. #11
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If you create an object method like this:
    Code:
    function MyObject() {
      this.func = function() { doNothing(); };
    }
    Every time you create a new instance of MyObject, a new copy of that function is created. This is inefficient. Instead, if you do:
    Code:
    function MyObject() {
    }
    
    MyObject.prototype.func = function() { doNothing(); };
    ... the function is only created once, then pointers to it assigned to each new copy of MyObject.

    In Konqueror, there's an interesting bug: on hitting the apple for the first time, the snake jumps back to its starting point then back to where it was after a few seconds, after which it is unable to collide with the apple (although it can still hit walls).

    /EDIT: Also, if you toggle between speeds a few times, your snake goes super-sonic.
    Last edited by Twey; 08-06-2006 at 02:17 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #12
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh, this is awesome.

    I would be more Interested if you could write a tutorial on how did you make this.

  3. #13
    Join Date
    Aug 2004
    Posts
    9,903
    Thanks
    3
    Thanked 967 Times in 955 Posts
    Blog Entries
    15

    Default

    Not bad at all. Functionality wise one thing I'd change is the speed difference between Medium and Fast- right now the two basically are both insanely and similarily fast to me.

  4. #14
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    shachi: Take a look through the source. I don't think I did anything to advanced.

    ddadmin: Thanks for the suggestion! My original link has been updated to include a faster 'fast'.

    Twey: Thanks for the tip. Changing to that method also stops IE 5.5 from crashing. I have added support for Konqueror. It didn't like how I used innerHTML. So I switched to appendChild. It is still pretty buggy though. I also prevented super-sonic,but my solution is a little cheap

    Here's the latest version...
    Last edited by blm126; 08-09-2006 at 03:43 PM.

  5. #15
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    pretty cool if u could add a 'Pause' feature
    Please don't mind me. I am just posting a lot of nonsense.

  6. #16
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yeah, I thought about suggesting that.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #17
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Ok, I added a pause feature thanks for the suggestion.

  8. #18
    Join Date
    Aug 2004
    Posts
    9,903
    Thanks
    3
    Thanked 967 Times in 955 Posts
    Blog Entries
    15

    Default

    Ok, I'm going to post this script to DD soon. Did you want the OO version to be the one showcased? You should pick the one you plan on making any updates to to.

  9. #19
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by blm126
    Ok, I added a pause feature thanks for the suggestion.
    so how do i pause the game then?
    Please don't mind me. I am just posting a lot of nonsense.

  10. #20
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Press space.
    Like it says in the instructions.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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