Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: skatey on Mon 08/08/2005 10:23:03

Title: Few Scripting Questions
Post by: skatey on Mon 08/08/2005 10:23:03
Ok i started using ags 1 day ago and i have made alot of progress i know alot of the scripting (mainly to knowing C++, C, java, perl) so it was pretty easy but i have a few questions:

i have  a popup menu which shows when you right click the code shows its middle at the mouse:

example:

gMenu.X = mouse.x - gMenu.Width;
gMenu.Y = mouse.y - gMenu.Height;

or so i think that was it im not sure but anyway when it shows i make sure it dosent show off the screen like this:

exaple:

if(gMenu.X < 0){
   gMenu.X = 0;
}
else if(gMenu.X > game.room_width){
          gMenu.X = game.room_width - gMenu.Width;
}

if(gMenu.Y < 0){
   gMenu.Y = 0;
}
else if(gMenu.Y > game.room_height){
          gMenu.Y = game.room_height - gMenu.height;
}


but a problem occurs when you use scrolling menus it dosent work so is there another way to get this value i tried system.width and system.height but they didnt work.

I have a bar on my gui which has inventory (alternative for right click) show, and all the mouse modes but for some reason it isnt detecting the mouse presses i cannot give an example of my code because the chances are it wouldnt, i am just wondering if anyone has came across this problem in the past. Oh also i used the button event (Left Click = change mouse mode) but that didnt work.

I'll be thankful for any help, and if anyone needs any coding done for there game i will be happy to help.
Title: Re: Few Scripting Questions
Post by: Ishmael on Mon 08/08/2005 11:19:27
I did a verb coin some time ago, and to stop it from going out of the screen I first calculated the position, according to the mouse co-ordinates, and then moved to GUI to position and turned it on. GUIs work on screen co-ordinates, not room, so you can just use 320 for width (if it's low res, 640 if it's hi res) and 200 or 240 for height.
Title: Re: Few Scripting Questions
Post by: skatey on Mon 08/08/2005 11:22:05
Easy enough but how did you make sure gITEM.X + gITEM.Width isnt more than the screen ?
Title: Re: Few Scripting Questions
Post by: Ishmael on Mon 08/08/2005 11:26:17
You mean how to stop it from going out of the right edge?

if (mouse.x > (system.width - gMenu.width/2))
Ã,  gMenu.x = (system.width - gMenu.width/2);

Haven't tested, but that ought to do it.
Title: Re: Few Scripting Questions
Post by: Gilbert on Mon 08/08/2005 11:27:51
Quote from: Ishmael on Mon 08/08/2005 11:19:27
...so you can just use 320 for width (if it's low res, 640 if it's hi res) and 200 or 240 for height.
A bit of correction, horizontal screen res is still 320 when it's hi-res (it's 400 if you use 800x600 mode).
Title: Re: Few Scripting Questions
Post by: Ishmael on Mon 08/08/2005 11:30:37
Quote from: Gilbot V7000a on Mon 08/08/2005 11:27:51
A bit of correction, horizontal screen res is still 320 when it's hi-res (it's 400 if you use 800x600 mode).

Rrrright, me not thinking again... ::) Sorry.
Title: Re: Few Scripting Questions
Post by: skatey on Mon 08/08/2005 11:32:02
I tried that but for some strange reason would not work. So know any fixes ?
Title: Re: Few Scripting Questions
Post by: Ishmael on Mon 08/08/2005 11:49:17
Try this simple change then...

if (mouse.x > (320 - gMenu.width/2))
  gMenu.x = (320 - gMenu.width/2);
Title: Re: Few Scripting Questions
Post by: skatey on Mon 08/08/2005 13:56:09
haha you gave me the anwser not exactly the same but similar since i always use srolling screens *2 of my normal size so my 640 normal screen gets turned in 1280 i can just /2 and it works fine but then again this is only thoery lol i gotta get home and try this.
Title: Re: Few Scripting Questions
Post by: Pumaman on Mon 08/08/2005 22:00:35
Quote from: Ishmael on Mon 08/08/2005 11:49:17
Try this simple change then...

if (mouse.x > (320 - gMenu.width/2))
gMenu.x = (320 - gMenu.width/2);

That will leave it half off the screen though, so you probably want:

if (mouse.x > (320 - gMenu.width))
gMenu.x = (320 - gMenu.width);
Title: Re: Few Scripting Questions
Post by: Ishmael on Mon 08/08/2005 22:46:00
Doh >_< Yes, thankyou.

I haven't done any serious scripting in ages, my basic knowledge is beginning to rust, I think...