Code:
Problem description: Hello! I was trying to create something like an "after-image" effect. When a mob is dashing, I made it so that it creates a mirror image of himself/herself with random rgb mixed into the after image's icon. The project is using pixel movements and a movement loop is being called every tick.
I tried using the image proc, and I've also tried creating an object... Both seemed to lag quite a bit since 20-30 of image/objs were being created. Is there an efficient way of accomplishing this task?
Thanks!
Jul 12 2015, 8:16 pm
|
|
Show the code of what you are doing. Icon procs are likely the source of your problem.
|
var/turf/t = loc This is being called every tick (movement loop)whenever the dashing variable is ticked on in the mob. |
i.icon+=rgb(rand(250),rand(250),rand(250)) That's the source of your problem. You really don't want to be adding random colors to icons because icon modification is slow, generates resources that are NEVER garbage collected while the world is running, and they have to be sent over the network to every client that sees them. Here's what I'd do: create a slightly transparent object where the player is standing, then set its blend mode to additive. var/obj/o = new(loc) Though, I'd really suggest making this into an object: effect Now all you have to do is call:
new/effect/afterimage(loc,src)
somewhere in the proc. |
In response to Ter13
|
|
Thank you very much!
I would've never known that the icon proc would be the problem without your help. |
I would've never known that the icon proc would be the problem without your help. Biggest thing I can say on the subject, is that if you are generating icons on demand, it should be avoided where at all feasible. Use atom.color and alpha and blend modes where possible. It's fine for a limited subset of things like player customization, but ideally you don't actually want to give the player the ability to fully customize things. You lose artistic control over the way your game looks, and that gives players the ability to destroy the visual appeal of your game, thus driving away potentially interested players. Give players the choice between a limited subset of color customization options that fit the overall palette for your world. This has the added benefit of reducing the dynamic cache size and reducing network overhead while giving the players options for customization without destroying the visual appeal of your game. It's very rare that generating new icons at runtime will ever be necessary. |