Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Need some help with checking the color of a specific point of a sprite.

Author
Message
ErDa
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location:
Posted: 2nd Apr 2008 17:35
Well the title explains it all, really. I need to have my character unable to move if he's walking over a specific point of my sprite that is red, (255,0,0). dbRGBR does not work because it is a sprite i think.
nodapro
16
Years of Service
User Offline
Joined: 14th Mar 2008
Location:
Posted: 3rd Apr 2008 23:18
I need to tell I don't know the answer. The following method might be a workaround, but I didn't try it myself.

1. Use dbSpriteImage to get the corresponding image (shouldn't be deleted yet).
2. Make a memblock from the image (see jason's post in another thread) or paste it to a bitmap.
3. Get the color code at (X,Y) of the image. For example, use dbPoint for the bitmap (or pointer to memblock). Then dbRGBR get the Red etc.
4. Note: (dbSpriteX + X, dbSpriteY + Y) may be the actual point you want to check, so you should get (X,Y) first before Step 3.

As I said, this may not work. You have to test it. And it may have an impact on speed because of the extra operations.
ErDa
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location:
Posted: 5th Apr 2008 20:19
Thanks for the input, made me think a little, and i got this here put together:



And it outputs the correct amount of red-ness at that point (255). Now the next challenge will be how i should go about moving this bitmap. Because as far as i know you can't move a bitmap.
ErDa
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location:
Posted: 5th Apr 2008 20:42
Would it be possible to:

- Display full-screen sprite.
- Capture image of screen to bitmap.
- Delete sprite.
- Display bitmap.

If anyone could take the time to write a sample code to do this, or explain which commands to use for this, I should be able to figure out the rest myself. Any help would be much appreciated.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 6th Apr 2008 09:35
Don't have time to run this through but basically just

dbSetCurrentBitmap (1); // or whatever
dbPasteSprite(1, 0, 0); // paste sprite 1 to bitmap in upper-left corner

But if the sprite is based on a full screen image then you just need to paste the image (dbPasteImage) rather than dealing with the sprite. The primary difference is that sprites can be rotated, flipped, mirrored, diffused, etc. whereas images can't.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
ErDa
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location:
Posted: 6th Apr 2008 12:25
Thanks, this was exactly what I was looking for.

Login to post a reply

Server time is: 2024-11-20 07:34:41
Your offset time is: 2024-11-20 07:34:41