- Joined
- Aug 1, 2017
Eh, it's not that bad since it's actually doing something as compared to yandev's indecipherable 30-condition if() statements and pages and pages of else-if.
No comments though. Gross.
No comments though. Gross.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I don't know anything about coding. Did he write an entire game as one entity rather than in smaller chunks that each do a specific thing and work together?
if (blockType !== 'blank') {
var oShape = '<circle fill="none" class="oShape" stroke="#000000" stroke-width="5" cx="40" cy="40" r="30"/>';
var oOutline = '<path class="outline" d="M40,74.5C20.977,74.5,5.5,59.023,5.5,40S20.977,5.5,40,5.5S74.5,20.977,74.5,40S59.023,74.5,40,74.5L40,74.5 z"/>';
SVGString += '<svg version="1.2" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" x="0px" y="0px" width="80px" height="80px" viewBox="0 0 80 80" xml:space="preserve"><defs></defs>';
if (blockType == 'circle') {
//SVGString += oOutline;
SVGString += oShape;
}
if (blockType == 'base') {
SVGString += '<polygon class="shape" points="62.5,45 62.499,34.999 52.071,35 59.445,27.625 52.374,20.555 44.999,27.93 44.999,17.5 35,17.5 35,27.929 27.625,20.555 20.555,27.625 27.928,35 17.5,35 17.5,45 27.929,45 20.555,52.374 27.625,59.445 35,52.072 34.999,62.499 45,62.5 44.999,52.07 52.374,59.445 59.445,52.374 52.071,45 "/>';
SVGString += '<circle class="jewel" cx="40" cy="40" r="7.5"/>';
}
if (blockType == 'star') {
SVGString += '<polygon class="shape" points="62.5,45 62.499,34.999 52.071,35 59.445,27.625 52.374,20.555 44.999,27.93 44.999,17.5 35,17.5 35,27.929 27.625,20.555 20.555,27.625 27.928,35 17.5,35 17.5,45 27.929,45 20.555,52.374 27.625,59.445 35,52.072 34.999,62.499 45,62.5 44.999,52.07 52.374,59.445 59.445,52.374 52.071,45 "/>';
}
if (blockType == 'ostar') {
SVGString += oShape;
SVGString += '<polygon class="shape" points="62.5,45 62.499,34.999 52.071,35 59.445,27.625 52.374,20.555 44.999,27.93 44.999,17.5 35,17.5 35,27.929 27.625,20.555 20.555,27.625 27.928,35 17.5,35 17.5,45 27.929,45 20.555,52.374 27.625,59.445 35,52.072 34.999,62.499 45,62.5 44.999,52.07 52.374,59.445 59.445,52.374 52.071,45 "/>';
}
if (blockType == 'plus') {
SVGString += '<polygon class="shape" points="62.5,35 45,35 45,17.5 35,17.5 35,35 17.5,35 17.5,45 35,45 35,62.5 45,62.5 45,45 62.5,45 "/>';
}
if (blockType == 'oplus') {
//SVGString += oOutline;
SVGString += oShape;
SVGString += '<polygon class="shape" points="62.5,35 45,35 45,17.5 35,17.5 35,35 17.5,35 17.5,45 35,45 35,62.5 45,62.5 45,45 62.5,45 "/>';
}
if (blockType == 'cross') {
SVGString += '<polygon class="shape" points="59.445,52.374 47.071,40 59.445,27.625 52.374,20.555 40,32.929 27.625,20.555 20.555,27.625 32.929,40 20.555,52.374 27.625,59.445 40,47.071 52.374,59.445 "/>';
}
if (blockType == 'ocross') {
SVGString += oShape;
SVGString += '<polygon class="shape" points="59.445,52.374 47.071,40 59.445,27.625 52.374,20.555 40,32.929 27.625,20.555 20.555,27.625 32.929,40 20.555,52.374 27.625,59.445 40,47.071 52.374,59.445 "/>';
}
if (blockType == 'arrow1') {
SVGString += '<polygon class="shape" points="22.42,57.58 46.762,52.419 40,47.071 59.445,27.626 52.374,20.555 32.929,40 27.582,33.238 "/>';
}
if (blockType == 'arrow11') {
SVGString += oShape;
SVGString += '<polygon class="shape" points="22.42,57.58 46.762,52.419 40,47.071 59.445,27.626 52.374,20.555 32.929,40 27.582,33.238 "/>';
}
if (blockType == 'arrow2') {
SVGString += '<polygon class="shape" points="40,64.861 53.563,44 45,45 45,17.5 35,17.5 35,45 26.438,44 "/>';
}
// ... it continues for a couple more pages like this
// Cosmo apparently doesn't know that else if statements are a thing, as such each string comparison must be evaluated every time the function is called.
// This is a very bad thing. A good alternative would be switches, or dictionaries of functions.
}
Oh, God, he doesn't know about "switch", does he?
Oh, God, he doesn't know about "switch", does he?
Oh, God, he doesn't know about "switch", does he?
I don't know what started this myth about a switch block being in any way better than a lengthy if-else chain, since I see it regurgitated so often in /v/ threads about YandereDev. Sure, it is a little more DRY, but it doesn't solve the piss-poor control flow. In fact it makes it worse since most switch implementations require `break` statements and other fuckery which needs to be maintained
This issue in particular would be better solved as covered by @awoo
I don't know what started this myth about a switch block being in any way better than a lengthy if-else chain, since I see it regurgitated so often in /v/ threads about YandereDev. Sure, it is a little more DRY, but it doesn't solve the piss-poor control flow. In fact it makes it worse since most switch implementations require `break` statements and other fuckery which needs to be maintained
function getMoves(blockType) { // used for highlighting blocks
var blockList = {
'base': function () { return [[-1,-1], [0,-1], [1,-1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]]; },
'star': function () { return [[-1,-1], [0,-1], [1,-1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]]; },
'ostar': function () { return [[-2,-2], [0,-2], [2,-2], [-2, 0], [2, 0], [-2, 2], [0, 2], [2, 2]]; }, // A dictionary of functions is not a bad idea,
'p1': function () { return [[-1,-1], [0,-1], [1,-1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]]; }, // but it's probably better to not to allocate one EVERY CALL
'p2': function () { return [[-1,-1], [0,-1], [1,-1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1]]; },
'plus': function () { return [[0,-1], [-1, 0], [1, 0], [0, 1]]; },
'oplus': function () { return [[0,-2], [-2, 0], [2, 0], [0, 2]]; },
'cross': function () { return [[-1,-1], [1,-1], [-1, 1], [1, 1]]; },
'ocross': function () { return [[-2,-2], [2,-2], [-2, 2], [2, 2]]; },
'hbar': function () { return [[-1, 0], [1, 0]]; },
'ohbar': function () { return [[-2, 0], [2, 0]]; },
'vbar': function () { return [[0, -1], [0, 1]]; },
'ovbar': function () { return [[0, -2], [0, 2]]; },
'tlbr': function () { return [[-1, -1], [1, 1]]; },
'otlbr': function () { return [[-2, -2], [2, 2]]; },
'bltr': function () { return [[-1, 1], [1, -1]]; },
'obltr': function () { return [[-2, 2], [2, -2]]; },
'arrow1': function () { return [[-1, 1]]; },
'arrow11': function () { return [[-2, 2]]; },
'arrow2': function () { return [[0, 1]]; },
'arrow22': function () { return [[0, 2]]; },
'arrow3': function () { return [[1, 1]]; },
'arrow33': function () { return [[2, 2,]]; },
'arrow4': function () { return [[-1, 0]]; },
'arrow44': function () { return [[-2, 0]]; },
'arrow6': function () { return [[1, 0]]; },
'arrow66': function () { return [[2, 0]]; },
'arrow7': function () { return [[-1, -1]]; },
'arrow77': function () { return [[-2, -2]]; },
'arrow8': function () { return [[0, -1]]; },
'arrow88': function () { return [[0, -2]]; },
'arrow9': function () { return [[1, -1]]; },
'arrow99': function () { return [[2, -2,]]; },
'blockade': function () { return [[]]; },
'blank': function () { return [[]]; },
'ice': function () { return [[]]; },
'knight': function () { return [[1, 2], [2, 1], [-1, 2], [2, -1], [1, -2], [-2, 1], [-1, -2], [-2, -1]]; },
'mine': function () { return [[]]; },
'reclaim': function () { return [[]]; }
};
if (typeof blockList[blockType] !== 'function') {
console.log ("SHIT! SHIT!"); // cool error messages dude
throw new Error('Invalid action.');
}
return blockList[blockType]();
}
This is absurd. Let me explain: He needs to look up a word and doesn't have a dictionary. So he creates a dictionary, looks up the word, then destroys the dictionary. Every time he needs to look up a new word, he recreates the entire dictionary from scratch and destroys it again. Needless to say, he should simply keep the dictionary.I wish I knew why this code was so bad. I guess either way I'd still think it looks like shit.
W E A K C H I N
E
A
K
C
H
I
N
She really has no clue does she? wow. Maybe one day she will figure out the answers to these questions. Dear lord.
When you think about it, Wind Waker was a pretty long run, about 4-5 hours if I remember correctly. Still raked in views by the thousands. Seems like no run he does now can help.Seems like he's been only getting 120~ views tops on his Zelda speedruns. Compared to his glory days... yikes.
His runs are waaay too long (5-6 hours) who has time to watch all that in one sitting? He should do the most popular run, IMO.