Universal Objects?

Started by geork, Thu 03/09/2009 15:28:02

Previous topic - Next topic

geork

 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

Gilbert

You may use a GUI or a character for this purpose

Matti

Don't use objects, use GUIs for health and such things..

Edit: Beaten by Gilbet..

geork

 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:
Code: ags

  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.

Khris

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.

NsMn

Also, if you want it to display when the button is being hold, you should use a while loop instead of the if-struct.

geork

 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.

Matti

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

geork

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

SMF spam blocked by CleanTalk