Freethought & Rationalism ArchiveThe archives are read only. |
07-13-2003, 09:27 AM | #101 | |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
Quote:
(What's that old saying, "Rubber on me, glue on you,..." ) |
|
07-13-2003, 09:32 AM | #102 |
Veteran Member
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
|
i
yep, the i thing, i was once a fortran programmer.
The difference between PLANspeed and LANspeed, was a cut and paste job, necessarily done to rush the code out into production. I was in a hurry to see my baby do the jiggy-do. Honestly, I am much more careful with variablenames. Sometimes I name one variable such a long name it drifts off the screen. Then I have troubles seeing the for-loop SO I have to convert the loop to a strict-while. Troubles you have when you are a professional thinker. (added) Actually I forgot to tell you the conditions for running the code. Including the sweat-band. These are the external conditions most programmers forget to mention. The condition which entails their programs run like an embedded external object. |
07-13-2003, 11:15 AM | #103 |
Veteran Member
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
|
just so anyone can try to follow the code...
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>GREETINGs by Sophie </title> <link type="text/css" rel="stylesheet" href="http://www.notrich.org/GREETING/greeting.css"> <script language="JavaScript1.2"> var DANCINGimages = new Array() ; DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ; DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ; var RETURNcode ; var IMAGESindex = 0 ; var IMAGESmax = DANCINGimages.length ; var IMAGESpreLoad = new Array() ; for (var eye = 0; eye < IMAGESmax; eye++) { IMAGESpreLoad[eye] = new Image() ; IMAGESpreLoad[eye].src = DANCINGimages[eye] ; } var DANCINGspeed = new Array() ; DANCINGspeed[0] = 300 ; DANCINGspeed[1] = 240 ; DANCINGspeed[2] = 180 ; DANCINGspeed[3] = 140 ; DANCINGspeed[4] = 50 ; DANCINGspeed[5] = 130 ; DANCINGspeed[6] = 183 ; DANCINGspeed[7] = 130 ; DANCINGspeed[8] = 50 ; DANCINGspeed[9] = 321 ; DANCINGspeed[10] = 440 ; DANCINGspeed[11] = 500 ; var REPEATdanceMOVE = new Array() ; REPEATdanceMOVE[0] = 6 ; REPEATdanceMOVE[1] = 3 ; REPEATdanceMOVE[2] = 5 ; REPEATdanceMOVE[3] = 1 ; REPEATdanceMOVE[4] = 8 ; REPEATdanceMOVE[5] = 2 ; REPEATdanceMOVE[6] = 7 ; REPEATdanceMOVE[7] = 2 ; REPEATdanceMOVE[8] = 11 ; REPEATdanceMOVE[9] = 2 ; REPEATdanceMOVE[10] = 4 ; REPEATdanceMOVE[11] = 4 ; var TOTALdancingIMAGES = DANCINGimages.length ; var COUNTimagesSHOWN = TOTALdancingIMAGES ; var ANIMATIONtreshold = DANCINGspeed.length ; var ANIMATORindex = ANIMATIONtreshold - 1; var HAVErepeatedTHISmoveTHESEtimes = REPEATdanceMOVE[ANIMATORindex]; function NEXTdanceSPEED(){ if (++COUNTimagesSHOWN > TOTALdancingIMAGES ) { if ( ++HAVErepeatedTHISmoveTHESEtimes > REPEATdanceMOVE[ANIMATORindex] ) { COUNTimagesSHOWN = 1 ; HAVErepeatedTHISmoveTHESEtimes = 0 ; if (++ANIMATORindex >= ANIMATIONtreshold) ANIMATORindex= 0 ; } } return (DANCINGspeed[ANIMATORindex]) } function ANIMATEdance() { if (document.images) { document.images.DANCING.src = IMAGESpreLoad[IMAGESindex].src; var newspeed = NEXTdanceSPEED() ; if (++IMAGESindex > (IMAGESmax-1)) IMAGESindex=0 ; RETURNcode = setTimeout('ANIMATEdance()', newspeed) ; } } </script> </head> <body onload="ANIMATEdance()" bgcolor=green > <img src = "http://www.notrich.org/ANIMATION/PLAN1.jpg" border=no NAME="DANCING"> We Give NICE Hi U</font> </body> </html> |
07-13-2003, 11:37 AM | #104 |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
Code:
for (var eye = 0; eye < IMAGESmax; eye++) { IMAGESpreLoad[eye] = new Image() ; IMAGESpreLoad[eye].src = DANCINGimages[eye] ; } |
07-13-2003, 11:57 AM | #105 |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
DNAunion: Hmmm, seems to me that the array DANCINGimages is unnecessary. Instead of:
Code:
var DANCINGimages = new Array() ; DANCINGimages[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ; DANCINGimages[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ; … var IMAGESmax = DANCINGimages.length ; var IMAGESpreLoad = new Array() ; for (var eye = 0; eye < IMAGESmax; eye++) { IMAGESpreLoad[eye] = new Image() ; IMAGESpreLoad[eye].src = DANCINGimages[eye] ; } … var TOTALdancingIMAGES = DANCINGimages.length ; Code:
var IMAGESpreLoad = new Array() ; IMAGESpreLoad[0] = new Image() IMAGESpreLoad[0] = 'http://www.notrich.org/ANIMATION/PLAN2.jpg' ; IMAGESpreLoad[1] = new Image() IMAGESpreLoad[1] = 'http://www.notrich.org/ANIMATION/PLAN1.jpg' ; … var IMAGESmax = IMAGESpreLoad.length ; … var TOTALdancingIMAGES = IMAGESpreLoad.length ; |
07-13-2003, 12:12 PM | #106 |
Veteran Member
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
|
suggestion
I used the original because whenever I add or subtract an image I only need to cut and paste one line, change one index and change one file name.
With your suggestion, I have to cut and paste two lines, change two indicies, and change one file name. This case I have more possibilities for errors when I am maintaining the code. I usually mostly maintain code when I am half asleep, so I am prone to creating multiple errors. Now think of this, at the expense of a lowly array, if during the life cycle of this code, which I expect to run two years, I regularily increase my animations, to make it more image complex, I would have wasted over 1000 cut and pastes, and would have changed an extra index 1000 times. Instead as that time accumulates, I can use the time more constructively. Memory is inexpensive these days and most people have 64Mbytes in their machines, so I feel well justified saving myself some maintanence time... |
07-13-2003, 06:30 PM | #107 |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
DNAunion: Oh, I just debugged more of my own code. Again, it is IMPOSSIBLE for me to correct the code due to the 120-minute window for editing imposed by this forum. If I could do so, I would just fix it and wouldn't even bother bringing it up.
I thought I had better spend a few minutes to review the code I have posted here and in doing so spotted an oversight in the doubly linked list. When a Node is popped off of the stack, the Next pointer of what is then the last node is left pointing to the Node that was just deleted. A simple single line that sets that pointer to 0 corrects this. |
07-13-2003, 06:42 PM | #108 | |||||
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
Quote:
Two arrays (Sophie’s original): 1) Use mouse to highlight selection 2) Right-click selection to bring up the context menu 3) Choose COPY 4) Position mouse pointer where text is to be pasted 5) Right-click to bring up context menu 6) Choose paste 7) Move to end of line where file name is: edit file name 8) Move to middle of line where index is: edit index One array (my inquired about change): 1) Use mouse to highlight selection 2) Right-click selection to bring up the context menu 3) Choose COPY 4) Position mouse pointer where text is to be pasted 5) Right-click to bring up context menu 6) Choose paste 7) Move to end of line where file name is: edit file name 8) Move to middle of line where index is: edit index 9) Click up arrow to get to other index: edit index The only difference is editing the extra index (that is, contrary to your statements, you wouldn’t have to do any extra work to copy and paste two lines instead of one). And, you would already be editing the other index that is immediately below it: up arrow gets you right there. Quote:
Quote:
Secondly, no, you wouldn’t have wasted 1,000 cuts and pastes: in fact, you wouldn’t have wasted any. It takes just as many operations to copy and paste two contiguous lines of code as one. So that part is dismissed. By the way, why would you CUT, and then paste? That wouldn’t get you anywhere! Now, hypothetically, over the span of two years, assuming you add 1,000 more images to your “animation megaplex!”, then you would have to change an extra index 1,000 times. Let’s see, at about, oh 3/10 of a second per extra index, that comes out to be roughly 300 seconds “wasted” spread out over two years. If you are really worried about “wasting” 5 minutes over a 2-year span, perhaps you’re a bit too obsessed with time management. Quote:
Quote:
Just so that we are straight...no matter how many tens, dozens, hundreds, or thousands of images you have, my inquired about method would be faster, require less memory, and promote code clarity. Because I reject most of your "melodramatics", the only real downside I see – assuming you really are headed towards the amazing animation megaplex! – is that my inquired about method would bloat the source code more than yours would because it includes a separate arrayName[x] = new Image(); statement for each image. But I had no idea that your script was that switches between two images was meant for anything other than a "see, I can write some code too". I have more to say about your code, but I'll save that for another post. |
|||||
07-13-2003, 07:10 PM | #109 |
Veteran Member
Join Date: Jan 2001
Location: USA
Posts: 1,072
|
DNAunion: You have another unneeded variable in your code.
Both IMAGESmax and TOTALdancingIMAGES are assigned the same value, neither variable’s value is modified after being assigned, and both variables are used to test for the same type of condition. Here are all references to those two variables: IMAGESmax var IMAGESmax = DANCINGimages.length ; for (var eye = 0; eye < IMAGESmax; eye++) if (++IMAGESindex > (IMAGESmax-1)) TOTALdancingIMAGES var TOTALdancingIMAGES = DANCINGimages.length ; var COUNTimagesSHOWN = TOTALdancingIMAGES ; if (++COUNTimagesSHOWN > TOTALdancingIMAGES ) Only one of those two variables is needed. |
07-14-2003, 05:47 AM | #110 |
Veteran Member
Join Date: May 2003
Location: On the road to extinction. . .
Posts: 1,485
|
Only one of those two variables iis needed.
(1) IMAGESmax (2) TOTALdancingIMAGES True. One came before the other as if they were independently programmed. The two parts can act independently meaning a change in one part will not affect the other. This would be meaningless to you as such I concede the point. One unnecessary variable conceded. |
Thread Tools | Search this Thread |
|