Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

diablo2_v

Detecting Pixels

This topic is 5580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, Im designing a rts game with a few friends. Im using directdraw 7.0 to do this. I load all my graphics into sprites, and display them onto the screen. I plan on making the map/world just 1 large picture. Ill make a seperate 1 that is colour coded for different objects. eg. Water is gray, tree is red etc. What i dont know how to do is get the pixel colour of any given coordinate from the reference map picture from memory. I dont want to display it on the screen. FYI : Im using visual basic 6.0 Thanks [edited by - diablo2_v on February 9, 2003 8:21:24 PM]

Share this post


Link to post
Share on other sites
Advertisement
I tried something very similar to this a while ago in VB6. The way I got around it was to pre-load the collision map into a memory array. e.g.

Enum MapTile
0=Water
1=Lava
...
End Enum

Dim CArray(100,100) as MapTile

Picture1.picture=loadpicture("CollisionMap")

For g = 0 to 99
For H = 0 to 99
Carray(g,h) = picture1.point(g,h)
Next H
Next G

Works like a treat. You can speed it up a little by using the API GetPixel function. Also, the value returned by .Point is a double that contains the decimal values of R,G and B, so you''ll need to use something like Hex$ to get the seperate RGB values out.

Works perfectly though.

You can try to use direct memory interrogation on the collision map, but in VB this is dangerous and slow, so it''s much better to pre-cache it.

''Doing the impossible is kind of fun'' - Walt Disney

Share this post


Link to post
Share on other sites
Thanks, Ill give it a try. Hopefully it will work well.

I think thats going to be the next step in my game, whenever i get time to program

Share this post


Link to post
Share on other sites
I''ve run into another problem. If I preload the picture into a picture box, I need to get a certian pixel at an xcord and ycord of the screen.

In a picture box however, it doesn''t use the screen coordinates.

How can I get around this problem?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!