how to you blit bitmap in an array?

Started by
3 comments, last by mickey 22 years, 3 months ago
i want to blit a bitmap on a 3 by 3 tictactoe grid when the user presses the left mouse button,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Advertisement
hiya mickey :D
pls be more specific, I don''t think we quite understand what you really want

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
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
oh da cobra, forget about my last question that was quite silly,
here,

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?
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
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 | 9then when you press a number an X or an O appears on that placeif 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  

This topic is closed to new replies.

Advertisement