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


how to you blit bitmap in an array?

Recommended Posts

mickey    100
hey da_cobra, haha found me here eh!

Anway, sorry about that, what I want to do is, there's a picture of a 3 by 3 tic tac toe grid on the screen ie.,

| |

then, using the left mouse button, the user will select any area on this 3 by 3 grid to put his mark(say X), and the X mark must appear ONLY within the grid's available area. my program must not allow or must not accept if the input will be outside of the grid,

oh and Da_Cobra, i got this snippet from your code,
Blt(&dest, G.lpDDSBuffer, &src, DDBLT_WAIT, NULL) ;

does &dest and &src already contain a bitmap or something here?

I ask here coz am kinda shy asking you guys there in our forum hehe

Edited by - mickey on December 19, 2001 11:38:24 AM

Edited by - mickey on December 19, 2001 11:40:14 AM

Edited by - mickey on December 19, 2001 11:44:09 AM

Edited by - mickey on December 19, 2001 11:45:34 AM

Share this post

Link to post
Share on other sites
mickey    100
oh da cobra, forget about my last question that was quite silly,

void BlitArray()
for (i=0; i<10; i++)
for (j=0; j<20; j++)
switch (PlayField [j])
case 1: // blue cube
// make the current copy position for the source cube
SetRect(&src, 0, 0, 16, 16) ; // SetRect( &src, top, left, right, bottom );
// make the current paste position for the destination cube
SetRect(&dest, (PlayfieldX+(16*i)), (PlayfieldY+(16*j)),
(PlayfieldX+(16*i)+16), (PlayfieldY+(16*j)+16)) ;
// now just blit the source cube to the destination cube
G.lpDDSBack->Blt(&dest, G.lpDDSBuffer, &src, DDBLT_WAIT, NULL) ;
break ;

are you just coping the area(no content) of &src to &dest here?

Share this post

Link to post
Share on other sites
da_cobra    122
well its actually very easy :D

you have to use the following line to define the what you want to copy from your buffer surface

SetRect(&src, 96, 0, 112, 16) ; // (&src,top-left x&y, bottom-right x&y)

then define where you want to copy it to your back buffer

SetRect(&dest, 96, 0, 112, 16); // (&dest, top-left x&y, bottom-right x&y)

remark => both areas should be the same size else your image will be smaller/bigger (directx would stretch it so it fits into your destination rectangle)

for your blitting I would suggest first to have 9 nrs for your playfield like this :


1 | 2 | 3
4 | 5 | 6
7 | 8 | 9

then when you press a number an X or an O appears on that place
if that works then just modify your code so it also works with a mouse (but here I can''t help, I''ve never used a mouse before in my DirectX games)

hope I helped a bit

PS don''t be shy to ask on our forum first :D

Share this post

Link to post
Share on other sites