Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Norman Barrows

Member Since 04 Apr 2012
Offline Last Active Nov 17 2014 08:08 PM

Posts I've Made

In Topic: is there a better way top refer to assets in a game?

17 November 2014 - 08:12 PM


In any case, you shouldn't have code like playwav("some_sound.wav"); though -- more like:
Sound* some_sound = loadwav("some_sound.wav"); //filename processing paid once, pointer obtained
...
playwav(some_sound); // no details of filesystem involved per frame

 

oh trust me, i don't! <g>

 

its more like playwav(some_sound_pointer);    

 

but i'd like to be able to use some more human readable format such as playwav(some_sound_name);

 

preferably without a slow lookup, making everything data driven, or enum'ing everything, but those seem to be the only options.

 

i guess enums would be no more typing than some sort of lookup table, but more typing than coding up a simple string lookup function.

 

otoh, simply keeping a side list of filenames and their indexes isn't that big a deal, i may just stick with that for non-data driven stuff. its less typing than enums.


In Topic: is there a better way top refer to assets in a game?

17 November 2014 - 07:59 PM


Do you have evidence to back up that claim? How is passing a string to a sound playing function noticeably slower than passing an integer?

 

you'd have to convert the string to an array index, then call playwav(i) :

 

#define maxwavs 200

 

playwav(filename):

for i=0 i<maxwavs i++

    {

    if strcmp(wav[i].filename,filename)==0) 

        {

         playwav(i);

         return

        }

    }

 

playwav(i) is simply wav[i].lpd3dsoundbuffer.play (or whatever the exact xaudio2 call is - i'm too lazy to pull up the exact code at the moment, but you get the idea).

 

only by use of a #define or enum or data driven do you avoid the string to index lookup.


In Topic: is there a better way top refer to assets in a game?

17 November 2014 - 07:48 PM

so i take it that data driven is the normal approach, eh? and binding of human readable format to some numeric internal representation is done prior to runtime or perhaps at load time?

 

but i assume that real time on the fly filename to array index conversion would still be too slow for non-data driven, correct? if i'm drawing 16,000 non-instanced meshes, i don't want to be looking up the array index for the mesh filename of each one.  especially if i have hundreds of mesh filenames to search through.

 

 

 

 

 

 

.


In Topic: data organization and cache friendly, data oriented, data driven CES

17 November 2014 - 07:20 PM

a little pseudo coding of one big entity list vs parallel arrays reveals no major code savings using parallel arrays:

 

drawit(drawinfo[i],location[i]) for parallel arrays vs drawit(entity[i].drawinfo,entity[i].location) for one entity list - that type of thing.  

 

with parallel arrays you don't have to type "entity" everywhere, that's about it.

 

since one big entity list is usually not a speed issue, it looks like parallel arrays are only called for if the game runs too slow, and entity list cache misses are your biggest bottleneck, or for other reasons like CES for the sake of being able to define new entity types from existing components without recompiling, or CES as a way out of object hierarchy hell.


In Topic: is there a better way top refer to assets in a game?

17 November 2014 - 01:59 PM

ok, a bit more detail as to my situation:

 

i have libraries (Spiro) / databases (barrows) / pools (Adams) of shared resources: meshes, textures, models, animations, and wavs.

 

they are implemented as static arrays.

 

assets are referred to by array index:      

 

drawinfo.meshID=3;

drawinfo.texID=27;

playwav(7);

aniplayerID=start_ani(3,50);    // model=3 animation=50

and so on...

 

load order defines what filename (and therefore asset) is associated with which array index.

 

all assets are loaded at game start, so which asset is which index never changes. assets and file names may change during development, but the index associated with a particular asset (sphere mesh, granite texture, etc) stays the same.

 

what i want to be able to do is refer to an asset with something more human readable than an array index.

 

something like:    playwav(gigantopithicus_attack_wav);   

 

instead of:  playwav(126);   // 126= gigantopithicus_attack.wav

 


The resource packer translates names to sequential numbers

 

so the resources have human readable names in a level editor of some sort, which get translated into ID #'s for use by the binary?

 

so that would be an example of the data driven with editor approach, requiring data driven code, and an editor, right?

 

it appears that one must go data driven and bind human readable to id number in an editor, or use human readable enums for non-data driven code.


PARTNERS