WasabiHeat
Member
This is more of a logic problem than a programming problem, but I've been putting together a block building/destruction system and wanted the block's sprites to dynamically change based on where blocks (of the same type) were around it, just like how the auto tiler determines tile sprites or how block sprites work in something like Spelunky.
Making code that can check all 8 spots around a given block (oWall) is easy but knowing which sprite for the block to use is the tricky part. I'd rather not use a bloated if statement / switch statement that just covers every possible combination of blocks, at least, if there's a better option available. I'm also curious as to how I would implement all of the different sprites for the block to use. as you can see in the gif I already have an autotile spritesheet working in the editor but for the block object I was thinking of having each block sprite as a frame for a single sprite resource, and the block will pick the specific image_index it needs to display. Are there any ideas for this or maybe some gamemaker functions I could delve into that would help me with this?
(at the moment my script to check the 8 spaces around a given oWall object just has 8 booleans, each representing 1 space, that turn from false to true if another oWall object is found. I was considering using a point_in_rectangle() function to count how many blocks were around the block running the code but I don't know if that will actually serve any purpose)
Making code that can check all 8 spots around a given block (oWall) is easy but knowing which sprite for the block to use is the tricky part. I'd rather not use a bloated if statement / switch statement that just covers every possible combination of blocks, at least, if there's a better option available. I'm also curious as to how I would implement all of the different sprites for the block to use. as you can see in the gif I already have an autotile spritesheet working in the editor but for the block object I was thinking of having each block sprite as a frame for a single sprite resource, and the block will pick the specific image_index it needs to display. Are there any ideas for this or maybe some gamemaker functions I could delve into that would help me with this?
(at the moment my script to check the 8 spaces around a given oWall object just has 8 booleans, each representing 1 space, that turn from false to true if another oWall object is found. I was considering using a point_in_rectangle() function to count how many blocks were around the block running the code but I don't know if that will actually serve any purpose)