Jump to content
  • Advertisement

Archived

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

yochai_vb9

Some questions about VC++

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

Hi there! I was Game Programming Genesis article, and I've used GDI for some stuff, but now when I'm making my little game, I've encountered some questions. Can anyone help? 1) When i resize (Minimize, Maximize etc.) my window, my Background image is geting deleted or "cleaned up". How can I keep it in the background? Possible ways are to Redraw it every time I resize or is there something to help Redraw problems? 2) After I've loaded my background picture, I have another, smaller picture, which I want to be visible in certain time, maybe move around a little and then delete it from the screen. A. How can I delete the picture from the screen? B. How can I move the picture around but with no "trails"?(Again, Redraw problem.) 3) Back again to the smaller picture, I know there's a way with BitBlt to make the picture Masked - means using black/white picture and the oroginal one to show the necessary parts without the background color/whatever. How can I do that? 4) The last thingy =). How can I create a random int/long value? Thanks. [edited by - yochai_vb9 on April 13, 2004 4:43:40 PM]

Share this post


Link to post
Share on other sites
Advertisement
I've never really touched GDI so I can't answer questions 1-3. But for the random number... (assuming C++ [edit: now I see you're using VC++ ])

1. Initialize the random number generator at the start of your program:

#include <ctime>
#include <cstdlib>
...
srand (unsigned(time (NULL)));

2. To get a random integer in range [a,b]:

int rnd_ab = rand()%(b-a+1)+a;



[edited by - nonpop on April 14, 2004 8:52:18 AM]

[edited by - nonpop on April 14, 2004 9:04:04 AM]

Share this post


Link to post
Share on other sites
Haven''t looked a GDI in ages but I''ll have a go at answering your questions

1) When you do this windows has to repaint your window, when it does this you get the WM_PAINT message. So basically whenever you get the WM_PAINT message draw your background (as well as any other stuff you want in the window).

2) Use RedrawWindow and set the rectange to redraw around where the picture was before you moved it and where you want to move it to. When you get the WM_PAINT message you need to draw in the little bit of background where the picture was and draw the picture in its new position

3) WinProg had a tutorial on GDI that included masking, check that out

4) Take a look at the rand( ) function

As I said I haven''t looked at GDI in ages, so I may be wrong here.

Share this post


Link to post
Share on other sites
Thank you very very much. Though I''ve already found some solutions for my problems, some of the stuff here really helped me. Thanks.

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!