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 / 2d transparency!!!!!

Author
Message
10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 25th Sep 2009 16:44
ok i am trying to make a 2d space shoot em up game and the 1 problem that i keep on having is that i cannot set the background of my space ship image "space.bmp" to be tranparent, the colour surrounding its is light purple (255,0,255) so idon't know why it dosen't work, here is the code and attatched is a pic of my game in the making

Attachments

Login to view attachments
bloodmage2
15
Years of Service
User Offline
Joined: 14th Jun 2009
Location:
Posted: 25th Sep 2009 23:16 Edited at: 25th Sep 2009 23:25
dbSetSpriteAlpha(g, 100 /*0 is nothing, 255 is opaque*/);

i think that is what you are trying to accomplish. you want the space.bmp to be see-through, right?

edit: oh wait, i see what you were trying to say, well, what program did you use, if not paint, then you might want to check what color every pixel is, because i doubt it would be exaclty 0xff00ff

-to the optimist, the glass is half full. to the pessimist, it is half empty, to the engineer, it is twice as big as it needs to be.
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 26th Sep 2009 01:24
May I just ask, why use a background picture when you can have the stars scroll in the background?
10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 26th Sep 2009 02:52
ok bloodimage, i checked and every pixel surrounding the space.bmp is definetly (i checked using paint shop pro) and puppy of kosh the reason i don't have the stars scrolling in the background is because i'm a almost a complete noveice so..... could you kindly explain how i could have the star scrolls in the background?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Sep 2009 05:09
I think you need to tell GDK what colour you are using as transparent so it can alpha mask the correct one, I cant remember what it defaults to, but I do remember having to tell it to use a different mask when I was using something similar to that pink as a transparent color when I was doing something similar.

dbSetImageColorKey() is the command I think to do that.

If it ain't broke.... DONT FIX IT !!!
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 26th Sep 2009 08:38
Why dont you just edit this pic on photoshop or anything else and make it alpha channeled, and save it as .tga, if you dont have any program that can make alpha channeled image, send me the image and ill make it for you.

10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 26th Sep 2009 09:04
thanks hassan ill try it oh yeah mr wilson i did use dbSetImageColorKey() it is in my code snippet (it, for some reason did not work).
10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 26th Sep 2009 12:44
it worked lol here is a new picture of game (with different background lol thnx alot but tere is another problem i have, you (the player) can move the picture of the ship off the screen so.. could any one tell me how to put like a barrier or something around the edges of the screen so the ship can't move off,the edge of the screen????

Attachments

Login to view attachments
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 26th Sep 2009 16:06 Edited at: 26th Sep 2009 16:07
Do you want the player to be limited to that area? Like the game asteroids, for example. Or do you want the "camera" to "follow" the ship?

As for preventing the player from moving off the screen, put something like




That'll make it so if you go off the side of the screen, you'll come back on the other side.
bloodmage2
15
Years of Service
User Offline
Joined: 14th Jun 2009
Location:
Posted: 26th Sep 2009 16:08
thats an easy one.

if your wondering why the width/2 is there, its so that the ship does not appear to move offscreen, as in, when one side hit the boundary, it stops rather than when the center hit the boundary

-to the optimist, the glass is half full. to the pessimist, it is half empty, to the engineer, it is twice as big as it needs to be.
10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 26th Sep 2009 16:11
thanks alot, both of you i'll try both ideas and see which one works best
10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 26th Sep 2009 16:22
um bloodimage assumaing that the sprite is set to an index of g (as in int g=2) so basically two how do i write it, i tried but i kept getting error messages
10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 26th Sep 2009 17:22
ok don't worry bloodimage i used puppy of kosh's method and i also loaded in a new picture for my ship (looks way better) and the asteroids that appear randomly that dark gdk loads when you first click on Make new Dark gdk 2d game. my question is (sorry about all of this) how do i make it so that the asteroids and the ship blow up when they collide here is my code

attatched is yet another picture

Attachments

Login to view attachments
10521
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 27th Sep 2009 16:39
um yeah bloodmage2 i bin calling u bloodimage for all this time sry don't know y

Login to post a reply

Server time is: 2024-11-25 00:41:16
Your offset time is: 2024-11-25 00:41:16