Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: geork on Thu 03/09/2009 15:28:02

Title: Universal Objects?
Post by: geork on Thu 03/09/2009 15:28:02
 Hello all!
  I was wondering whether it is possible to implement an object into many rooms (instead of implementing the object in each room, and updating it to the last rooms status). For example, maybe a healthbar which has 5 different HP stages, and if the player gets damaged, another object is displayed for a different HP stage, I wouldn't want to add 5 objects to many, many rooms i will be using. (This is an example).
   Thanks
Title: Re: Universal Objects?
Post by: Gilbert on Thu 03/09/2009 15:31:23
You may use a GUI or a character for this purpose
Title: Re: Universal Objects?
Post by: Matti on Thu 03/09/2009 15:32:32
Don't use objects, use GUIs for health and such things..

Edit: Beaten by Gilbet..
Title: Re: Universal Objects?
Post by: geork on Sat 05/09/2009 21:15:56
 Thanks!
  I have another question, related. I want the GUI to appear if the player clicks and holds the right mouse button. if the mouse is above a certain x position (while right mouse is held down), i want it to display an the GUI with a different background image (image 7), and if below, a third image (image 8). I tried this code:

  if(mouse.IsButtonDown(eMouseRight)&& undone == true){
   undone = false; //so GUI won't move when mouse moves
      rightx = mouse.x - 100; //centre image on mouse
      righty = mouse.y - 100; //centre image on mouse
      gRightClick.SetPosition(rightx, righty); //uses the centreing
     gRightClick.Transparency = 0;//displays GUI from invisible
}
if(mouse.IsButtonDown(eMouseRight) != true){
  gRightClick.Transparency = 100; //get GUI back invisible
   undone = true; //so one can right click with effect to get the GUI
}
   if(gRightClick.Transparency == 0){
     if(mouse.x > rightx){
       gRightClick.BackgroundGraphic = 7;
     }
     if(mouse.x < rightx){
       gRightClick.BackgroundGraphic = 8;
     }
}

    However, the only image ever displayed is image 7, and never image 8.
     what do I need to do?
      Thanks.
Title: Re: Universal Objects?
Post by: Khris on Sat 05/09/2009 21:21:57
Well, you're setting rightx to mouse.x - 100, so naturally, mouse.x is bigger than rightx when you do the check.
I'm not sure what you're after so I can't provide a solution yet.
Title: Re: Universal Objects?
Post by: NsMn on Sat 05/09/2009 21:24:28
Also, if you want it to display when the button is being hold, you should use a while loop instead of the if-struct.
Title: Re: Universal Objects?
Post by: geork on Sat 05/09/2009 21:44:11
 heh, the solution was to add 100 to rightx ;)
  thanks for the while loop idea :)
Just one more question: is there a way to test whether a mouse is beneath a line runningly up at 45 degrees?
    thanks.
Title: Re: Universal Objects?
Post by: Matti on Sat 05/09/2009 22:03:04
I know shit about math, so Khris might be the man, but...

If you know where the line starts, you could simply do something like:

if (mouse.y<mouse.x) ....

This would work if the line starts at the bottom left of the room and goes to the upper right. If it starts somewhere else, just add some numbers..
Title: Re: Universal Objects?
Post by: geork on Sat 05/09/2009 22:16:28
 Thankyou! It seems so obvious, and yet...
  of course, if the line did not have 45 degree angle one would have to do stuff with trigonometery etc, but for my needs, it works!
   Thanks again for all you're help :)