Computer Science Canada Smooth Movement on a predetermined path? |
Author: | Atherial [ Fri Dec 04, 2015 10:16 am ] |
Post subject: | Smooth Movement on a predetermined path? |
Hello everyone! First I would like to thank this community for the continual help, it has made this course a lot more fun, and more laid back for me! I have started work on a Tower Defense styled game, with functional turning towers to shoot at cars, etc. I have everything functional except the movement of the units/cars on the path. On the sandy parts, I want the cars to smoothly navigate and make corners with ease. Of course, I have made sprite navigate the path, with for loops and loops that exit when certain vectors are reached; but this does not appear as professional as I would wish in this program. (The cars stop moving to turn) If anyone has any ideas on any equations or something that would render their movement more smooth, realistic on the paths, please let me know! (Each black square is 75 pixels by 75 pixels, the grey squares are 25 pixels by 25.) If you guys want the tileset I made for this game for your own projects, id be pleased to share them! Thank you for the help! -Mackenzie |
Author: | Insectoid [ Sat Dec 05, 2015 8:16 pm ] |
Post subject: | RE:Smooth Movement on a predetermined path? |
I think the easiest way would be to have an array of coordinates representing the vertices in your path. Have the cars move in a straight line from one coordinate to the next. When it reaches that coordinate, start moving to the next one. Alternatively, you can define your grid as a 2d array of Boolean. True is a wall, and false is a road. It will only take a very simple pathfinding algorithm to navigate your roads based on this approach. You can even use this array to draw the map with your tileset, so all it will take to make a new map is changing the array. Pathfinding and drawing it will be handled automatically. |
Author: | Atherial [ Mon Dec 07, 2015 9:59 am ] |
Post subject: | RE:Smooth Movement on a predetermined path? |
Thank you, il just have the sprite rotate once it reaches the XY position on the array, I may switch to the 2d array of boolean if I allow for the user to make their own tower defense map's. Great idea! |