Jump to content
  • Advertisement

Archived

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

Rickwi22

Making Parts of Graphics INvisible in VB 6.0

This topic is 5278 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

OK, I want to be able to have a picture of say a circle, but I have to store it in a sqquare image obviously. I want the sides to just show whatever else happens to be behind the ball. Here is how I have it set up. I am declaring StdPictures for the various images, and then using PaintPicture() to draw them like this: PaintPicture pic, 50, 50, 1000, 1000, , , , , (Some RasterOp code) Now what I want to know is if there is one of those opcodes that can do what I want, if say the part that I want to be invisible is white. If I cant do this using op codes, how can I?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I''d suggest at least using BitBlt for your graphics, which will allow you to use masks (masks allow you to specify transparency)

If you dont know howto use BitBlt from VB, I''d suggest you go through a quick toturial.. theres one here:

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=36053&lngWId=1

(hope that address fits all in one line, its sposed to)

Maybe even BitBlt is overkill.. but its fast enough for alot of simpler games, and has decent functionality for most VB games.

Once you learn BitBlt, google for a tutorial on using masks and bitblt in VB - which will give you transparency

This probably sounds like alot to learn, but actually, the bitblt tutorial I refered you to takes like 15 minutes tops to complete and its pretty easy to understand. A masking tutorial should be around the same timeframe to complete.

If you need more tutorials, I''d suggest checking out Lucky''s VB Gaming site at:

http://www.rookscape.com/vbgaming

Share this post


Link to post
Share on other sites
I spent a very long time searching the MSDN thing, and I actually messed around with MaskBlt, but even tho I got the program to compile and run, it didnt ever show anything on the screen. Thanks for the tutorials, Ill see if I can get it working now.

Share this post


Link to post
Share on other sites
Aha! Thanks a bunch for the tutorial, I finally have it working. Heres my current code, (Btw I didnt mess with BitBlt or MaskBlt yet, I just took the concepts for now.


Dim pic As New StdPicture
Dim mask As New StdPicture

Private Sub Form_Load()
Set pic = LoadPicture("triangle.bmp")
Set mask = LoadPicture("trianglemask.bmp")
End Sub

Private Sub Timer1_Timer()
PaintPicture mask, 50, 50, 1000, 1000, , , , , vbSrcAnd
PaintPicture pic, 50, 50, 1000, 1000, , , , , vbSrcPaint
End Sub

Share this post


Link to post
Share on other sites
Thanks Kazgaroth, last night I got my game working using BitBlt for all the graphics instead of PaintPicture, but I had a problem that I couldnt get the image to stretch with whatever X, y, Width, and Height coordinates I BitBlt it to. It just showed up on the screen in the same size I saved it as in Paint. I didnt have this problem before.

Share this post


Link to post
Share on other sites
If you want the displayed image to be a different size to the image in memory, you need to use StretchBlt in the Windows API.

It is declared as follows:
Private Declare Function StretchBlt Lib "gdi32" (byval hDCDestination as long, byval xDest as long, byval yDest as long, byval cxDest as long, byval cyDest as long, byval hDCSrc as long, byval xSrc as long, byval ySrc as long, byval cxSrc as long, byval cySrc as long, byval dwrop as long) as long

It''s used the same way as BitBlt, but with two extra parameters ''cxDest'' and ''cyDest'', which are the required width and height, respectively.
Pretty much the same as the PaintPicture method.

Hope this is useful.

Share this post


Link to post
Share on other sites
Thanks, I tried that and it works great now. Also I read something about MaskBlt, is that just used to be able to have transparency in just one function call as opposed to:

StretchBlt Form1.myBackBuffer, Cloc.x - CRadius, Cloc.y - CRadius, CRadius * 2, CRadius * 2, CircleMask, 0, 0, 50, 50, vbSrcAnd
StretchBlt Form1.myBackBuffer, Cloc.x - CRadius, Cloc.y - CRadius, CRadius * 2, CRadius * 2, CirclePic, 0, 0, 50, 50, vbSrcPaint


Because I would imagine they do the same thing.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!