473,569 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

graphic window checker board game......

i got board working using graphic window in vb.net but no controls
adding to form. i am doing checker board game. when i clicked and moved
the peg to another location(grid). but how do i get bitmap or image to
make invisible.

here is code for mouseevent:

Protected Overrides Sub OnMouseDown(ByV al e As
System.Windows. Forms.MouseEven tArgs)
Me.PegPicking = True
If Me.PegPicking = True Then
g.SmoothingMode = Drawing2D.Smoot hingMode.AntiAl ias
DrawingUtility. DrawPeg(g, New Rectangle(Me.mP osition.X
- 15, Me.mPosition.Y - 15, 30, 30), Me.PelleteColor s(0))
g.SmoothingMode = Drawing2D.Smoot hingMode.HighSp eed

End If
' Invalidate()
End Sub

Protected Overrides Sub OnMouseMove(ByV al e As
System.Windows. Forms.MouseEven tArgs)
' change Position to current mouse Position
Me.mPosition = New Point(e.X, e.Y)
' Repaint to Show Effect
Invalidate()
' End If
End Sub

Protected Overrides Sub OnMouseUp(ByVal e As
System.Windows. Forms.MouseEven tArgs)
Me.PegPicking = True
'Inserting Pegs but only is Game is Active
Invalidate()
End Sub

how do i make bitmap or image invisible or something like disappearing?

Nov 20 '05 #1
6 2821
I dont really know how you have written this. But one approach might be to
repaint a sqare either with or without the peg, depending on the underlying
matrix properties ( assuming you have coded it like this. )

Regards - OHM


"Supra" <su*******@roge rs.com> wrote in message
news:Kd******** ****@news04.blo or.is.net.cable .rogers.com...
i got board working using graphic window in vb.net but no controls
adding to form. i am doing checker board game. when i clicked and moved
the peg to another location(grid). but how do i get bitmap or image to
make invisible.

here is code for mouseevent:

Protected Overrides Sub OnMouseDown(ByV al e As
System.Windows. Forms.MouseEven tArgs)
Me.PegPicking = True
If Me.PegPicking = True Then
g.SmoothingMode = Drawing2D.Smoot hingMode.AntiAl ias
DrawingUtility. DrawPeg(g, New Rectangle(Me.mP osition.X
- 15, Me.mPosition.Y - 15, 30, 30), Me.PelleteColor s(0))
g.SmoothingMode = Drawing2D.Smoot hingMode.HighSp eed

End If
' Invalidate()
End Sub

Protected Overrides Sub OnMouseMove(ByV al e As
System.Windows. Forms.MouseEven tArgs)
' change Position to current mouse Position
Me.mPosition = New Point(e.X, e.Y)
' Repaint to Show Effect
Invalidate()
' End If
End Sub

Protected Overrides Sub OnMouseUp(ByVal e As
System.Windows. Forms.MouseEven tArgs)
Me.PegPicking = True
'Inserting Pegs but only is Game is Active
Invalidate()
End Sub

how do i make bitmap or image invisible or something like disappearing?

Nov 20 '05 #2
can u see my pic? on right side i clicked peg and moved another location
(grid), but b4 i moved peg another location. the peg isn't invisible. i
am using gdi graphic using image. there are no control on form.
ne ideas u can give me an hint?
regards,
supra

One Handed Man ( OHM#) wrote:
I dont really know how you have written this. But one approach might be to
repaint a sqare either with or without the peg, depending on the underlying
matrix properties ( assuming you have coded it like this. )

Regards - OHM


"Supra" <su*******@roge rs.com> wrote in message
news:Kd******** ****@news04.blo or.is.net.cable .rogers.com...
i got board working using graphic window in vb.net but no controls
adding to form. i am doing checker board game. when i clicked and moved
the peg to another location(grid). but how do i get bitmap or image to
make invisible.

here is code for mouseevent:

Protected Overrides Sub OnMouseDown(ByV al e As
System.Window s.Forms.MouseEv entArgs)
Me.PegPicking = True
If Me.PegPicking = True Then
g.SmoothingMode = Drawing2D.Smoot hingMode.AntiAl ias
DrawingUtility. DrawPeg(g, New Rectangle(Me.mP osition.X
- 15, Me.mPosition.Y - 15, 30, 30), Me.PelleteColor s(0))
g.SmoothingMode = Drawing2D.Smoot hingMode.HighSp eed

End If
' Invalidate()
End Sub

Protected Overrides Sub OnMouseMove(ByV al e As
System.Window s.Forms.MouseEv entArgs)
' change Position to current mouse Position
Me.mPosition = New Point(e.X, e.Y)
' Repaint to Show Effect
Invalidate()
' End If
End Sub

Protected Overrides Sub OnMouseUp(ByVal e As
System.Window s.Forms.MouseEv entArgs)
Me.PegPicking = True
'Inserting Pegs but only is Game is Active
Invalidate()
End Sub

how do i make bitmap or image invisible or something like disappearing?



Nov 20 '05 #3
Theres no picture attached, but if there were it would not help.
Store the position of pegs in a class level variable.
Do ALL your drawing in the forms Paint method.
In your mouse events, update the position of the current peg and Invalidate
the form, preferably passing a rectangle to the Invalidate call so that only
the relevant part of the form gets painted.

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi1...nate/home.html
"Supra" <su*******@roge rs.com> wrote in message
news:iX******** ***********@twi ster01.bloor.is .net.cable.roge rs.com...
can u see my pic? on right side i clicked peg and moved another location
(grid), but b4 i moved peg another location. the peg isn't invisible. i
am using gdi graphic using image. there are no control on form.
ne ideas u can give me an hint?
regards,
supra

One Handed Man ( OHM#) wrote:
I dont really know how you have written this. But one approach might be to repaint a sqare either with or without the peg, depending on the underlying matrix properties ( assuming you have coded it like this. )

Regards - OHM


"Supra" <su*******@roge rs.com> wrote in message
news:Kd******** ****@news04.blo or.is.net.cable .rogers.com...
i got board working using graphic window in vb.net but no controls
adding to form. i am doing checker board game. when i clicked and moved
the peg to another location(grid). but how do i get bitmap or image to
make invisible.

here is code for mouseevent:

Protected Overrides Sub OnMouseDown(ByV al e As
System.Window s.Forms.MouseEv entArgs)
Me.PegPicking = True
If Me.PegPicking = True Then
g.SmoothingMode = Drawing2D.Smoot hingMode.AntiAl ias
DrawingUtility. DrawPeg(g, New Rectangle(Me.mP osition.X
- 15, Me.mPosition.Y - 15, 30, 30), Me.PelleteColor s(0))
g.SmoothingMode = Drawing2D.Smoot hingMode.HighSp eed

End If
' Invalidate()
End Sub

Protected Overrides Sub OnMouseMove(ByV al e As
System.Window s.Forms.MouseEv entArgs)
' change Position to current mouse Position
Me.mPosition = New Point(e.X, e.Y)
' Repaint to Show Effect
Invalidate()
' End If
End Sub

Protected Overrides Sub OnMouseUp(ByVal e As
System.Window s.Forms.MouseEv entArgs)
Me.PegPicking = True
'Inserting Pegs but only is Game is Active
Invalidate()
End Sub

how do i make bitmap or image invisible or something like disappearing?


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Nov 20 '05 #4

here is code for red peg image:
Private Function CreateRedImageS quares() As Image
Dim img As Image
img = New Bitmap(60, 60) 'create square 60 * 60
Dim g As Graphics = Graphics.FromIm age(img)
g.Clear(Me.Back Color)
g.SmoothingMode = Drawing2D.Smoot hingMode.AntiAl ias
rb = New Rectangle(1, 1, 150, 150)
Dim sb As New SolidBrush(Colo r.Red)
g.FillRectangle (sb, rb)
Return img
End Function

Private Sub drawDraughts()
' Create Offscreen Bitmap with width and height equal to
that of Form
OffScreenBitmap = New Bitmap(Me.Width , Me.Height)
g = Graphics.FromIm age(OffScreenBi tmap)
RedImageSquares = Me.CreateRedIma geSquares
BlackImageSquar e = Me.CreateBlackI mageSquares
PegImages = CreatePegImages (2)
End Sub

the pb is if u clicked peg(mousedown) i wanted that image disappearred
and place another location. but i have red peg on new location.... that
fine, but can't deleteed previously.
another ideas.....if i clicked red peg, get the black colour and paint
over red peg image to make invisible....is that good ideas. but how do i
changed to blk colour?
ne hint u can give me?
regards

Mick Doherty wrote:
Theres no picture attached, but if there were it would not help.
Store the position of pegs in a class level variable.
Do ALL your drawing in the forms Paint method.
In your mouse events, update the position of the current peg and Invalidate
the form, preferably passing a rectangle to the Invalidate call so that only
the relevant part of the form gets painted.


Nov 20 '05 #5

"Supra" <su*******@roge rs.com> wrote
the pb is if u clicked peg(mousedown) i wanted that image disappearred
and place another location. but i have red peg on new location.... that
fine, but can't deleteed previously.
another ideas.....if i clicked red peg, get the black colour and paint
over red peg image to make invisible....is that good ideas. but how do i
changed to blk colour?
ne hint u can give me?
regards

Normally I add a Picturebox to the form for drawing, but here, for
demonstration, I just used the BackGroundImage of the form.

Start a new project and paste the code below AFTER the
'Windows Form designer generated code' section. Run the
program and click on the checkerboard to see the yellow
marker mark the square. Of course, instead of a yellow
marker, you could be drawing actual game pieces, or
whatever. Do note that I only create 1 bitmap for the
entire time the form is loaded.

HTH
LFS
Private Const SS As Integer = 40 ' Square Size
Private Board As Bitmap = New Bitmap(360, 360)
Private Color1 As Color = Color.Tomato
Private Color2 As Color = Color.Black
Private Mouse As Point
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim x, y As Integer
' Create checkerboard
Graphics.FromIm age(Board).Clea r(Color.White)
For y = 0 To 7
For x = 0 To 7
DrawSquare(x, y)
Next
Next
Me.BackgroundIm age = Board
End Sub

Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
Dim X As Integer = e.X \ SS
Dim Y As Integer = e.Y \ SS
If X < 8 And Y < 8 Then 'Limit to within board
DrawSquare(Mous e) ' Draw old position
Mouse = New Point(X, Y)
DrawSquare(Mous e, Color.Yellow) ' Draw new pos.
Me.Invalidate()
End If
End Sub

Private Sub DrawSquare(ByVa l Mouse As Point)
DrawSquare(Mous e.X, Mouse.Y)
End Sub

Private Sub DrawSquare(ByVa l Mouse As Point, ByVal Kolor As Color)
DrawSquare(Mous e.X, Mouse.Y, Kolor)
End Sub

Private Sub DrawSquare(ByVa l X As Integer, ByVal Y As Integer)
' Default red/black colors
If (Y And 1) = (X And 1) Then
DrawSquare(X, Y, Color1)
Else
DrawSquare(X, Y, Color2)
End If
End Sub

Private Sub DrawSquare(ByVa l X As Integer, ByVal Y As Integer, ByVal Kolor As Color)
' Draws a single square
Dim gr As Graphics = Graphics.FromIm age(Board)
Dim br As Brush = New SolidBrush(Kolo r)
Dim rct As Rectangle = New Rectangle(X * SS, Y * SS, SS, SS)
gr.FillRectangl e(br, rct)
gr.DrawRectangl e(Pens.Black, rct)
br.Dispose()
gr.Dispose()
End Sub
Nov 20 '05 #6
thank! i c u have drawsquare overloaded.
regards,

Larry Serflaten wrote:
"Supra" <su*******@roge rs.com> wrote

the pb is if u clicked peg(mousedown) i wanted that image disappearred
and place another location. but i have red peg on new location.... that
fine, but can't deleteed previously.
another ideas.....if i clicked red peg, get the black colour and paint
over red peg image to make invisible....is that good ideas. but how do i
changed to blk colour?
ne hint u can give me?
regards


Normally I add a Picturebox to the form for drawing, but here, for
demonstration, I just used the BackGroundImage of the form.

Start a new project and paste the code below AFTER the
'Windows Form designer generated code' section. Run the
program and click on the checkerboard to see the yellow
marker mark the square. Of course, instead of a yellow
marker, you could be drawing actual game pieces, or
whatever. Do note that I only create 1 bitmap for the
entire time the form is loaded.

HTH
LFS
Private Const SS As Integer = 40 ' Square Size
Private Board As Bitmap = New Bitmap(360, 360)
Private Color1 As Color = Color.Tomato
Private Color2 As Color = Color.Black
Private Mouse As Point
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim x, y As Integer
' Create checkerboard
Graphics.FromIm age(Board).Clea r(Color.White)
For y = 0 To 7
For x = 0 To 7
DrawSquare(x, y)
Next
Next
Me.BackgroundIm age = Board
End Sub

Private Sub Form1_MouseDown (ByVal sender As Object, ByVal e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
Dim X As Integer = e.X \ SS
Dim Y As Integer = e.Y \ SS
If X < 8 And Y < 8 Then 'Limit to within board
DrawSquare(Mous e) ' Draw old position
Mouse = New Point(X, Y)
DrawSquare(Mous e, Color.Yellow) ' Draw new pos.
Me.Invalidate()
End If
End Sub

Private Sub DrawSquare(ByVa l Mouse As Point)
DrawSquare(Mous e.X, Mouse.Y)
End Sub

Private Sub DrawSquare(ByVa l Mouse As Point, ByVal Kolor As Color)
DrawSquare(Mous e.X, Mouse.Y, Kolor)
End Sub

Private Sub DrawSquare(ByVa l X As Integer, ByVal Y As Integer)
' Default red/black colors
If (Y And 1) = (X And 1) Then
DrawSquare(X, Y, Color1)
Else
DrawSquare(X, Y, Color2)
End If
End Sub

Private Sub DrawSquare(ByVa l X As Integer, ByVal Y As Integer, ByVal Kolor As Color)
' Draws a single square
Dim gr As Graphics = Graphics.FromIm age(Board)
Dim br As Brush = New SolidBrush(Kolo r)
Dim rct As Rectangle = New Rectangle(X * SS, Y * SS, SS, SS)
gr.FillRectangl e(br, rct)
gr.DrawRectangl e(Pens.Black, rct)
br.Dispose()
gr.Dispose()
End Sub


Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3547
by: Maarten | last post by:
Does anyone can help with this? For our goose game, we have to create the game board in a spiral. It may be a square instead of an oval or circle. Does anyone know a simple formula to do this with a variable amount of fields? I already created a table of fields (every field is an object of the type JLabel). Tnx in advance!
0
1969
by: Supra | last post by:
i got board working using graphic window in vb.net but no controls adding to form. i am doing checker board game. when i clicked and moved the peg to another location(grid). but how do i get bitmap or image to make invisible. here is code for moveevent: Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)...
0
1986
by: Supra | last post by:
i got board working using graphic window in vb.net but no controls adding to form. i am doing checker board game. when i clicked and moved the peg to another location(grid). but how do i get bitmap or image to make invisible. here is code for mouseevent: Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)...
2
2111
by: tshad | last post by:
I have an aspx window that is going to open a window (javascript) and display a graphic. I want to resize the window to the size of the graphic before it actually displays - how do I do that? In my calling routine I have the following: *********************************** function OpenLogoPreviewWindow() {...
10
12541
by: sam_cit | last post by:
Hi Everyone, I'm working on developing a chess game and i decided to use c++ for its object oriented approach. I have a bass class unit and is inherited to distinct number of units (like king, queen, pawns etc...), i will have pure virtual functions in the base class for move(), attack() etc which are applicable to all units and would...
4
20671
by: Hypnotik | last post by:
So I'm writing this program. I have the board constructed, and I'm having a problem making a move. At this point I just want to make a move, I'll work on whether it is a legal move after that. The code is posted below. I have a class for board, and the pieces are part of the board class. I also have a class for human move and computer move,...
1
1899
by: enp | last post by:
Hello, I am trying to create a board game in C#. I have looked into several different websites for creating a board for my game but I am unsuccessful. can somebody help me with their suggestion abt how can I go abt creating a board. I was thinking of using a gridlayout but I guess I am having issues with the display. Can anyone suggest if it is...
1
1326
by: nt5515 | last post by:
hey Im trying to make a game of pairs (the memory game) i have set up a grid which displays a graphic for the card back. im trying to link the edit menu to choose the graphic to be displayed. i've set up a string variable called deck which will contain the path to the required image. and actionlisteners DA and DB corresponding to which style is...
9
6256
by: ARC | last post by:
Hello all, I developed a tool a year or so ago for adding your own spell-checker to an access application. This is mainly for those using the runtime, as you can't distribute the spell-checker ability. After many complaints from my runtime customers, I decided to develop my own, which was a good challenge. I just wanted to give something...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6281
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.