5

I’m Programing an rpg app using c++ to run some home brew. For character creation, I’d use items and classes and races as enums right? And I can give enums stats like say, a sword would have cutting damage and base attack as 5. Or selecting “wizard” and taking on the base stats of whatever level it so be...

Comments
  • 3
    sounds like structs would scale better
  • 1
    @synemeup @SonKykun
    yeah, if you use enums everything is hardcoded.
    if you use structures + functions (like create_type creates a new one, etc), it becomes a breeze to modify it thereafter. also it leaves you space for mods for instance:
    text file gets read by init function which puts everything in place. cant do that with enums
    also it avoids the issue of having to recompile the thing if you change gameplay related stuff if you base all data on text files.
    youre gonna have to load in your sprites/textures/meshes anyways... might as well go all the way
  • 2
    @bad-frog which is why all rpg’s I have heard about uses structs or similar and config files.

    Sure, its slightly slower code, but that is not going to be the bottleneck anyway.
  • 2
    @Voxera you can be pretty sure all games use text files at a certain level. even if later on those are compressed (those ubiquitoous .pak files)

    its a measure to improve effectiveness.

    when the gameplay values are hardcoded, often there are many places where the code has to be changed for tweaks to take effects. having those values external to the code is a serious advantage from the point of view of a solo coder.

    if in a team, it allows for compartimentalisation: once the engine is done, mission/world builders dont need to touch, understand, or be qualified to modify the engine code.

    but i think the greatest advantage of them all is being able to re-use an existing engine for a new project

    and it isnt a problem performance-wise:
    you dont want to be reading files every 5 secs, you load (read) them during the loading screen.

    once its all in the memory, it makes no difference. and can be even faster than using enums and such if you limit dereferencing by having good structures
  • 1
    yeah, enums look nice on paper, but these are just a placeholder for a number...
    .. which you have to input as an index.
    which means you have 1 dereferencing and pointer arithmetic.
    now multiply this times all your attribute arrays
    (like sword is enum nr x, then you have to plot that into an array for say, physical damage, then another to get durability etc...)

    using a structure you do pointer arithmetic only once, to find the root of the structure.
    after that is all pure dereferencing: you skip half the process needed with arrays:)

    also having structures allows for more flexibility and ease in expanding.

    if you need another type of damage, say:
    with enums it throws off all your arithmetic.

    with structures, you just add another type of value in your header file.
  • 3
    since you're new, I don't know what level of programmer you are... but here's the most basic advice I can give you

    Build an Minimal Viable Product (MVP) first, worry about implementation later.

    first get a thing that functions properly... you can rework any of the code into anything else once you have a functional game. You don't want to get stuck deciding whether to use enums or file inputs before you even have your first map ready...

    I'd very much advice you to use the simplest and easiest road to take first to get a product into peoples hands...
  • 1
    @bad-frog I know, just wanted to keep it open, otherwise you can bet someone find one that is not using text files ;)

    Like the old fortran based adventure, not really an rpg though.
Add Comment