Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: arscott on Sat 06/12/2008 08:02:58

Title: Help getting mouse location
Post by: arscott on Sat 06/12/2008 08:02:58
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)?
Title: Re: Help getting mouse location
Post by: on Sat 06/12/2008 09:19:59
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.
Title: Re: Help getting mouse location
Post by: suicidal pencil on Mon 08/12/2008 02:38:24
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:


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.
Title: Re: Help getting mouse location
Post by: Trent R on Mon 08/12/2008 04:02:31
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