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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Snake

  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Snake

    Not very original (and it takes some time to preload the graphics ) but here goes:
    The game: http://www32.brinkster.com/shmoove/snake/main.htm
    Download as a zip and install locally: http://www32.brinkster.com/shmoove/snake.zip (and edit the graphics, why should you be playing an ugly game just because I have no artistic talent whatsoever).

    shmoove
    Last edited by shmoove; 01-01-2004 at 07:05 PM.

  • #2
    New Coder
    Join Date
    Dec 2003
    Location
    At work...still
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its fun
    Why?
    Ok, but Why?

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, but I've had people object to eating rats (my ex-girlfriend was from PETA ;P ).

    shmoove

  • #4
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't work.

    I click on "start", and get nothing but a black screen.

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #5
    New Coder
    Join Date
    Dec 2003
    Location
    At work...still
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Tell PETA to file a petition with Mother Nature. Snakes eat rats.

    Will
    Why?
    Ok, but Why?

  • #6
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't work.

    I click on "start", and get nothing but a black screen.
    Really? What browser are you using? I've only tested in IE.

    shmoove

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't work in Firebird 0.7. From what I read in your code, it shouldn't - looks like you're using the IE-only DOM (document.all collection).

    Happy coding!

  • #8
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh, that explains it. I never use IE. Of course, you could change all instances of document.all.elementID to document.getElementById("elementID"), and it would probably work in all modern browsers.

    BTW, your ZIP file is corrupted. You might want to re-upload it.
    Last edited by Skyzyx; 12-29-2003 at 10:44 PM.

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    From just experiencing the game, it seems you are reloading the same image 140 (give or take) times each new game. Rather than taxing my poor 56k (regardless of how small that image might be), you could just cloneNode() one and append it multiple times to the document, so my poor little modem can have a chance to recuperate.

    Hope that helps!

    Happy coding!

  • #10
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Of course, you could change all instances of document.all.elementID to document.getElementById("elementID"), and it would probably work in all modern browsers.
    Tried that. Didn't work

    BTW, your ZIP file is corrupted. You might want to re-upload it.
    I had no problems downloading and opening it. But I uploaded it again just in case.

    it seems you are reloading the same image 140 (give or take) times each new game.
    I have this to preload the pictures (just 24 pictures BTW):
    Code:
    //preloading pictures
    pics=new Array();
    picnames=new Array("empty","food",
    		"ehead","eheaddead","eheadwink",
    		"nhead","nheaddead","nheadwink",
    		"whead","wheaddead","wheadwink",
    		"shead","sheaddead","sheadwink",
    		"etail","ntail","wtail","stail",
    		"ne","nw","se","sw","horizontal","vertical");
    for (var i=0;i<picnames.length;i++) {
    	pics[i]=new Image();
    	pics[i].src="pics/" + picnames[i] + ".jpg";
    }
    Counting on the browsers caching mechanism, I think. At least that's what my teacher said. Is there a better way to do that.
    Are you sure it's reloading the pictures every time? I can't see why.

    shmoove

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When I tested the game in IE, each time I pressed the 'Start' button, it would say 140 items remaining. When those loaded, and I pressed it again, the same thing happened. I tested a third time and same thing happened. The reason is in the init function:

    Code:
    	for (x=0;x<15;x++) 
    		for (y=0;y<10;y++)
    			setCell(x,y,"empty");
    You're looping through 150 cells and resetting them to "pics/empty.jpg."

    Hope that helps!

    Happy coding!

  • #12
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, but that picture is already in the cache (since it was preloaded). Unless you have you're browser set to no caching whatsoever that shouldn't be a problem, am I wrong?

    shmoove

  • #13
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by shmoove
    OK, but that picture is already in the cache (since it was preloaded). Unless you have you're browser set to no caching whatsoever that shouldn't be a problem, am I wrong?

    shmoove
    *Feels silly*

    I rarely use IE, and didn't notice my cache setting was 'Every time I visit a page.' Heh, sorry. Now it's working as you say.

    Happy coding!

  • #14
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    That's an awsome game

    I got 88
    That looks like a complicated game to code..
    congrats
    Shawn

  • #15
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's an awsome game
    Thanks
    That looks like a complicated game to code..
    The code is there, you tell me.

    shmoove


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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