Game Development Community

Help: (TGB) how to get pixel's color?

by Jack Cicci · in General Discussion · 09/08/2008 (2:37 am) · 8 replies

Hi All

how to get pixel's color at position x,y in an image?

is possible?

thanks

#1
09/08/2008 (6:07 am)
This is not possible in script, although you could of course in C++. What is it you are trying to accomplish?
#2
09/09/2008 (12:19 am)
I need to move my player only on certain areas of an background image, areas defined by a specific color...
the background images must be interchangeable (only by images file replacement), so i cant use collision polygon to define areas where walk is permitted or not (each image --> a lot of collision polygon to define: impossible/not useful)

is possible to integrate C++ statements in a TGB project?


Thanks

(sorry for my poor english)
#3
09/09/2008 (12:43 am)
You get access to the (C++) source code with the pro license. With that you could possibly add a new ConsoleMethod like maybe, t2dStaticSprite::getPixel( %objectPos ).
#4
09/09/2008 (1:00 am)
Perhaps i explained not very well what i want to realize and what is my problem:

I need to move my player only on certain areas of an background image; the background image is interchangeable (by image file replacement); each background image is caracterized by areas where i want myplayer can walk on and others that are prohibited...

because of the large number of different images that i need to use, it is impossible to think of using collision polygon to define permitted/prohibited areas (a lot of polygon for a lot of images...). since each permitted area is characterized by same color, I thought to use this information to distinguish areas. So I would be able to define a single function capable of managing the movement on all different background image.
But, (here's the problem) how to get the color of pixel which is my player on?


is possible to integrate C++ (or visual basic) statements in a TGB project?
#5
09/09/2008 (1:01 am)
I've only indie license...
#6
09/09/2008 (1:10 am)
However, thank you very much
#7
09/09/2008 (12:44 pm)
I don't know of a way to do that with script only, other than building the collision polygons by hand in the editor. If there is another way, perhaps someone else can post here.
#8
09/15/2008 (5:35 am)
My teacher bought Pro license, so now i have source code...

I'll try to add that function...

Thanks