Jump to content

  • Log In with Google      Sign In   
  • Create Account

how to you blit bitmap in an array?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 mickey   Members   -  Reputation: 100

Like
Likes
Like

Posted 18 December 2001 - 09:46 PM

i want to blit a bitmap on a 3 by 3 tictactoe grid when the user presses the left mouse button,

Sponsor:

#2 da_cobra   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 December 2001 - 03:01 AM

hiya mickey :D
pls be more specific, I don''t think we quite understand what you really want



#3 mickey   Members   -  Reputation: 100

Like
Likes
Like

Posted 19 December 2001 - 04:35 AM

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

#4 mickey   Members   -  Reputation: 100

Like
Likes
Like

Posted 19 December 2001 - 04:56 AM

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?


#5 da_cobra   Members   -  Reputation: 122

Like
Likes
Like

Posted 19 December 2001 - 05:18 AM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS