Few Scripting Questions

Started by skatey, Mon 08/08/2005 10:23:03

Previous topic - Next topic

skatey

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.

Ishmael

#1
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.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

skatey

Easy enough but how did you make sure gITEM.X + gITEM.Width isnt more than the screen ?

Ishmael

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.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Gilbert

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).

Ishmael

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.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

skatey

I tried that but for some strange reason would not work. So know any fixes ?

Ishmael

Try this simple change then...

if (mouse.x > (320 - gMenu.width/2))
  gMenu.x = (320 - gMenu.width/2);
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

skatey

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.

Pumaman

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);

Ishmael

Doh >_< Yes, thankyou.

I haven't done any serious scripting in ages, my basic knowledge is beginning to rust, I think...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk