TerrariaClone – An incomprehensible hellscape of spaghetti code
41–50 of 289 posts
Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#42> The TerrariaClone.init() method, which is over 1,300 lines long, actually grew so large that the Java compiler started running out of memory trying to compile it! Seems surprising, 1.3kloc doesn't feel that big in the scale of things. I wouldn't be surprised if some of the methods at $work would be on the same scale, and it compiles just fine (relatively speaking..). And based on quick scroll-through, there isn't r…
Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#43I'd actually try to recruit raxod502 at the high-school senior level. It certainly shows passion and commitment. You just need to grok the higher level abstractions. And may in the end even find your "spaghetti" version is actually more performant at run time ;) The thing is you sort of need to write like this for the first draft of your first game. And Terraria is pretty ambitious. Considering most people struggle w…
Writing code in spare time, not to mention 11,000 lines of it, already sets any high schooler (or any beginning programmer) apart from the majority of peers. It's shocking how little students in "AP" computer science courses actually end up doing, and how few do anything outside of class. Given the choice between interviewing a student who had produced nothing but verbiage and one who had produced TerrariaClone, I wo…
The AP class was mainly a self or group study class inside of a lower level programming class.
We didn't get as much directed study, but we basically were allowed to chose projects that interested us and spent a lot of time developing them and getting help, iterating, figuring it out.
We ended up doing only OK on the AP exam, but we had built a pretty impressive little java app by the end. A scrolling tile based map, enough network code to run a chat and let users join, and we had started building some game logic on top of our multiplayer game room. Very cool and informative, but not exactly what the AP exam was looking for.
Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#44I love DoubleContainer: https://github.com/raxod502/TerrariaClone/blob/master/src/Do... which is fortunately only used in a comment here: https://github.com/raxod502/TerrariaClone/blob/9ea04b15add48...
Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#45Earlier quoted context omitted.
This is decompiled code, not the original source, so much/most/all of the craziness probably comes from that.
Decompiling .NET or Java binaries usually yields code very close if not identical to the original source code, at least unless an obfuscator was used but that seems not to be the case here. Chances are very good the original source code looks almost exactly like that code, maybe with some additional comments.
Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#46I did the same trying to write a Minecraft clone back in 2012: https://github.com/beager/craftalike I'm very much not proud of the code, it's sloppy, incomplete, quite copy-pasta. But it helped me learn a lot of concepts about game dev that a web dev wouldn't know, and it was tremendously exciting to create something in code that you could compile and play around with. No regrets.
We basically gave up after the networking stuff grew over our heads.
Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#47Earlier quoted context omitted.
This is decompiled code, not the original source, so much/most/all of the craziness probably comes from that.
Decompiling .NET or Java binaries usually yields code very close if not identical to the original source code, at least unless an obfuscator was used but that seems not to be the case here. Chances are very good the original source code looks almost exactly like that code, maybe with some additional comments.
What was no doubt written like this:
if(a
Decompiled into this: if(a Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#48Re: TerrariaClone – An incomprehensible hellscape of spaghetti code
#49The real Terraria code isn't much better. Here's their 3MB [decompiled] NPC.cs: https://raw.githubusercontent.com/csnxs/Terraria/67de21a27e1... They had serious problems implementing multiplayer because they had to synchronize objects with 50KB of state every frame.
Those SetDefaults methods.. ouch. On the plus side, it's fun to press the page down and see the code 'animate' from left to right