Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Scavenger on Thu 08/08/2013 21:09:55

Title: Troubles with Inventory / Creating a Wavy Line Effect
Post by: Scavenger on Thu 08/08/2013 21:09:55
I'm working on a new interface for my MAGS game, but I'm coming up with a bit of trouble.

I'm trying for a Discworld style interface, where you can pick up and put down inventory items in your inventory. I can get it to work partway, that is, I can make the item be put down when you're hovering over the space of the inventory item you're carrying. I can't make it return the inventory item when it's over a null area, though. Here's the code I'm using:

Code (AGS) Select

// In my on_mouse_click function.
else if (button == eMouseLeftInv)
  {
    if (GUIControl.GetAtScreenXY (mouse.x, mouse.y) == invInventory)
      {
        InventoryItem* item =  InventoryItem.GetAtScreenXY (mouse.x, mouse.y);
        if (player.ActiveInventory != null)
        {
          player.ActiveInventory.Graphic = gItem.BackgroundGraphic;
          if (item == player.ActiveInventory || item == null) //If the item you're over is the (now empty) active inventory, or nothing at all
          {
            ReturnInventory (); //Return the inventory item to it's place in the window.
          }
        }
        else //Grab a new inventory item.
        {
        player.ActiveInventory = item;
        gItem.BackgroundGraphic = item.CursorGraphic;
        item.Graphic = 32;
        if (mouse.x - 16 > 0 ) gItem.X = mouse.x - 16;
        if (mouse.y - 10 > 0 ) gItem.Y = mouse.y - 10;
        gItem.Visible = true;
        itemvisible = true;
        }
      }
  }



And on an unrelated note, how would I be able to get a wavy effect on the background image (and some of the objects) with any alacrity, ala the line offset of the Genesis? You can see it in the Down the Tubes level of Earthworm Jim, or, I think, when you're underwater in Sonic 3. I'm not sure how I would make a sine wave distortion with the image. I tried modifying the Underwater module, but it just doesn't give the right effect. Would I need to chop the image up into lines (using the crop functions) and draw them onto a new frame at varying offsets but the same Y coords? Is that slow?
Title: Re: Troubles with Inventory / Creating a Wavy Line Effect
Post by: Gilbert on Fri 09/08/2013 03:06:14
By wavy effect do you mean something like this (http://www.youtube.com/watch?v=--WcU-az_6E)?
Title: Re: Troubles with Inventory / Creating a Wavy Line Effect
Post by: Scavenger on Fri 09/08/2013 03:17:03
Yeah! Exactly like those. All four in fact. I'm just not sure how to do it efficiently enough for real time.
Title: Re: Troubles with Inventory / Creating a Wavy Line Effect
Post by: Gilbert on Fri 09/08/2013 03:23:04
It's just some random test I've tried(and severely limited atm, as as far as I remember it could only shift < 10 pixels each line or something, so it needs some for refining but it didn't happen). I'll PM to you a link of the source for your reference. As it's been a few years ago I may not be able to decipher immediately what each line does in it.
Title: Re: Troubles with Inventory / Creating a Wavy Line Effect
Post by: Scavenger on Fri 09/08/2013 03:45:26
Yeah, I think this is just about enough for me to decipher! I can work out most of the specifics and work around the limitations of the code for now.