Original Post
I know for those of you who already programs in VC++, this question will be really simple, maybe stupid. But I just wanna learn
1st Question...
I''m doing my final project for my VC++ class. The project is a Duck Hunt game. I''m using bitmaps for it (for the background and the ducks).
Does anyone know how to use the transparency for bitmaps?
I found 2 function: TransparentBlt and TransparentBitmap.
but MSDN sucks explaining it... does anyone could help me out?
Here the code that could be interesting for the 2 question:
__________________________________________________________
//Create Window
CDuckWin::CDuckWin()
{
Create (NULL, "Duck Hunt!", /*WS_OVERLAPPEDWINDOW*/NULL,
CRect(1, 1, 900, 580), NULL, "Duck" );
m_bmpBackground.LoadBitmap ("BACK_BMP");
m_bmpDuck1.LoadBitmap ("DUCK1_BMP");
CClientDC dc (this);
m_memDC.CreateCompatibleDC(&dc);
m_memDC1.CreateCompatibleDC(&dc);
m_memDC.SelectObject (&m_bmpBackground);
m_memDC1.SelectObject (&m_bmpDuck1);
x = 0;
y=90;
count=0;
Score = 0;
// TransparentBlt (NULL, x, 100, 117, 76, m_memDC1, 10, 10, 10, 10, RGB(0,0,0));
}
afx_msg void CDuckWin::OnPaint ()
{
CPaintDC dc (this);
CRect rect;
GetClientRect (▭);
dc.BitBlt (1, 1, 900, 580, &m_memDC, 0, 0, SRCCOPY);
dc.BitBlt (x, y, 117, 76, &m_memDC1, 0, 0, SRCCOPY);
}
afx_msg void CDuckWin::OnTimer()
{
if(x>870)
flag = 1;
else if (x<2)
flag = 2;
if(flag==2)
x += 2;
else if (flag ==1)
x -=2;
num = rand() %3;
if(num==1 && y <500)
y +=8;
else if(num==2 && y > 10)
y -=8;
InvalidateRect(NULL,FALSE);
}
__________________________________________________________
2nd Question...
I wanna make a SMOOTH path for the duck to fly. Right now, the path sucks. The duck is going everywhere in the screen and it''s always refreshing as hell (this doing an effect that isn''t too much professional)
I wanna make a cool smoothing path, does anyone could help me out for this one also?
Thanx a lot for your help!
X-Fe@R... is back!
------------------