vb graphics

D

:\\\\derian

What is the best way to flip a drawing.... I designed a chess game that can
be played over the network. I would like the board to be oriented according
to the player selection -- if player 1 is looking at the board, the white
pieces should start off at the bottom and if player 2 is viewing the board,
the black pieces should be on the bottom. I would like to accomplish this
while maintaining my current coordinate system for determining which square
was selected. Currently, when the user selects a square, a series of
calculations is performed that determines which square was selected... i
would like to preserve this while flipping the board!!

any help / suggestions / different ways of approaching the issue are are
much appreciated.

:\\derian
 
K

Ken Tucker [MVP]

Hi,

You can use the bitmap classes rotate flip method.

Dim bm As New Bitmap("C:\camera.bmp")

bm.RotateFlip(RotateFlipType.Rotate180FlipNone)

PictureBox2.Image = bm

Ken
 
F

Fergus Cooney

Hi Derian,

Your question has a sneaky little catch in it, I believe. ;-)

When you swap sides in chess (or stand over the other player's shoulder),
you <rotate> the board. This gives the same layout of squares, but, of course,
a different layout of the pieces.

You don't actually want to flip the board at all. You certainly don't want
to <draw> the board flipped!!

Black
o Q K x
x o x o
o x o P
x Q K o
White (Queen on Player's Lhs)
versus
White
o K Q x
P o x o
o x o x
x K Q o
Black (Queen on Player's Rhs)

Ok, let's talk about that solitary P on the board. To White, it's at X=4,
Y=2. To Black it's at X=1, Y=3. These are not the same <screen> square but
they <are> the same <game> square. In other words, you <must> have a mapping
from a player-centric screen square to your game board. [And, of course, vice
versa so that you draw the pieces in the correct places.]

One of your players is going to be 'lucky' in that their mapping is
one-to-one. The other player will need this 'flip' of yours. Let's have White
stay and Black be flipped.

White {X, Y} = Board {X, Y}
Black {X, Y} = Board {NS - X + 1, NS - Y + 1}

NS is the number of squares on each side (4 in my example)
So: White {4, 2} => Board {4, 2} => Black {4 - 4 + 1, 4 - 2 + 1} = Black
{1, 3}

[Of course, the game Board might be 0-based while for the Players it will
be 1-based so you'd have to have that adjustment in when you display any
co-ordinates.]

That covers what I understand the question to be. If there's more, come on
down! ;-)

Regards,
Fergus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top