Help getting mouse location

Started by arscott, Sat 06/12/2008 08:02:58

Previous topic - Next topic

arscott

Hiya.  Name's Alan.  I'm brand new to these forums.

Right.  Now that I've gotten a chance to play around with AGS for a bit and am comfortable with the basics, I'm trying to do something a little bit more ambitious--A chalkboard that the player can draw on.

Problem is, I can't figure out how to get the exact location of the mouse--something that's rather important for drawing.

Is there a way to get the mouse coordinates in relation to the background, or in relation to an object (either would work)?

Ghost

Mouse coordinates are stored in mouse.x and mouse.y. You can test and compare them easiliy with an IF statement-

if (mouse.y == oDoor.y) {//do code}

AGS mostly handles mouse coordinates and scrolling rooms internally, but if you need "true room coordinates", you need to add the viewport to the mouse coordinates.

suicidal pencil

As ghost said, coordinates are stored in mouse.x and mouse.y.

Using them to draw on a chalk board isn't too hard.

Just need to use a hotspot, and a new sprite.

the code would look something like this:

Code: ags

function HOTSPOT1_AnyClick()
{
***Create 'sprite001' at 'mouse.x' and 'mouse.y' 
}



Not sure what the command will be to create a new sprite, but that's the basic shell of what it might be.
Please note that it is pseudo-code.

Trent R

Ghost is right about the mouse thing, and it sounds like you know what the drawing part will require.

To expand upon suicidal's comments, you should look up DrawingSurface and DynamicSprite in the manual. But I'm not even sure if you need them....


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk