graphics question

  • Thread starter Thread starter Snuyt
  • Start date Start date
S

Snuyt

Hello,

I want to make a cards game. The only problem is now to add the cards in
the form. I want to add bitmaps (that part is working), but also delete
those bitmaps (1 at a time) by clicking on it.

Anyone knows which component or classes to use for this ?



Now I use an imageList for the bitmaps:

ImageList1.Images.Add(New Bitmap("pics/113.bmp"))
ImageList1.Images.Add(New Bitmap("pics/213.bmp"))

and I can draw them with:
Dim g As Graphics = CreateGraphics()
g.DrawImage(ImageList1.Images(1), 50, 50)

Thus I am looking for a way to delete the image from g, and a way to add
an event to g (clicking, by which i can get the coordinates of the
mouse, to see which card is underneath)

Thanks,
Snuyt
 
* Snuyt said:
I want to make a cards game. The only problem is now to add the cards
in the form. I want to add bitmaps (that part is working), but also
delete those bitmaps (1 at a time) by clicking on it.


Anyone knows which component or classes to use for this ?

Now I use an imageList for the bitmaps:

ImageList1.Images.Add(New Bitmap("pics/113.bmp"))
ImageList1.Images.Add(New Bitmap("pics/213.bmp"))

Replace the "/" with "\".
and I can draw them with:
Dim g As Graphics = CreateGraphics()
g.DrawImage(ImageList1.Images(1), 50, 50)

Don't forget to call 'g.Dispose()' after you finish using the 'Graphics'
object.
Thus I am looking for a way to delete the image from g, and a way to
add an event to g (clicking, by which i can get the coordinates of the
mouse, to see which card is underneath)

You will have to handle the form's 'MouseDown' and/or 'MouseUp' event
and determine which card has been clicked. You can remove a card by
drawing a filled rectangle over the card.
 
Hi Snuyt,

I would use a flat style button for it.

If you want a sample to add and remove them dynamicly tell it.


Cor
 
Herfried said:
Replace the "/" with "\".

No need, the "/" also works (or if you have a reason to use "\", please
tell me)
Don't forget to call 'g.Dispose()' after you finish using the 'Graphics'
object.

Ok, I will, thx
You will have to handle the form's 'MouseDown' and/or 'MouseUp' event
and determine which card has been clicked.

Ok, thx

You can remove a card by
drawing a filled rectangle over the card.

Yes, at first I thought of that, but then there's the question of
overlapping cards, lets say A overlaps B. What if A is removed. The part
of B that was hidden by A must be redrawn. And you can extend this to
more overlaps, so redraw B is only a loose solution...


thx anyway,

Snuyt
 
Cor said:
Hi Snuyt,

I would use a flat style button for it.

If you want a sample to add and remove them dynamicly tell it.


Cor

That is probably a good solution... Thanks, I'll look for it.

Snuyt
 
Snuyt,

* Snuyt said:
No need, the "/" also works (or if you have a reason to use "\",
please tell me)

It's more Windows-like.

;-)
Yes, at first I thought of that, but then there's the question of
overlapping cards, lets say A overlaps B. What if A is removed. The
part of B that was hidden by A must be redrawn. And you can extend
this to more overlaps, so redraw B is only a loose solution...

Maybe it's easier to use PictureBoxes for the cards. This will make
dealing with the problem you mentioned easier, but the application will
consume more memory.
 
Back
Top