![]() |
Simple Click To Move - Printable Version +- Mirage Engine (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Simple Click To Move (/showthread.php?tid=267) |
Simple Click To Move - Tutorial Bot - 23-08-2006 Author: pingu Difficulty: 1/5 "Click somewhere on the map and your player will automatically walk there. However, blocks are ignored and the player may find themself stuck if they go too far. Double click to run the distance." :: CLIENT SIDE :: Find: Code: ' Game fps Code: ' Used for automatic movement Code: PlayerBuffer = "" Code: xToGo = -1 Code: Sub CheckInput Code: Sub CheckInput(ByVal KeyState As Byte, ByVal KeyCode As Integer, ByVal Shift As Integer) Code: Sub picScreen_MouseDown Code: Private Sub picScreen_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Code: ' Check if player is trying to move Code: ' Auto move Code: ' Check if player has the shift key down for running Code: ' Check if player has the shift key down for running - Spodi - 23-08-2006 From what I see, it is "You move in this direction while clicking", correct? Has anyone done a "Click here and the engine will calculate the shortest path and walk there automatically"-type thing? That'd be pretty fun to see, too. Theres plenty of pathfinding guides and code out there, so that wouldn't be the hard part. Taking into account the fact that people can jump into your way may make things a little harder, though. Easiest way to go about it would to keep in memory the targeted (clicked) position and recalculate the path every tile a new tile is reached and just move one tile. You could probably optimize it a bit, though, by keeping a buffer of the path to travel, then after each movement to a new tile check if any of the path has been obstructed - if so, then recalculate. Sorry, I digress. :wink: - pingu - 23-08-2006 I actually wrote a really big function once that kept calling itself (I forget what that is called). In theory, it worked nicely. It would split off into four directions with another few function calls. It would then work it's way until one of them hit gold, and then stop all the others. Sounds nice, but the stupid thing found a way of turning on itself and lagging. In in the end, the long wait time just wasn't worth it. |