Hi. I'm just wandering if there is anything that will enable me to move my mouse and have something follow it (e.g An Object). Specifically a demo or just a really good explanation.
And Forgive me for asking of two things in one post, though I'm wondering whether there are any good Tile to Tile smooth movement libraries or demos. I liked using step_size (changing walk speed is essential!) but it was rather tedious since my game is built for tile to tile movement and attacks. I also checked out a few delay demos; but they are awfully glitchy - my character warps steps when I incorporate it into my game.
Oh, and in case you were wondering why you should download datumpoint? Because this is what you would have to do otherwise:
client
var/turf/t = locate(round(client.mouse_world_x/TILE_WIDTH)+1,round(client.mouse_world_y/TILE_HEIGHT)+1,client.mouse_world_z)
As for a few other things, I should mention, I'm not sure what will happen when the object you hover over is a screen object. So... There's that, and if you hover your mouse over something that is overlaying the edge of the map, you are going to get all kinds of problems. Admittedly, it would probably be easier to do something along these lines: var/get_dir_to_point(var/atom/o,var/point/dp) That should make it a bit more reliable. |
Uhh...Wow.
I'll try to understand all of that xD! I'm still on my way to become awesome. Thanks for taking the time to write that again, Ter. |
I'd actually taken the time to write most of it in another thread, I just repurposed it for your needs.
|
This will give you the mouse position in reference to the screen.
If you need mouse positions in reference to a particular object, I highly recommend you download my DatumPoint library, because it makes it quite easy:
Making an object follow this, is as simple as getting the location from the point datum, and telling the object to move toward this point:
Now, this won't be perfect, because you need to account for pixel_step, but I'll leave that to you to figure out.
I left a link to a matrixstep proc I had written on one of Kaio's feature requests, specifically regarding a request to stop rounding off step values. If you want perfect pixel movement towards wherever your mouse is pointing, I'd take a look at that.
Also, a link to the DatumPoint library:
http://www.byond.com/developer/Ter13/DatumPoint