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.

2D All the way! / Transparency with get image doesn't work

Author
Message
NA170425
User Deleted
Posted: 5th Oct 2006 01:51
Ok, when I load an image and make a transparent sprite from it, it works, but when I use get image and make a sprite out of the captured image, it doesn't turn transparent when I make a sprite.

Here's my code.



I have another question...
I've seen many image files that have several individual images in them against the pink background. Are we supposed to use get image to capture these images on-the-fly, or copy each one to it's own file and load them one by one?

Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 5th Oct 2006 04:07
Your forgetting that when you grab the image from the screen, the transparency color has already been discarted, thus you have black instead of pink, according to your code, and no transparency at all.

Quote: "I've seen many image files that have several individual images in them against the pink background. Are we supposed to use get image to capture these images on-the-fly, or copy each one to it's own file and load them one by one?"


I do that, however, i've done a little program that fits to my needs on that. I basically just got to put all images in a pattern, then the program would catch them by itself, then within it i can adjust eachs images offset, save it, and use that saved file in my game to know where each image is.

Further on my stuff at...
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 5th Oct 2006 11:05
With the latest updates you can now grab transparency. You will need to use the command SET BITMAP FORMAT 21 before any other bitmap commands and when you GET the image you will need to set the texture flage to 2.


Failing that I have written some code to get an image with transparency using memblocks. It's in the code snippets somewhere.


NA170425
User Deleted
Posted: 5th Oct 2006 23:40 Edited at: 5th Oct 2006 23:44
Quote: "Your forgetting that when you grab the image from the screen, the transparency color has already been discarted, thus you have black instead of pink, according to your code, and no transparency at all."


So, set image colorkey changes the pink color to transparent black? I'm a little confused, I had the paste sprite transparency flag set off, so how could the transparency have been discarded? It couldn't have gotten the black from the backdrop because transparency is off, so the pink must have changed to black somehow. This must be because of set image colorkey, does it change all the pink pixels to black and turn up the alpha?

I put set image colorkey right before get image so the pasted image would have the pink in it and get image could make it transparent, and it works now. Thank you.

[edit]
I tried to make a program like the one you said, but I had never done a program like that before and it was faster to just copy and save them manually.

NA170425
User Deleted
Posted: 6th Oct 2006 02:17
Ugh, now there's another problem. When I use sprite hit(x, 0) it always returns 0 and sometimes crashes the program. I searched and this is in the Bug Reports and it was supposed to be fixed in DBP 5.9 and I have 6.2, what's going on?



Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 6th Oct 2006 05:07
I ran your code, and had no problems at all...

Further on my stuff at...
NA170425
User Deleted
Posted: 6th Oct 2006 22:08
It doesn't crash anymore but the breakout tiles don't dissapear when the ball hits them, did that happen when you ran it?


When I use 0 for the second parameter of sprite hit, it always returns 0 even if the sprite in question is intersecting another sprite.



But, if I do it this way, it works.



Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 7th Oct 2006 00:52
Not sure about the sprite hit command, what i do know is that in order to make it look "ok", i had to add the command "cls" right in the beggining of the loop, that is like this:



The reason i had to do so, was due to the sprites left their trace.

Further on my stuff at...
NA170425
User Deleted
Posted: 7th Oct 2006 14:50
Were you using a 640*480 image for backdrop.bmp? I didn't need to use cls because the backdrop sprite is rendered before everything else. By the way, Pieces.bmp is from the Artist's Challenge thread. For me, the sprite hit command works for images loaded, but not image that were captured with get image.

Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 7th Oct 2006 18:27
Quote: "For me, the sprite hit command works for images loaded, but not image that were captured with get image."


The sprite hit works with sprites, and sprites alone, either their image was captured or loaded.

Oh, and i found out why is it that it doesn't work. Your background is a sprite, right?.... so "sprite hit(2, 0)" will always return 1 as its the backgroung sprite. Replace the background with a pasted image, like this...



It now works fine for me, just take a look at the attached pic.

Further on my stuff at...
NA170425
User Deleted
Posted: 8th Oct 2006 03:54
Ok, I get it. The sprite hit command seems returns the first to return the first colliding sprite it finds.

I already finished the breakout game this afternoon so I guess I'll keep it the way it is.

Thanks anyway, though.

Confucius Say...

Login to post a reply

Server time is: 2026-07-07 01:30:11
Your offset time is: 2026-07-07 01:30:11