xzfc / agar-expose

Yet another ogar client
12 stars 12 forks source link

Can you add mouse coords? im pretty sure its case 32? #9

Closed DaAwesomeRazor closed 8 years ago

DaAwesomeRazor commented 8 years ago

As in the title

xzfc commented 8 years ago

Emm, you want to read mouse coordinates? Explain, please.

FYI, case 32 is "Owns blob" opcode that server sends to client 1.

DaAwesomeRazor commented 8 years ago

@xzfc Im an idiot just saying. THey are stored in vairable wa and va in the main.js.

Mouse coordinates. I am making bots and i need the bots to follow mouse. I made my own custom main.js and it is stored in function Ra() and vairables wa and va. I like using the script better though

jakemayeux commented 8 years ago

I think this is what you want

https://github.com/xzfc/agar-expose/issues/6

DaAwesomeRazor commented 8 years ago

@jakemayeux @xzfc I mean mouse coordinates. like the ones for bots. I need ones for my bots.

xzfc commented 8 years ago

Look at this:

var transform
var coords

function toWorldCoords(pixelCoords) {
    var x = (pixelCoords.x - transform.x) / transform.scale
    var y = (pixelCoords.y - transform.y) / transform.scale
    return {x, y}
}

agar.hooks.beforeTransform = (ctx, t1x, t1y, s, t2x, t2y) =>
    transform = {scale:s, x:t2x*s + t1x, y:t2y*s + t1y}

canvas.addEventListener("mousemove", e => coords = {x:e.x, y:e.y})

setInterval(() => console.log(toWorldCoords(coords)), 100)
DaAwesomeRazor commented 8 years ago

Works...