Color sampling per pixel from static sprite in a layer
by Bryant Schaper · in Torque Game Builder · 02/06/2012 (8:17 pm) · 1 replies
Is it possible to return such a value?
I was looking at the files of Europa Universalis, and noticed/assume that this is the method they use to know what county you click on. I have an idea for a strategy game, and the ability to layer a color map below the top layer map makes clicking on a territory very easy. Far simplier than collect a sprites into a map, and they having those clicked, or a irregular box in each territory.
User would just click on the map, and the script would return the RGB value of the bottom layer pixel or point, then a simple lookup table would tell what territory was clicked.
I know you have a performance hit, but on a turn based game this would not be a concern.
Any thoughts?
I was looking at the files of Europa Universalis, and noticed/assume that this is the method they use to know what county you click on. I have an idea for a strategy game, and the ability to layer a color map below the top layer map makes clicking on a territory very easy. Far simplier than collect a sprites into a map, and they having those clicked, or a irregular box in each territory.
User would just click on the map, and the script would return the RGB value of the bottom layer pixel or point, then a simple lookup table would tell what territory was clicked.
I know you have a performance hit, but on a turn based game this would not be a concern.
Any thoughts?
About the author
Simon Almqvist Pettersson
Dohi Sweden
Adding something like this to t2dImageMapDatablock.cc would be a start.
ColorI t2dImageMapDatablock::pickColor(U32 xPos, U32 yPos) { //xPos and yPos is the number of pixels from the top left corner of the image. ColorI pixelColor; if ( !mpSrcBitmap ){ loadSrcBitmap(); } mpSrcBitmap->getColor(xPos, yPos, pixelColor); return pixelColor; }And you would need a consoleMethod to that as well so you can call it from scripts.