• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM saving tiles in image_indexes

S

Shadowblitz16

Guest
is it possible to have backgrounds that you batch into a single sprite?

I was thinking along the lines of looping though all the tiles and then appending them to a single image index
game maker I know has a hard time doing things at runtime
so I was just wondering if there was a way to do something like this?

what I probably need is some sort of gms image library
 

RangerX

Member
Tiles or sprites?
If you have tons of TILES they should be tilesets.
Besides, having alot of sprites, background, tilesets and what not doesn't directly affect your game at run time. It only takes more memory, which shouldn't really be a concern. HUGE pro games run fine with alot of graphical assets in memory, it can't be more a problem for you.
 
S

Shadowblitz16

Guest
@RangerX
well I've been trying to recreate a system where everything is stored in a tile index and you can access them by referencing a index, width, height, and framenumber
and then returning a sprite you can animate

now that I think about it it would be nice to have a extension or dll for something like this
 

RangerX

Member
Why this system? GameMaker DOES index your graphic assets and you can reference them and display them according tons of parameters width, height, framenumber, etc.
 
A

anomalous

Guest
I don't understand the request.
A background batched into a sprite, so that you can reference a tile index, and get returned a sprite "you can animate"?

background : a single image, it has no frames. Tiles come from a background.

sprite: one or multiple images, each stored as a subimage. Having >1 subimage typically means its animated (doesn't have to be)

A tile: is a "piece" of a background, that you can add to a room. Once added, it has its own id distinct from the background it came from (although any info from the background can be looked up).

So after reading that, can you describe what you're trying to do?
Are you trying to use a sprite sheet or something you copied from the internet?
 
S

Shadowblitz16

Guest
its for project organization
I would just use some sort of sprite loading function that returns sprites that are indexes in gamemakers texture pages
but gamemaker doesn't support it. which makes it extremely unoptimized
I want to use external graphics/scripts eventually but I would need some sort of extension, end every good one out there isn't compatible with studio
 
E

eltantillo

Guest
@RangerX
no when you load a sprite during runtime it creates a whole new texturepage
For this you need to add every image you will need in a single file, save the coordinates, width and height of every image within the larger image and then you can draw them in game. SO you'll need two files, your image file with all the images in it and a text file with the coordinates and width/height information
 

RangerX

Member
@RangerX
no when you load a sprite during runtime it creates a whole new texturepage
True that. But why loading stuff at runtime? You should do that only if ABSOLUTELY necessary.
If all your graphic assets are in your project, you'll need to manage nothing and everything will be organised and ready for you to use, all indexed, all the parameters you need to manipulate those assets, etc. The only drawback, as I told you already, is the memory space it takes to have it all at the start. But then again, it shouldn't become an issue, its unnecessary optimisation for 99,9% of games that are produced with GMS and if you really need to push your game on some device that is having very very low memory, you can flush texture pages and have GameMaker redo them when need be, automatically.
 
S

Shadowblitz16

Guest
For this you need to add every image you will need in a single file, save the coordinates, width and height of every image within the larger image and then you can draw them in game. SO you'll need two files, your image file with all the images in it and a text file with the coordinates and width/height information
I want to make my engine dynamic so that the players can add new sprites/tiles to the game and add a animation config and scripts external.
I would like to make an editor that my game is based around and can test levels inside it
 

RangerX

Member
I want to make my engine dynamic so that the players can add new sprites/tiles to the game and add a animation config and scripts external.
I would like to make an editor that my game is based around and can test levels inside it
Now I see why you want to do all that!
 
E

eltantillo

Guest
I want to make my engine dynamic so that the players can add new sprites/tiles to the game and add a animation config and scripts external.
I would like to make an editor that my game is based around and can test levels inside it
Then you are doomed :p new texture pages will be created. You can, and this may sound a little crazy, load the new image, append it to a textures surface, save the surface to a file, in case the surface gets deleted by gamemaker, so you can load it again.
 
S

Shadowblitz16

Guest
@RangerX @eltantillo

so wait I can't save tiles to an array or list?
thats dumb it limits gamemaker alot

surfaces delete themselves,
there is no way of writing and reading image data
how am I supposed to get around this?

is there a way to do this with a extension or something?
I would like my game to be compatible with mac and linux so a dll wouldn't work
 
A

anomalous

Guest
so wait I can't save tiles to an array or list?thats dumb it limits gamemaker alot
Not sure what you mean by "save tiles to an array"...terminology again. Tiles are a subset of a background.
And backgrounds can be loaded externally, as well as sprites.
You save them as an image. You can of course save the tile position data (background, top, left) to an array, or any other data type structure.

surfaces delete themselves,there is no way of writing and reading image data
1. Surfaces don't typically arbitrarily do that, its usually specific things related to graphics that do it.
2. you can save surfaces

Do you mean again that you want to load external images and use them in GMS at runtime?
Yes you can do this, and you do not need an extension/DLL.

sprite_add();
background_add();
surface_save();
surface_save_part();

All there. All in the manual.
 
S

Shadowblitz16

Guest
Not sure what you mean by "save tiles to an array"...terminology again. Tiles are a subset of a background.
And backgrounds can be loaded externally, as well as sprites.
You save them as an image. You can of course save the tile position data (background, top, left) to an array, or any other data type structure.


1. Surfaces don't typically arbitrarily do that, its usually specific things related to graphics that do it.
2. you can save surfaces

Do you mean again that you want to load external images and use them in GMS at runtime?
Yes you can do this, and you do not need an extension/DLL.

sprite_add();
background_add();
surface_save();
surface_save_part();

All there. All in the manual.
I mean like save a piece of them in a array

1. what do you mean Surfaces don't do that?
2. maybe externally but not in a variable in raw data

yes but sprite_add / background_add create whole texture pages and I would have to do hacky scripting to fix it
 
E

eltantillo

Guest
so wait I can't save tiles to an array or list?
thats dumb it limits gamemaker alot
You can build your array or list with the information you need to extract the tiles from the surface as you please. There's no programing language that considers an array or list and image files data as a blended concept.

1. what do you mean Surfaces don't do that?
He said they typically don't arbitrary delete. Surfaces get deleted when certain events occur, like resolution change of screen, switch between fullscreen and windowed, and some others I dont recall at this moment.

2. maybe externally but not in a variable in raw data
GameMaker is a high level framework and you are talking about a very low level concept here. variables do point to raw data (buffers) in memory, wich you can save to files. So in case the "raw data" gets deleted from memory for any reason, you can recreate that "raw data" again by loading the saved surface file.

yes but sprite_add / background_add create whole texture pages and I would have to do hacky scripting to fix it
That's what we have in Studio right now, so you will have to go with hacky scripting for the moment if you really want to implement this functionality without the use of a dynamic link library.
 
Last edited by a moderator:
Top