As far as I know, most maps are in some sort of text-based format due to limitations of stuff like XML and YAML. It's simply inefficient to encode a maze/platform in something like XML - there is alot of wasted text. However if you wanted to you could do something like K-Bal suggested.
Do you find it efficient enough to loop through the entire YAML document each time you need to find an enemy. I was thinking of doing this but I'm not sure whether it will be efficient enough.
Not so good if you are dynamically creating enemies, which is not the case in my game. You could save an enemy preset each time an enemy is loaded and on further requests just return a clone.
Do you find it efficient enough to loop through the entire YAML document each time you need to find an enemy. I was thinking of doing this but I'm not sure whether it will be efficient enough.
Wait, wait, wait. I'm confused as to what you're doing with this.
Are you not loading each enemy into a class/structure then just referring to them in memory later? Shouldn't loading be a one-time deal?
GyroVorbis wrote:Are you not loading each enemy into a class/structure then just referring to them in memory later? Shouldn't loading be a one-time deal?
It should be. This was just a first quick'n'dirty implementation from my game.
GyroVorbis wrote:Are you not loading each enemy into a class/structure then just referring to them in memory later? Shouldn't loading be a one-time deal?
It should be. This was just a first quick'n'dirty implementation from my game.
Oh, right, right. I wasn't looking at the original code to see that it was from a LoadEntity() function. I just saw it quoted and thejahooli asked about looping through a whole file to get an entity.
thejahooli, he's loading all of the entities at one time, so if he wanted to "find one," it's a matter of iterating through his entity list to find a particular one, not accessing the file.
This kind of thing is perfectly fine for most applications, since the processing is only going on when the level/file is being loaded. After that, it's not like you're still referring back to an XML/YAML file.
Yeah, but if I create two enemies, it will iterate two times through the document. For better performance you would buffer the enemy template the first time and create copies on further requests. However, this is faster, but requires more memory for buffering the enemy templates.
K-Bal wrote:Yeah, but if I create two enemies, it will iterate two times through the document. For better performance you would buffer the enemy template the first time and create copies on further requests. However, this is faster, but requires more memory for buffering the enemy templates.
Oh, I gotcha.
Yeah, in ES, we are loading "EnemyAttributes" so that if you were to construct one, it's common data is already loaded into a structure, and the enemy is just given a pointer to the attributes.