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?
ID:265606
![]() Jul 19 2006, 6:55 pm
|
|
Instead of creating a new hud object when the player needs it, would this be better?
var To just add it to there client.screen instead? |
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. |
Or...
Hud 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. |
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.
|
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. 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. |
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. 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 |
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. |
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. |
think of it like this
create list ===> add to list ===> add to hud
compared to the origional
add to hud
...which would be faster?