Pathfinding

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts Page 1 of 1
Contributors
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Pathfinding
Lewis
Hello guys,
Well lately i have been trying to make an isometric game with pathfinding ( explained later in post ) but i have resorted to making the user click to move a tile.
gamepic.png
When the user clicks a tile ( highlighted red ) i want the box shape to make a rout from tile to tile, the fastest way, until it has reached the specified location, All help will be great, if you need any more info please put it bellow.

Lewis

current source:
Code: Select all
Public Class Form1

    Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
        PictureBox1.Location = New Point(PictureBox1.Location.X - 28, PictureBox1.Location.Y + 14)
        PictureBox2.Location = New Point(PictureBox2.Location.X - 28, PictureBox2.Location.Y + 14)
        PictureBox3.Location = New Point(PictureBox3.Location.X - 28, PictureBox3.Location.Y + 14)
        PictureBox4.Location = New Point(PictureBox4.Location.X - 28, PictureBox4.Location.Y + 14)
        PictureBox5.Location = New Point(PictureBox5.Location.X - 28, PictureBox5.Location.Y + 14)
    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        PictureBox1.Location = New Point(PictureBox1.Location.X + 28, PictureBox1.Location.Y - 14)
        PictureBox2.Location = New Point(PictureBox2.Location.X + 28, PictureBox2.Location.Y - 14)
        PictureBox3.Location = New Point(PictureBox3.Location.X + 28, PictureBox3.Location.Y - 14)
        PictureBox4.Location = New Point(PictureBox4.Location.X + 28, PictureBox4.Location.Y - 14)
        PictureBox5.Location = New Point(PictureBox5.Location.X + 28, PictureBox5.Location.Y - 14)
    End Sub

    Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        PictureBox1.Location = New Point(PictureBox1.Location.X + 28, PictureBox1.Location.Y + 14)
        PictureBox2.Location = New Point(PictureBox2.Location.X + 28, PictureBox2.Location.Y + 14)
        PictureBox3.Location = New Point(PictureBox3.Location.X + 28, PictureBox3.Location.Y + 14)
        PictureBox4.Location = New Point(PictureBox4.Location.X + 28, PictureBox4.Location.Y + 14)
        PictureBox5.Location = New Point(PictureBox5.Location.X + 28, PictureBox5.Location.Y + 14)
    End Sub

    Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click
        PictureBox1.Location = New Point(PictureBox1.Location.X - 28, PictureBox1.Location.Y - 14)
        PictureBox2.Location = New Point(PictureBox2.Location.X - 28, PictureBox2.Location.Y - 14)
        PictureBox3.Location = New Point(PictureBox3.Location.X - 28, PictureBox3.Location.Y - 14)
        PictureBox4.Location = New Point(PictureBox4.Location.X - 28, PictureBox4.Location.Y - 14)
        PictureBox5.Location = New Point(PictureBox5.Location.X - 28, PictureBox5.Location.Y - 14)
    End Sub
End Class
You do not have the required permissions to view the files attached to this post.
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Pathfinding
mandai
Maybe you could move the shape with 2 for loops until it is where it needs to be?
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Pathfinding
Lewis
Example code, I dont realy get it like that .
Image
User avatar
lesan101
Top Poster
Top Poster
Posts: 193
Joined: Tue Jun 29, 2010 8:10 am

Re: Pathfinding
lesan101
haha, looks like habbo hotel. lol
Image
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Pathfinding
Lewis
yeah well, i designed it, i diddnt rip.
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Pathfinding
mandai
Code: Select all
        Dim xBlocks As Integer = 2
        Dim yBlocks As Integer = 3 'example to move right by 2 blocks, down by 3

        Dim blocksize As Integer = 28

        For x As Integer = 0 To xBlocks * blocksize Step blocksize
            PictureBox1.Left += x
        Next

        For y As Integer = 0 To yBlocks * blocksize Step blocksize
            PictureBox1.Top += y
        Next
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Pathfinding
Lewis
Mandai that code diddnt work as it went off path and diddnt go on the tile correctly, Also i want it to like "animate" itself to each tile (slide)
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Pathfinding
mandai
For animation you can add in delays and have the loop running inside a different thread like in a backgroundworker, you could also decrease the step amount in each loop.
You might have to adjust the blocksize to the amount needed for it to work in isometric bounds.

Edit: Sorry this isn't my area of expertise maybe someone else can help?
Last edited by mandai on Wed Jul 28, 2010 10:42 am, edited 1 time in total.
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Pathfinding
Lewis
im having problems animating it ): Any help ?
Image
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Pathfinding
Lewis
Bump 's head on the forum because I still need help.
Last bumped by Lewis on Wed Jul 28, 2010 9:40 am.
Image
10 posts Page 1 of 1
Return to “Tutorial Requests”