Results 1 to 9 of 9

Thread: show a game tile (image) move from point a to point b

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    show a game tile (image) move from point a to point b

    I'm sure this must be fairly straight forward.. but i haven't been able to find a solution (or even a starting point).. i'm probably just doing the wrong searches..

    I have a game (several actually), all 'chess like'.. and i would like to add a bit of animation (not gifs) to show the tiles actually moving from point a to point b along a given path (usually not a straight line).

    the tiles/board are all done as custom picture boxes (if that matters).

    can anyone point me to a decent "how to".. or something?

    TIA

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: show a game tile (image) move from point a to point b

    Use a timer with a small interval. At each tick of the timer, move your tile part of the way towards its destination...

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: show a game tile (image) move from point a to point b


  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: show a game tile (image) move from point a to point b

    the picturebox needs to stay right where it is..(as it's the board too).

    should i be making a virtual PB for this?.. or doing some kind of draw event thing on the form..?

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: show a game tile (image) move from point a to point b

    You can use a picturebox, but it will look untidy if your piece icon isn't square. I'd use a semi transparent image. draw your pieces to a blank copy of your board, then display the board Image...
    Here's another graphical game example... https://social.technet.microsoft.com...rspective.aspx

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2016
    Posts
    216

    Re: show a game tile (image) move from point a to point b

    will go over that one.. see what i can do with it. (the previous one had so many errors it wasn't usable)

    ty

    Quote Originally Posted by .paul. View Post
    You can use a picturebox, but it will look untidy if your piece icon isn't square. I'd use a semi transparent image. draw your pieces to a blank copy of your board, then display the board Image...
    Here's another graphical game example... https://social.technet.microsoft.com...rspective.aspx

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: show a game tile (image) move from point a to point b

    Any errors are probably just due to vb versions, or else easily fixed, but as always, any errors are free of charge

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: show a game tile (image) move from point a to point b

    With your animations, anything 20frames per second or faster will be seen as fluent movement by the human eye...

  9. #9
    Lively Member
    Join Date
    Jan 2020
    Posts
    120

    Re: show a game tile (image) move from point a to point b

    HTML Code:
    Dim Offset As Point
    Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseDown
         Offset = New Point(-e.X, -e.Y)
    End Sub
    
    Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseMove
         If e.Button = Windows.Forms.MouseButtons.Left Then
             Dim Pos As Point = Me.PointToClient(MousePosition)
             Pos.Offset(Offset.X, Offset.Y)
             PictureBox1.Location = Pos
         End If
        End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width