473,320 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

LUDo gams in gdi.......

in ludo game i got 4 images on board. if i clicked first image then i
wanted first images be delete or invisible or whatever and place another
location and so on. how do i delete first images?..... u may copy and
paste it.

Private OffScreenBitmap As Bitmap
Private g As Graphics
Private rb As Rectangle
Dim Startpoint As Point = New Point(5, 10)
'Defines position and size each element of board
Dim Boxes(,) As Rectangle = New Rectangle(11, 4) {}
' defines Position and size of each Pegs available.
Dim ColorPellete() As Rectangle
'selected any colours
Private PelleteColors As Color() = New Color() {Color.Purple,
Color.Blue, Color.Green, Color.Red}
'Images for boxex images
Private PegImages() As Image

Dim BoxWidth As Integer = 24
Dim Border As Integer = 5
Private i, j, x As Integer

Private Sub CreateOffSetScreenImage()
g.Clear(Me.BackColor)
Dim pn As New Pen(Color.Blue, 5)
For i = 0 To PelleteColors.Length - 1
g.DrawImage(Me.PegImages(i), ColorPellete(i).X + 65,
ColorPellete(i).Y + 105)
Next i
End Sub

Protected Overrides Sub OnPaintBackground(ByVal pevent As
System.Windows.Forms.PaintEventArgs)
'do nothing. this will stop flicking due do background Drawing.
End Sub

Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
'if User is Draging peg no need to reDraw Image
If PegPicking = False Then
CreateOffSetScreenImage()
End If

'Get Graphics Object from EventArgs.Graphics
Dim gf As Graphics = e.Graphics
'Draw OffScreen Image to Screen
gf.DrawImage(Me.OffScreenBitmap, 0, 0, New Rectangle(0, 0,
Me.Width, Me.Height), GraphicsUnit.Pixel)

End Sub

Private Sub drawLudo()
' Create Offscreen Bitmap with width and height equal to
that of Form
OffScreenBitmap = New Bitmap(Me.Width, Me.Height)
g = Graphics.FromImage(OffScreenBitmap)
'UpperLeftCornerBoxImages =
Me.CreateUpperLeftImageSquaresCorner()

ColorPellete = PelleteRectangles(CByte((4)), New Point(20, 20))
PegImages = CreatePegImages(4)

End Sub

Private Function PelleteRectangles(ByVal b As Byte, ByVal p As
Point) As Rectangle()
Dim r() As Rectangle = New Rectangle(b) {}
For i = 1 To b
If Decimal.Remainder(i, 2) = 1 Then

r(i - 1) = New Rectangle(p.X + Border - 10,
CInt((p.Y + Border + Math.Floor((i - 1) / 2) * 50)), BoxWidth, BoxWidth)
Else
r(i - 1) = New Rectangle(p.X + Border * 2 + BoxWidth
+ 20, CInt((p.Y + Border + ((i - 2) / 2) * 50)), BoxWidth, BoxWidth)
End If
Next
Return r
End Function

Private Function CreatePegImages(ByVal pelleteSize As Byte) As
Image()
Dim pegImages() As Image = New Image(pelleteSize + 1) {}
For i = 0 To pelleteSize - 1
pegImages(i) = New Bitmap(40, 40)
Dim g As Graphics = Graphics.FromImage(pegImages(i))
g.Clear(Color.White)
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
DrawingUtility.DrawPeg(g, New Rectangle(5, 5, 30, 30),
PelleteColors(i))
g.Dispose()
Next
Return pegImages
End Function

' Mouse position while Draging.
Dim mPosition As Point = New Point(0, 0)
' true if user is draging peg to board.
Dim PegPicking As Boolean = False
Public SelectedPeg As Byte = 255
Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)
Me.PegPicking = True
End Sub

Protected Overrides Sub OnMouseUp(ByVal e As
System.Windows.Forms.MouseEventArgs)
Me.PegPicking = True
g.DrawImage(Me.PegImages(0), ColorPellete(0).X + e.X,
ColorPellete(0).Y + e.Y)
Invalidate()
End Sub

regards

Nov 21 '05 #1
0 938

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

Similar topics

2
by: JustSomeGuy | last post by:
I'm looking for c/c++/java/basic code for QR Decomposition. The numerical recipes code only handles square matrices.
4
by: Tan Thuan Seah | last post by:
Hi all, I am currently coding a sparse factorization program for my project. I intend to make a comparison of the column based method and multifrontal method in terms of running time, but I am...
15
by: Paul T. Rong | last post by:
Hi everybody, This time a very very difficult case: I have a table "tblStudent", there are 50 students, I also made a form "frmStudent" based on "tblStudent", now if I don't want to show all...
0
by: Paul T. Rong | last post by:
I don't know why that I lost track of the post. I found it from the newsgroup and paste last two posts. Pieter Linden said: "To do this - use conditional formatting..." I didn' work it out....
1
by: Nick Palmer | last post by:
Hi all, I'm looking for some third party libraries that provide mathematic (financial) functions, and date functions to include in a VC project. Anybody out there have anything that they can...
0
by: ts | last post by:
Attn: Scientific/engineering computing professionals Attendance (Jan): 4.072 million http://netlib.org -- sw repositories http://gams.nist.gov -- guide (index) For a quick intro on how...
2
by: Ludo VdB | last post by:
Hi, I'm new to ASP. Currently I'm planning to develop a web application for my company. I want to use ASP for the application and use SQL-server as the back-end. I want to enable a userID and...
0
by: ravindarjobs | last post by:
hi friends, i am using ms access, vb6 i have created a process using the code CreateProcess(vbNullString, sCmdLine, 0&, 0&, 1, lCreateFlag, 0&, 0&, StartUp, udtProcess) and i want other...
9
by: san1014 | last post by:
Hi I have created a procedure using UTL_FILE. Before executing the procedure i created a directory as connect system/system; grant execute on sys.utl_file to PUBLIC;
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.