ID:265606
 
Instead of creating a new hud object when the player needs it, would this be better?

var
list/Hud_List = list()
world
New()
..()
Hud_List.Add(new/obj/Hud)
mob
verb
Test()
for(var/obj/Hud/H in Hud_List)
src.client.screen += H

To just add it to there client.screen instead?
i'm not sure but i don't think its better because you are creating a list and then taking items from the list and then putting them in the screen. The list takes up more mem then just adding

think of it like this

create list ===> add to list ===> add to hud

compared to the origional

add to hud

...which would be faster?
In response to Shlaklava
Well you are just doing that instead of calling NEW and created a NEW hud you just add an existing one to the client's screen.

Not to be mean or rude, but I was looking for input from someone who can give me a definant answer. Thanks though.
In response to Sniper Joe
Or...
Hud
test_obj
var/xeal_is_sexier_than_you_lol_lol_lol_lol

mob/proc/add_hud()
for(var/obj/o as anything in typesof(/Hud)) // Some comments would be nice wouldn't it? Too bad I'm a bad commenter.
//adding functions here


Of course this is just a brief example, I'm not even sure if it'll work properly. If it doesn't, poo for you.
In response to Xeal
:-\ I know to add a HUD...agh, nevermind, I did some calculations and found out my answer anyway.
In response to Sniper Joe
I have a z level. I make new copies of everything on that z level. I set their screen_locs according to their x and y. I add them to client.screen.
I have a HUD.
I do that whenever I have a shared HUD. It reduces your object count, which saves a bit on memory (and on your object count, should you be in any danger of hitting the limit). Also, adding and removing objects is faster than creating and deleting them outright.
In response to Hazman
Hazman wrote:
I have a z level. I make new copies of everything on that z level. I set their screen_locs according to their x and y. I add them to client.screen.
I have a HUD.

Sounds like FIF's "When I go out" song:
"When I go out I play in the street. I make mash potatos. I get hit by cars!"

Man I miss that band.
In response to Hazman
Hazman wrote:
I have a z level. I make new copies of everything on that z level. I set their screen_locs according to their x and y. I add them to client.screen.
I have a HUD.

And they are talking about efficiency and speed, for which the way you do it is not at all good if you have to do that every time you need a new one.
I had the same problem. Having a shared HUD isn't only faster, it really helps you keep the object count to a minimum.


http://members.byond.com/?command=view_post&post=13677
In response to Shlaklava
I believe you're right that a list would take up slightly more memory, but it would be such a miniscule amount that it wouldn't even be worth using that reason.

Green programming isn't always what makes your game run faster; it's also making the code easier to edit and add to.
In response to SilkWizard
Yes, sharing as much of a HUD as possible is the way to go.

If you do full-screen huds, you can even take it a step farther like I did with Dungeon Diver and make the shareable full-screen HUDs turfs on the map. And since there would only be one screen, you won't have to worry about the turf var overload.
In response to Kunark
I use that for full screen HUDs alot, and big things. It's a really usefull idea.