15
u/MCKoleman Jan 11 '21
Why are the functions 4000+ lines of code? Are there really no helper functions in there?
14
244
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 10 '21 edited Jan 11 '21
Image Transcription: Code
[This post has two code snippets in separate images.]
[The first snippet is as follows (the two functions are both condensed, showing them to be around 4000 lines long each):]
protected override void Update(GameTime gameTime)
{
protected override void Draw(GameTime gameTime)
{[The second snippet is as follows:]
protected override void Draw(GameTime gameTime)
{
public void UpdatePlayerPosition()
public string ConvertKeyToChar(Keys[] key, bool shift)
{
foreach (Keys 1 in key)
{
Keys currentKey = q;
if (previousKG.IsKeyUp(q) && currentKG.IsKeyDown(q)
{
switch (q)
{
case Keys.Space: return " ";
// Escape Sequences
case Keys.Enter: return "\n"; // Create a new line
case Keys.Tab: return "\t"; // Tab to the right
// D-Numerics (strip above the alphabet)
case Keys.D0: return shift ? ")" : "0";
case Keys.D1: return shift ? "!" : "1";
case Keys.D2: return shift ? "@" : "2";
case Keys.D3: return shift ? "#" : "3";
case Keys.D4: return shift ? "$" : "4";
case Keys.D5: return shift ? "%" : "5";
case Keys.D6: return shift ? "^" : "6";
case Keys.D7: return shift ? "&" : "7";
case Keys.D8: return shift ? "*" : "8";
case Keys.D9: return shift ? "(" : "9";
// Numpad
case Keys.NumPad0: return "0";
case Keys.NumPad1: return "1";
case Keys.NumPad2: return "2";
case Keys.NumPad3: return "3";
case Keys.NumPad4: return "4";
case Keys.NumPad5: return "5";
case Keys.NumPad6: return "6";
case Keys.NumPad7: return "7";
case Keys.NumPad8: return "8";
case Keys.NumPad9: return "9";
case Keys.Add: return "+";
case Keys.Subtract: return "-";
case Keys.Multiply: return "*";
case Keys.Divide: return "/";
case Keys.Decimal: return ".";
// Alphabet
case Keys.A return shift ? "A" : "a";
case Keys.B return shift ? "B" : "b";
case Keys.C return shift ? "C" : "c";
case Keys.D return shift ? "D" : "d";
case Keys.E return shift ? "E" : "e";
case Keys.F return shift ? "F" : "f";
case Keys.G return shift ? "G" : "g";
case Keys.H return shift ? "H" : "h";
case Keys.I return shift ? "I" : "i";
case Keys.J return shift ? "J" : "j";
case Keys.K return shift ? "K" : "k";
case Keys.L return shift ? "L" : "l";
case Keys.M return shift ? "M" : "m";
case Keys.N return shift ? "N" : "n";
case Keys.O return shift ? "O" : "o";
case Keys.P return shift ? "P" : "p";
case Keys.Q return shift ? "Q" : "q";
case Keys.R return shift ? "R" : "r";
case Keys.S return shift ? "S" : "s";
case Keys.T return shift ? "T" : "t";
case Keys.U return shift ? "U" : "u";
case Keys.V return shift ? "V" : "v";
case Keys.W return shift ? "W" : "w";
case Keys.X return shift ? "X" : "x";
case Keys.Y return shift ? "Y" : "y";
case Keys.Z return shift ? "Z" : "z";
// Oem
case Keys.OemOpenBrackets: return shift ? "{" : "[";
case Keys.OemCloseBrackets: return shift ? "}" : "]";
case Keys.OemComma: return shift ? "<" : ",";
case Keys.OemPeriod: return shift ? ">" : ".";
case Keys.OemMinus: return shift ? "_" : "-";
case Keys.OemPlus: return shift ? "+" : "=";
case Keys.OemQuestion: return shift ? "?" : "/";
case Keys.OemSemicolon: return shift ? ":" : ";";
case Keys.OemQuotes: return shift ? "\" : "'";
case Keys.OemPipe: return shift ? "|" : "\\";
case Keys.OemTilde: return shift ? "~" : "`";
}
}
}
return string.Empty;
}
}
}This is an unofficial transcription. Our bot doesn't currently pick up gallery posts, so I'm doing this in an unofficial capacity. If you're interested in why I've done this, feel free to message me!
111
61
u/OrganicBid Jan 10 '21
No reason to punish yourself like that even if it is to help other people.
49
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 10 '21
Lol, how do you know? Maybe I've done terrible things, such as ignoring my alarm...
11
u/ywBBxNqW Jan 11 '21
I set three in a row just in case.
3
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Good idea. I'll try that.
4
u/OrganicBid Jan 11 '21
I also recommend Alarm Clock Xtreme (Android). Having to solve arithmetic in the morning to turn off the alarm is effective.
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Will give that a try as well! Thank you!
2
u/literallyfabian Jan 11 '21
honestly, i'm feeling pretty sure these posts gets requested to be transcribed just to troll
20
u/IsaGoodFriend Jan 10 '21
My god, this is an insane amount of work
20
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 10 '21
It wasn't too much, but those characters were annoying to update after the copypaste finished. Didn't help that the configuration isn't the one I'm used to.
12
u/Beloncio Jan 10 '21
I hate being the one to point this after your awesome work but... You misspelled the first 'protected'
14
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
It's good to point out the mistakes! I want the transcription to be as accurate as possible. I'll fix that as soon as I get back to my PC. :)
2
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Fixed now
I may have forgotten about it and gone to bed last night, thanks again for pointing out!5
u/vasilescur Jan 10 '21
Please tell me you used OCR for this...
13
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Since the bot can't find it, I can't show you what its attempt would have been, but it wouldn't have been pretty.
We have pretty much the best OCR not behind a huge paywall, and one of the many, many things that mess it completely is code. It drops formatting, loses characters and even whole lines, splits lines halfway through, and generally just has a bad time.
So because both the bot can't see it and the bit can't do it, nope, I didn't use OCR.
5
u/PC__LOAD__LETTER Jan 11 '21
Oh dear. I think I’m missing something - why?
7
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Usually the transcriptions are to aid blind/otherwise-visually-impaired people who rely on screen readers to browse Reddit, since that technology generally can't reliably read text from images.
I think few people would want to listen to this, though, so in this case it's probably more helpful for people whose internet or client can't load the image, and anyone wanting to copy-paste it.
5
u/alex_hawks Jan 11 '21
I'm the description of the first snippet, you say characters, I think you mean lines
2
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Oh shoot yeah. I'd gone to bed. I'll fix that once the PC's booted up.
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Fixed. Thanks for pointing out.
4
u/matjojo1000 Jan 11 '21
Btw, the methods aren't 4000 characters but 4000 lines long
3
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Thanks. I'll fix it once I boot up the PC. Trying to edit these on mobile is hell.
2
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Fixed now. Thanks again for pointing out.
3
2
2
1
u/shcanthinkofusername Jan 11 '21
do you get paid for this to transcribe?
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 11 '21
Nope, I'm a volunteer. The main wiki page at r/TranscribersOfReddit explains more (I'd link the specific page but I'm on mobile).
81
16
u/roycohen2005 Jan 10 '21
The best part is that it returns a string and not a char as suggested by the name.
16
u/tangerinelion Jan 10 '21
I liked
foreach (Key q in keys)for the excellent and obvious variable name.
14
9
u/Kidknudi Jan 11 '21
This is a good r/badcode submission simply for having been written in npp
11
1
u/MADH95 Jan 17 '21
I go to uni with him and suggested he upload it here.
It wasn't written in npp it was written in visual studio it just wouldn't open in the latest version so he had to improvise.
3
4
2
u/Not_Sugden Jan 11 '21
case Keys.D2: return shift ? "@" : "2"
because only the american keyboard exists you know, its not like any other keyboards actually have the " as shift+2
1


73
u/[deleted] Jan 10 '21
I don't see an alternative, at least in Monogame/XNA? I've written similar code in an older version of my game engine too. Or I'm living under a stone?