on hard coded vs soft coded constants

posted in A different way
Published September 11, 2013
Advertisement
on hard coded vs soft coded constants


a recent posting of mine:


[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]rpg/person sim, fps interface:[/background]

[/font][/color]
[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]~100 monster types, ~250 object types, ~60 weapon types, ~45 skill types, ~200 meshes, ~300 textures, ~ 10 materials, ~100 models, ~30 animations, 2500x2500 mile game world.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]models and animations are made using an in-game editor, and saved to disk. the list of models and animations to load is hard coded. [/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]meshes (.x) and textures (.bmp or .dds) are loaded from file. the list of files to load is hard coded.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]the game world is procedurally generated.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]everything else is hard coded: monster types, object types, weapon types, materials, skill types, etc.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]the reasoning is as follows:[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]1. for everything hard coded, the final values will be known constants for the final release version. so soft coding is only an aid in dialing in these "tune-able constants", such as the list of all meshes to load (the game loads everything once at program start). none of this stuff changes very much, only while dialing in the game. and it doesn't change at all once dialed in. and it never changes in versions released to the public - only in updates. granted, a zipped 2K text file list of meshes to load is smaller than a 1.2 meg zipped exe, but unless your releases are minor updates, odds are the code will change too. as always it depends on what you're doing.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]2. since soft coding is not required for release, and since i have full source access, and rebuilt times are not bad, its overkill.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]3. in the end, you have to "hard code" or type in this data somewhere using some syntax. if there's no difference except running faster and less code complexity, why not just do it in the native programming language? no need to learn a scripting language, no need to write hooks and calling wrappers for game engine functions so your scripts can invoke calls to the game engine, no need to find and integrate a scripting solution into the project. no slow 4gl / 5gl / scritping BS, no need to use multiple languages to code a game, and so on.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]so i soft code the models and animations. they are the type of data (scales, rotations, offsets, mesh and texture ID #'s) that really scream for an editor. i mean could you imagine having to use a markup language to do this:[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]gallery_197293_681_39669.jpg[/background]

[/font][/color]




[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]and having to picture in your head what the model looks like?[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]but everything else is more or less a set it one time and forget it kind of thing, unless you need to tweak stats. IE just add the info for a new whatever to the "list" or "database" when you add a new mesh, or monster type, or object type, or whatever.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]so its really easiest to just use code to say essentially: monstertype[new_monster].hp=100. and be done with it.[/background]

[/font][/color]

[color=rgb(40,40,40)][font=helvetica]

[background=rgb(250,251,252)]sure you may have to go back later and tweak that "100", but only if you didn't figure out the correct value the first time. you should have the "rules" of the game figured out before you code. wink.png[/background]

[/font][/color]
0 likes 1 comments

Comments

Norman Barrows

Note that i recently upgraded the Z game library to load soft coded lists of meshes, textures, model, and animations if desired.

I also upgraded the Z "engine" to load soft coded lists of target types and targets if desired.

But Caveman uses none of this (yet), for the reasons listed above.

September 11, 2013 09:11 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement