Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Do you remember an old board game called 4000 A.D.?
I'm writing a translation in VB.Net! I've got a Form with a PictureBox that has the Game Board Graphic in it. It has a space background with 48 Main Stars. I've written a routine that finds which Star the Mouse is hovering over and then Highlights that Star, or unhighlights a Star if the Mouse has stopped hovering over it, using the following code:
For Apos = 0 To 47
' If we're touching a Star
If (e.X > (StarX(Apos) - 10) And e.X < (StarX(Apos) + 10)) And (e.Y > (StarY(Apos) - 10) And e.Y < (StarY(Apos) + 10)) Then
If StHi Then
Apos = 47
starClicked = Apos
HighlightStar(tmpStr1, StarX(Apos), StarY(Apos))
saveStX = StarX(Apos)
saveStY = StarY(Apos)
StHi = True
Apos = 47
' We;re not touching a Star
' Erase Highlight
If StHi = True Then
HighlightStar("", saveStX, saveStY)
TextBox1.Text = GameMessage
StHi = False
This routine works, but it is slow.
Is there another way I could accomplish this faster?
Keep in mind I am a complete newcomer to VB.Net and there is much I do not understand.
Thanks and have a great day.
0 · ·