Mouse Position

by Forum_account
[Share] [Zip]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Forum_account.MousePosition##version=3

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Forum_account.MousePosition##version=3

682 downloads
Version 3
Date added: Aug 26 2011
Last updated: Oct 16 2011
5 fans
Mouse Position
Provides a way to get pixel-precise mouse coordinates. [More]
With BYOND's traditional mouse procs you can get the exact pixel location of the mouse cursor, but only when a mouse event happens. For example, when the mouse crosses the boundary between two tiles, the MouseEntered event is triggered. However, when the player moves the mouse entirely within a tile, no mouse events are being called.

This library creates the client/MouseUpdate() proc which is called every time it detects mouse movement. All you have to do is this:

// enable mouse position tracking
mob
    Login()
        ..()
        track_mouse()

// update the crosshair position when the mouse moves
client
    MouseUpdate(tx, px, ty, py)
        mob.crosshair.screen_loc = "[tx]:[px - 16],[ty]:[py - 16]"


Version 3
• Added support for a resolution value of 16.

Version 2
• Made MouseDrag() also trigger MouseUpdate

Version 1
• Initial posting

More Info

new library - Mouse Position by Forum_account

Advertisement

Comments

Bravo1: (Jun 1 2012, 6:22 pm)
I noticed that there's no support for different world.icon_size values.

Personally half my projects use 64 as the icon size, but I have a project that uses 16 as well. All it would need is an if() check and two icons, or perhaps just one file that uses the icon size as a variable for the icon state that's used. If you want. I'll make the file (I kind of HAVE to at this point) and I'll provide a public link for you to download it and you can just modify the code to support it?

It's up to you, I'm just letting you know 0__0

Yut Put: (Jan 1 2012, 7:57 pm)
it doesn't allow your game to use the object parameter in mouse procs because it always picks up the object as mouse_tracker which is just short of impossible for the me to work around lol
Forum_account: (Sep 28 2011, 7:21 am)
I haven't done any testing so I have no idea. My guess is that it would cause significant CPU usage with 100 players because having 100 players by itself is enough to cause decent CPU usage no matter what they're doing.

If performance is that important you can adjust the resolution used so that mouse events will be detected every 8, 4, 2, or 1 pixel that the mouse moves. You lose some precision but decrease the CPU usage.
Avainer1: (Sep 28 2011, 1:15 am)
Does this use a lot of CPU? Lets say a game with about 70-100 players using it.
Gigimoi: (Sep 18 2011, 5:14 pm)
Good to know, I'll be using this now <3