Game Programming and Development Tools

Pixel Access – Mene-Mene

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
If you've looked at my vision thread you'll see I learned how to create a polygon using Sin and Cos. I was wonder how you could access each pixel within the polygon. I tried drawing a line between the points at the top and the point at the bottom. I was also wondering how to average the two colors.

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
Hello?

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

Lazarus

Member

Posts: 1668
From: USA
Registered: 06-06-2006
Hello!

I suppose you could create an array - where for every array1[x,y] - the x, y contained the coordinates of a pixel.

Averaging two colors? Take their RGB values(red is (255,0,0), green(0,255,0), and blue(0,0,255), and average all three values together, I suppose.

If that would work, it'd be like(for combining red and green).
(255,0,0)
(0,255,)

(128, 128, 0)

[This message has been edited by Lazarus (edited December 22, 2006).]

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
How would it store it?

Here is the code I wrote for it.


ex = 100
ey = 100
px = 100
py = 200
sightdistance = 100
FoV = 20
EnemyFacing = 270
FoVLeft = EnemyFacing - (FoV / 2)
FoVRight = EnemyFacing + (FoV / 2)

r = Sqr(Abs(ey-py)^2)+(Abs(ex-ey)^2)
theta = ATan2(py-ey,px-ex)
If theta > FoVRight And theta < FoVLeft And r < SightDistance Then
Print "I can see you!"
End If

FOVLeftX = Sightdistance * Cos(FoVLeft) + ex
FoVLeftY = Sightdistance * Sin(FoVLeft) + ey
FoVRightX = Sightdistance * Cos(FoVRight) + ex
FoVRightY = Sightdistance * Sin(FoVRight) + ey

Dim FoVX#(FoV)
Dim FoVY#(FoV)


cur = 1

For a = 1 To FoV

FoVX#(cur) = Sightdistance * Cos(FoVLeft + cur) + ex
cur = cur + 1

Next

cur = 1

For a = 1 To FoV

FoVY#(cur) = Sightdistance * Sin(FoVLeft + cur) + ey
cur = cur + 1

Next

Line ex,ey,FoVLeftX,FoVLeftY
Line ex,ey,FoVRightX,FoVRightY

cur = 2

Line FoVLeftX,FoVLeftY,FoVX(1),FoVY(1)

For a = 2 To FoV

Line FoVX(cur - 1),FoVY(cur - 1),FoVX(cur),FoVY(cur)
cur = cur + 1

Next

cur = 2

As for averaging wouldn't it be 255,255,0?

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto

ArchAngel

Member

Posts: 3450
From: SV, CA, USA
Registered: 01-29-2002
for what language?

for C#, the getPath() method probably would be the way to go. but... I doubt your using C#

------------------
Yes, I'm still better than you
Soterion Studios

Mene-Mene

Member

Posts: 1398
From: Fort Wayne, IN, USA
Registered: 10-23-2006
BB

------------------
MM out-
Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice.
"Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClinto