Code Organization

preview_player
Показать описание
I talk about how I structure my code, using inventory as an example, since it is a common component of most (if not all) roleplaying games.
Рекомендации по теме
Комментарии
Автор

Thank you for replying my question. Your experience shows how that should be done. The way you described it, with can_equip() method, also allows for example, easily implement highlighting items which are equippable to some particular slot, maybe when player mouse over the gear slot.

greenya
Автор

As someone who has written more than one complex inventory system, I definitely like your design preferences. Separating the questions from the commands is a good strategy to keep the functioning code clean. Even a simple inventory system can become complicated very quickly. My system used a layer mechanic, where equipping a clothing-type item would automatically unequip anything that overlaps the same layers on the same body parts, as well as show the player which items were going to conflict with it before any action was taken. I think my inventory UI module ended up being the most bloated module in the game, with the number of compiled bytes surpassing the character AI module. Anyway, you've essentially started an online gamedev dojo, and we appreciate it very much, sensei.

robertmoats
Автор

Hey those technical talks are pretty great, we need more of those with this level of details

jarsal_firahel
Автор

This is awesome advise for any code project, not just games. The more I code, the more I learn how important it is to keep things separated into independent modules with no dependencies. This also makes unit testing easier for stability and let's you reuse these small components in future games without having to migrate parts of your old game you don't need.

Tiden
Автор

Brilliant. Hadn't thought of breaking return codes into their own "Can" methods, or even reusing Inventory components across NPCs, chests, etc. Thanks as always, Tim!

parwesh
Автор

Glad having checks and actions for inventory is basically what I did for my inventory code, but also having to branch out for each type of item like stackable or not, etc. Also these technical talks are just as great as wig story talks lol

LunarcomplexMain
Автор

Love the discussions about clean code organization! Event systems are really good for decoupling and making the code clean

kirglow
Автор

WOW, this video was pure gold. Thank you very much. I would like to hear more about these.

OpenGLever
Автор

I don’t know a single thing about game design, nor will I ever have anything to do w it in my career, but I watch all your videos.

dtoodlez
Автор

yay, trying to work out how to structure code for my first project, good timing!

rolypk
Автор

Love these kinds of talks. More please! How about "spells" or "effects"?

buttersstotch
Автор

Programming advice from the legend Tim Cain himself! You kids don't know how lucky you have it :)

JohnMcLaren-sh
Автор

This is awesome, I have nothing to do with game development, but now I really want to build an inventory module. This kind of high-level info is fairly rare afaik, love it!

dmon
Автор

Thank you! These sort of tips are invaluable and help me find a path forward instead of wanting to rip my hair out. Thank you!

Smeighl
Автор

Excellent video. I am not a game developer, but your explanation for this type of system might help me in designing a tool I want to build. Getting design tips from someone with so much experience and avoiding pitfalls is appreciated and insightful 😄

justthink
Автор

My inventory array, sobbing, running away after Tim says he doesn't care :(

Great vid, your structure implies a bunch of commonly run into issues that I wouldn't have considered just thinking about it!

lukusridley
Автор

Tim in for some more classic wisdom. You always make my morning with your videos 👍

VenturaHighwayman
Автор

As an amateur programmer this was very insightful. Thank you!

TPubbie
Автор

Thanks for this, I really like more detailed stuff like this. I personally (solo indie) use lists of struct pairs: {name, quantity} for various quality of life reasons.

x_
Автор

I am digging these technical videos a lot!

mrmeeker