Legacy GM Can I use external images as sprites?

Psycho_666

Member
Pretty much what the title said.
I looked around in the help files and I didn't see anything. But I seems to vaguely remember something in GM8... Or maybe I'm completely off and that's not possible.
 

kupo15

Member
It will also take twice the texture memory as well compared to putting it in the IDE. Not worth it imo unless for a very specific situation
 

kupo15

Member
Ah... I see...
Ok, thank you for your time. So in general I should avoid using that
yes, I don't see a need to use it unless you are creating a dev tool where you are able to constantly add and remove resources externally and want to dynamically load them without having to recompile the program. Its a pretty useless function for actual game development because of the cons it comes with. If it didn't use double texture memory then it would be super useful

My project is using a lot of texture memory and I haven't had any issues yet simply using GM as is for the most part. I don't use sprite_add and believe me, I've explored using it in depth
 

Psycho_666

Member
My project is using a lot of texture memory and I haven't had any issues yet simply using GM as is for the most part. I don't use sprite_add and believe me, I've explored using it in depth
I'll be honest, my idea was graphical moding of some stuff... I make a card game and I want people to be able to create moded cards with custom icons. But now that I'm thinking about it, maybe it's not such good idea to give people the ability to destroy the balance I will have to create a bit later on...
 
R

robproctor83

Guest
If you can get away with only letting the user add a single photo you will probably be okay. Adding a single extra texture swap is probably not a huge deal in the grand scheme of things and so if you can say, make all the users custom art fit into a single texture page, like 1 large sprite sheet, then I'm guessing it will be okay for the most part... Someone correct me, but I would suspect adding a single remote image wouldn't be that big of a deal, no? The big issue would be if you wanted to have a modding community where you can let users find cards from all different players and add them to their game. You could actually possibly do that too if you were to combine the users selected cards into a single image. Now, doing that however would be a lot more difficult in actual practice.

Unfortunately there isn't a good way to make games "moddable" by GM that I can find. You can add remote images, like discussed above, but it's not something you should do if at all possible. Besides not being able to really allow for remote images you also can't really give the user the ability to add custom events either. So for example if you wanted to let them not only add a card graphic, but also a script with the card so they could make some custom card actions or something... Can't be done unless you write in your own code processor and the card modders use your limited coding system, but even then it's not really doable to a large degree. A couple of years ago I had looked into making a game I am working on moddable and I guess it hasn't really come along since then.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I would just like to say that while, yes all of the cons mentioned above exist, that doesn't mean it's not possible, or workable... I mean, there are overheads associated with sprite_add() but they may be acceptable to your game! My latest game "Microscope Madness" has a massive amount of texture swaps due to the way I process graphics, yet I still consistently get 500-600 fps on MOBILE, and it also has 7 2048x2048 texture pages to swap between... but do I care? Nope. The game works and looks great! :p

So, yeah, sprite_add can be resource heavy, but if the game works fine using it and gives you no problems, then what's the issue??? People get so hung up on "performance" and micro-optimisations, that they often discard solutions that will actually work fine within the scope of the game being made.

My suggestion... Try it and see! :)
 

Psycho_666

Member
can't really give the user the ability to add custom events either. So for example if you wanted to let them not only add a card graphic, but also a script with the card so they could make some custom card actions or something...
Damn... I haven't thought of that...
Yeah, I guess I can super limit the modding, but then it's kinda pointless. If I limit the modding I may as well just throw in the content...
Yeah, I guess the whole thing is kinda super difficult to program and in general pointless...
 

Ricardo

Member
I use sprite_add intensively without any major issue. As long as you know what you are doing the memory overhead is not a big deal.
 

kupo15

Member
I would just like to say that while, yes all of the cons mentioned above exist, that doesn't mean it's not possible, or workable... I mean, there are overheads associated with sprite_add() but they may be acceptable to your game! My latest game "Microscope Madness" has a massive amount of texture swaps due to the way I process graphics, yet I still consistently get 500-600 fps on MOBILE, and it also has 7 2048x2048 texture pages to swap between... but do I care? Nope. The game works and looks great! :p

So, yeah, sprite_add can be resource heavy, but if the game works fine using it and gives you no problems, then what's the issue??? People get so hung up on "performance" and micro-optimisations, that they often discard solutions that will actually work fine within the scope of the game being made.

My suggestion... Try it and see! :)
Yep, it also depends on how memory intensive your game is. I mean if you aren't using much texture memory and the extra overhead does't fill up the ram sure go ahead and use it if it works. I just didn't know if he was thinking its the perfect dynamic memory solution that will allow you to get the most memory from your game like I originally thought.
 

JeffJ

Member
I really wish there was something like sprite_add_ext() where you could point the sprite to a predefined texturepage, and then be able to reference each sprite separately from that texturepage. It wouldn't have to be a compiletime texturepage, it could be runtime as it is now, but this way you could add all the dynamic sprites to one page (or however many needed for fit) and then have pointers to each sprite. So much more efficient, and so much easier.
 

rIKmAN

Member
I really wish there was something like sprite_add_ext() where you could point the sprite to a predefined texturepage, and then be able to reference each sprite separately from that texturepage. It wouldn't have to be a compiletime texturepage, it could be runtime as it is now, but this way you could add all the dynamic sprites to one page (or however many needed for fit) and then have pointers to each sprite. So much more efficient, and so much easier.
If you use a texture packing tool to make your own texture page you can just read the generated xml/json (or whatever format it exports the sprite data to) into a map of lists (or map of arrays) and use draw_sprite_part() after referencing the sprite by name and pulling the related list / array out to get the coords.

It's a bit messier than it needs to be due to not being able to chain accessors yet, and maybe a bit slower than a native implementation but it's only a small amount of code to get working once you have the texture page and associated sprite coord data.

For OP - the Custom Sprite Framework by Braffolk might be worth looking at if your project is big enough that using sprite_add() as-is might cause issues and/or you think it would benefit your project to use. It's free too so worth a look either way, even if only to have a look at and learn something along the way for the future.

I agree with @Nocturne though, don't pre-emptively optimise before you have tested things out first.
 
Last edited:
Top