detecting a section of a sprite
id: 750211
category: Help with Scripts
posts: 4
cs765885
loading
I'm working on a project where I have a large map, and I want to recognize and locate where certain patterns or sections within that map are.
Could I make a smaller sprite (like a cut out section) that resembles the part on the map that I want to locate, and then have it somehow detect its position within the map, essentially finding its location on the map? Maybe by moving the sprite around until it detects that the part of the map it is touching matches with itself perfectly? Or could I scan for a certain array of pixel colors that match the section I want to locate? How could I get this to work?
Could I make a smaller sprite (like a cut out section) that resembles the part on the map that I want to locate, and then have it somehow detect its position within the map, essentially finding its location on the map? Maybe by moving the sprite around until it detects that the part of the map it is touching matches with itself perfectly? Or could I scan for a certain array of pixel colors that match the section I want to locate? How could I get this to work?
Wolf_Link21
loading
when you make the sprite, it could remember the x and y coordinates it has on the map, but I'm not totally sure if this is what you wanted.
27xz
loading
Perhaps you could make the map in tiles, and the tile which you wish to detect could have a different ID using a “for this sprite only” variable? I would also use custom x and y variables to detect position.
MrKingofScratch
loading
Yeah, you're idea was on the right track. Make another sprite that has just the area you want to “detect” (and lines up with the map). Then, can use the
I hope this helps, and if you can't understand this (I'm terrible at explaining things, sorry) let me know.
set [ghost v] effect to (100)block to make it invisible, but you can still detect it with
<touching [sprite v] ?>If the map moves at all (like if it's scrolling) you can use
foreverThis does lag behind one frame, but it shouldn't matter if you're only using it for a map.
go to [Map v]
end
I hope this helps, and if you can't understand this (I'm terrible at explaining things, sorry) let me know.