5 ms·
This version is more up-to-date and has a readme: https://github.com/UTINKA/Terraria https://github.com/UTINKA/Terraria Having looked at a few games' source co
by mac-chaffee 5y ago
This version is more up-to-date and has a readme: https://github.com/UTINKA/Terraria https://github.com/UTINKA/Terraria
Having looked at a few games' source code, are there really any complex games with pretty code? With as many subsystems, items, and enemies as Terraria has, it feels almost inevitable that you'll have complexity like this snippet for determining when to spawn the hair stylist NPC:
else if ((int) Main.tile[index1, y].wall == SpiderUnsafe | flag10)
{
if ((int) Main.tile[index1, y].wall == SpiderUnsafe && Main.rand.Next(8) == 0 && (!flag6 && (double) y >= Main.rockLayer) && (y < Main.maxTilesY - 210 && !NPC.savedStylist && !NPC.AnyNPCs(WebbedStylist)))
NPC.NewNPC(index1 \* 16 + 8, y \* 16, WebbedStylist, 0, 0.0f, 0.0f, 0.0f, 0.0f, (int) byte.MaxValue);
else if (Main.hardMode)
NPC.NewNPC(index1 \* 16 + 8, y \* 16, BlackRecluse, 0, 0.0f, 0.0f, 0.0f, 0.0f, (int) byte.MaxValue);
else
NPC.NewNPC(index1 \* 16 + 8, y \* 16, WallCreeper, 0, 0.0f, 0.0f, 0.0f, 0.0f, (int) byte.MaxValue);
}
- ramesh31 5y ago>Having looked at a few games' source code, are there really any complex games with pretty code? Games don't have the same maintenance requirements as a web application. They are made, shipped, played, and forgotten. So code cleanliness is generally an afterthought. And honestly, most indie game developers are not great programmers. But making a great game has very little to do with programming nowadays. The tooling has come so far that many hit indie games are now built using "no-code" solutions like Unreal Blueprints. And advertising that you hand coded the entire game in C with immaculate coding standards wont make it any more fun.
- autarch 5y ago> They are made, shipped, played, and forgotten. Terraria was released in 2011 and is still getting updates.
- deleted 5y ago[deleted]
- ramesh31 5y ago>Terraria was released in 2011 and is still getting updates. Yes, it was a runaway success. Terraria is a huge outlier in the indie scene for lasting so long. But my point is that the creator almost certainly was not planning to be maintaining this code 10 years later when he wrote it. And so it was written for speed and simplicity, not elegance and maintainability.
- deleted 5y ago[deleted]
- JoeyBananas 5y agoGames are being updated for a lot longer these days.
- DavidPeiffer 5y ago> Having looked at a few games' source code, are there really any complex games with pretty code? I haven't seen the Factorio source code, but having read their blog enough, I have to believe they have beautiful source code.
- devenvdev 5y agoI would recommend anyone in IT to read their blog (and play the game a little for the context) to understand how to wisely deal with complex systems and learn good programming practices. https://www.factorio.com/blog/ https://www.factorio.com/blog/
- remram 5y agoSince this is decompiled, you really can't infer much from it, in terms of code quality. The original might have really detailed comments, and involve additional functions that have been inlined.