I'm encountering a problem with an attempt at a* movement.
If you don't know what that is, it is computer influenced movement/path-finding. Right now all I have is the basics.
The brown things are obstacles. I'm going to change my code to avoid obstacles once I get it to work without obstacles.
It's only supposed to move one at a time, but instead it moves, usually, around four at a time, towards the yellow block.
You have to press a key to activate the movement.
I anybody could look at what I'm doing wrong that would be greatly appreciated!
Looping problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Looping problem
- Attachments
-
- a_star.love
- (2.66 KiB) Downloaded 67 times
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- severedskullz
- Prole
- Posts: 36
- Joined: Thu May 30, 2013 1:55 am
Re: Looping problem
In line 46 of Main.lua you are breaking the loop and allowing more executions. You're naming conventions are horrible, so I don't know what variable is what. I assume you want to 'return' there instead, which solved your issue.
After the 4th iteration I ran into an error on line 84 in tile.lua in which you are trying to access nil values by blindly accessing indexes of a table. In this case, you are at the bottom with no tiles below you, yet you try and access a non-existent tile. You need to check and see if the exist first before you assign them and use them in expressions.
After the 4th iteration I ran into an error on line 84 in tile.lua in which you are trying to access nil values by blindly accessing indexes of a table. In this case, you are at the bottom with no tiles below you, yet you try and access a non-existent tile. You need to check and see if the exist first before you assign them and use them in expressions.
Re: Looping problem
Thanks! This solved my problem!
Still can't figure out what's wrong with that scenario, though, since I create the tables if it's not there.
Still can't figure out what's wrong with that scenario, though, since I create the tables if it's not there.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- severedskullz
- Prole
- Posts: 36
- Joined: Thu May 30, 2013 1:55 am
Re: Looping problem
Why? That's a very bad way of going about a solution. You need to check if there is tiles on all 4 sides before you try and use it in your formula. If there isn't anything below you obviously you cannot go down, so don't take it into consideration when you are weighing the least expensive path for A*.davisdude wrote:Thanks! This solved my problem!
Still can't figure out what's wrong with that scenario, though, since I create the tables if it's not there.
Re: Looping problem
Yeah, I know. It just keeps my code DRY.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Who is online
Users browsing this forum: No registered users and 4 guests