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.

DarkBASIC Professional Discussion / Sprite And Bitmap Transparency Issues

Author
Message
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 19th Nov 2010 05:59
Yep it's another forum by me So i have created some png images, which are supposed to support transparency, and i have added transparency to them. i am trying to make a tic tac toe game and when i put the image over the background, the transparent areas show up as white.
Here's a snippet:

dont mind all the integers defined

check my youtube channel at http://www.youtube.com/user/freeflightsimulator

Attachments

Login to view attachments
Brk_oth
19
Years of Service
User Offline
Joined: 8th Aug 2005
Location: Australia
Posted: 19th Nov 2010 07:49 Edited at: 19th Nov 2010 07:53
My first guess would be that you are loading a png and then creating bitmap images out of it.
Bitmaps do not support the alpha channel.

Also are you going to be doing your game in a 2D environment (using sprites) or a 3D environment (using planes) ???

No signature found...
Virtual Nomad
Moderator
19
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 19th Nov 2010 09:38 Edited at: 19th Nov 2010 09:45
you can load images directly using load image "FileName.png",ImgNumber ,1 (don't confuse bitmaps for images here. there's no need for all that bitmap stuff in your code). that last part ",1" will retain pixel perfect quality.

similarly, when you paste the images:

paste image ImgNum ,X ,Y ,1

the ",1" flag will set the transparency on for the image.

further, your .png file is using black as the "transparent color", which is less-than ideal as the true transparency support for .png files lies in the fact that no color is necessary to make it transparent. see the attached version of your image with the black removed:



i recommend you use .png files in this manner for any images you might use here. also, spend a little time hitting F1 and read the help files for the commands you're using. it will save you some grief.

good luck!

by the way, as you can see, your title for this issue is incorrect as neither sprites nor bitmaps are necessary. images are. terms you might have been familiar with before starting with dbpro may mean something a little different here so, really, go through the help files and learn the terms, usages, etc.

Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit

Attachments

Login to view attachments
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 19th Nov 2010 23:17
Well, ive been trying to use bitmpaps because i have been having issues with sprite size, and the people said to use that code sequence to get things to the correct size.

check my youtube channel at http://www.youtube.com/user/freeflightsimulator
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 19th Nov 2010 23:21
my bad IMAGES! Lol, i cant find any way to resize an image...

check my youtube channel at http://www.youtube.com/user/freeflightsimulator
Brk_oth
19
Years of Service
User Offline
Joined: 8th Aug 2005
Location: Australia
Posted: 19th Nov 2010 23:33
Save your images the correct size when you make them, then there is no need to resize them in your program.

otherwise, resizing a sprite that uses an image can be done with any of these commands:
SCALE SPRITE
SIZE SPRITE
STRETCH SPRITE

No signature found...
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 20th Nov 2010 00:01
the thing is when i make an image the correct size, the program scales it up or down and always keeps it a certain size in relation to the window. Also, when i make a sprite, the sprite that i put over it doesnt appear. if someone could provide some code that scales a background to the size of the window, the puts an image over that is transparent, that would be totally awesome.

the transparency works in this program, but i cant get the sizes correct.

check my youtube channel at http://www.youtube.com/user/freeflightsimulator
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Nov 2010 10:56 Edited at: 20th Nov 2010 11:33
Instead of using the SET WINDOW SIZE command change the IDEs resolution to a custom resolution instead of the default screen sizes. Do that and you'll get better control of how your screen looks. You can also prevent people from changing the window size by using the SET WINDOW LAYOUT command.

This uses Sven Bs Image Kit to resize the image (because it's faster ):


See the attachment for the results of using a custom resolution. I circled the place where BlueIDE shows the resolution. Every IDE should allow custom resolutions but if not you can edit the .dbpro file in notepad to change your projects resolution (look for "window resolution=").

The circle in the program window appears to have an empty space at the top and bottom because the original image has three lines of nothing at the top and one line of nothing at the bottom.

Oh yeah and this:


... should be in an array instead:


If you want the upper left use Grid(0,0), the middle of the grid is Grid(1,1), and the lower right is Grid(2,2).

You can learn the basics of arrays if you check out TDKs Tutorials (part one has arrays):

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Attachments

Login to view attachments
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 20th Nov 2010 17:42
Thanks! Here we go again--arrayslol!

check my youtube channel at http://www.youtube.com/user/freeflightsimulator

Login to post a reply

Server time is: 2025-05-17 19:12:01
Your offset time is: 2025-05-17 19:12:01