Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Miglioshin

#21
Hi Steptoe,
I faced the same problem in my game, but I solved with a little workaround (since I think that it's better to leave the 'hard coded parts' alone until you PERFECTLY know what you are doing EXACTLY).

I've written a function that checks which inventory item is currently under the cursor, and I used it for a double-purpose:
1.To print the name of the inventory item in a label in the inventory window
2.To work around the hard coded 'interact with inventory'.

in GlobalScript.asc:

Code: ags

function Inventory_Label_and_FakeInteract()
{
  if(gInventory.Visible==true)
    {
      
//I create an Inventory item token named 'item' that store the displayed object 
//at the actual mouse position

        InventoryItem *item = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
        
//If the mouse is over that item I want to open the new gui (iNew_Gui) I change the mouse.Mode
//from eModeInteract to another custom mode "eModeFakeInteract" that has the 
//same graphic that the interact cursor, viceversa I restore the 'true' eModeInteract

        if(item==iNew_Gui && mouse.Mode==eModeInteract)
          {mouse.Mode=eModeFakeInte;}
        if(item!=iNew_Gui && mouse.Mode==eModeFakeInte)
          {mouse.Mode=eModeInteract;}
          
//If mouse cursor isn't pointing an inventory item I 'empty' the label 

        if(item==null){lblInventory.Text="";}
        
//if mouse cursor is pointing an inventory item I print the inventory name

        else{lblInventory.Text=item.Name;}
    }
}


Then, since you have coded that behaviour that works perfectly with eModeLookat, you'll just add this

Code: ags

function iNew_Gui_OtherClick()
{
  if(mouse.Mode==eModeFakeInte)
    {iNew_Gui.RunInteraction(eModeLookat);}
}


Then, in game repeatedly_execute, you just make a call to the function

Code: ags

Inventory_Label_and_FakeInteract();


Obviously you can use only the code that 'change' the mouse.Mode to give the player the illusion of 'interacting' with the item that will only open a new gui instead of change the mouse.Mode to eModeUseInv.

I hope I haven't forgot nothing and that this can be of help.

Let us know...

Cheers

#22
Quote from: Khris on Thu 26/01/2012 22:09:25
Quote from: Miglioshin on Thu 26/01/2012 15:43:40And since I'm allowed to use 40 objects per room this will be 1 second slow in the worst case!  :o
Not at all; processing the entire loop only takes a fraction of a millisecond, even if it had to process hundreds of objects.

AGS doesn't work like Inform at all; each game loop, after all functions have been processed and the new screen has been drawn, AGS actually waits until the current game loops ends, otherwise most games would be impossible to control.

Oh... I see... so AGS goes far beyond my first thoughts on it...  :o
VERY FAR BEYOND...

   :=
#23
I looked into that code you suggested me, the one using a dynamic array, and I ended up with this lines to handle all the treasures (Scrigno del tesoro) and money bags (Sacco di dobloni) and eventually other kinds of collectible valuables I might insert... just with adding a few lines!

in room_RepExec()

Code: ags

  int totale;
  while (totale < Room.ObjectCount) 
    {if(Tesori[totale]==0 && AreThingsOverlapping(ISLANDHERO, object[totale].ID+1000))
      {if(object[totale].Graphic==457) //Scrigno del tesoro
        {Tesori[totale]=1;
         object[totale].SetView(17, 0, 0);
         object[totale].Animate(0, 6, eOnce, eNoBlock);
        }
       if(Tesori[totale]==1) 
        {Tesori[totale]=2;
         punteggio += 400;
        }
       if(object[totale].Graphic==466) //Sacco di dobloni
        {Tesori[totale]=1;
         object[totale].SetView(18, 0, 0);
         object[totale].Animate(0, 6, eOnce, eNoBlock, eForwards);
        }
       if (Tesori[totale]==1) 
        {Tesori[totale]=2;
         punteggio += 50;
        }
      }
     totale++;
    }


I was sort of scared approaching arrays in the past, they always looked complicated to me, but with your bit of code I think I understood them a little bit more...
And the code I came up with it's cool!
lol

Quote from: Khris on Tue 24/01/2012 22:28:04
That indentation however... :=

What's wrong with my indentation?
I always used this kind (also in INFORM6) and had no problems at all, actually, you are the first that comment on it... O_o

I think it's very clear and 'space' saving (I know that the empty lines doesn't affect the source code size, but affects how many times I have to scroll my window to check if all it's ok! lol)

See:



EDIT:

I looked further more into the code and I managed to streamline it a little bit more:

Code: ags

  int totale;
  while (totale < Room.ObjectCount) 
    {if(Tesori[totale]==0 && AreThingsOverlapping(ISLANDHERO, object[totale].ID+1000))
      {if(object[totale].Graphic==457) //Scrigno del tesoro
        {Tesori[totale]=1;
         object[totale].SetView(17, 0, 0);
         object[totale].Animate(0, 6, eOnce, eNoBlock);
         punteggio+=400;
        }
       if(object[totale].Graphic==466) //Sacco di dobloni
        {Tesori[totale]=1;
         object[totale].SetView(18, 0, 0);
         object[totale].Animate(0, 6, eOnce, eNoBlock, eForwards);
         punteggio+=50;
        }
      }
     totale++;
    }


This works good! And it will work as it is even if I add more trasures! And since I'm allowed to use 40 objects per room this will be 1 second slow in the worst case!  :o
This is AMAZING!  8)

Many thanks again Khris!!

#24
I figured out that it was firstly a matter of 'order of things', the biggest issue I had with AGS is that I was used to think 'one game loop after every action' (with IF the game do just one loop after each command/action you input) and not 40 loops per second!!
So with AGS the order in which you put conditions is much more relevant than ever because 40 different values can change in about a second giving you the feeling that nothing happened! lol (from time to time I forget about this thing...)

IMO is not that strange that this actually works, following the game loop:

Code: ags

  if(AreThingsOverlapping(ISLANDHERO, 1000) && oScrigno1.Graphic==457)

    //Ok, now we are overlapping so:

     {if(Scrigno1==false)   //not yet collected
        {if(!oScrigno1.Animating)   //not yet animating  
           {oScrigno1.SetView(17, 0, 0); 
            oScrigno1.Animate(0, 6, eOnce, eNoBlock, eForwards);
           }

//I set the view and trigger the animation AFTER checking if an animation has been
//triggered the loop before, in this order the conditions prevent AGS to trigger the
//animation again during the next game loop. 
//In the code used before I was setting the view BEFORE checking .Animating
//so the animation triggered the loop before stopped due to the .SetView call and
//not due to the frame delay.



Smooth... or not?

EDIT:
While testing I realized that opening the chest doesn't give points anymore, so I moved the scoring part of the script out from the AreThingsOverlapping call and ended with this:
Code: ags


  if(AreThingsOverlapping(ISLANDHERO, 1000) && oScrigno1.Graphic==457)
     {if(Scrigno1==false)
        {if(!oScrigno1.Animating)
           {oScrigno1.SetView(17, 0, 0);
            oScrigno1.Animate(0, 6, eOnce, eNoBlock, eForwards);
           }
        }
     }
  if(oScrigno1.Graphic==465 && Scrigno1==false)
      {Scrigno1=true;
       punteggio=punteggio+400;
      }



Now all seems well.

#25
Indeed, the animation was triggered over and over....
Now that you helped me to address the problem I modified my lines into
Code: ags


  if(AreThingsOverlapping(ISLANDHERO, 1000) && oScrigno1.Graphic==457)
     {if(Scrigno1==false)
        {if(!oScrigno1.Animating)
           {oScrigno1.SetView(17, 0, 0);
            oScrigno1.Animate(0, 6, eOnce, eNoBlock, eForwards);
           }
         if(oScrigno1.Graphic==465)
           {if(Scrigno1==false)
              {Scrigno1=true;
               punteggio=punteggio+400;
              }
           }
        }
    }



and it work just as we expected. ^_^

I will go deep into your coding suggestion to figure it out completely before simply copying and pasteing into my code.
That really look like a useful slimming diet for my code! LOL

Many thanks Khris.

#26
Ok, I inserted your code at the top:

Code: ags


lblDebug.Text = String.Format("ATO return value: %d", AreThingsOverlapping(ISLANDHERO, 1000));



without the 'return', because leaving that there will completely freeze the room (I have several things happening in room_RepExec).

It returned several values from 0 (non-overlapping) to 20 (I was in the middle of the treasure box) to 0 again (when I walked to the right 'leaving' the treasure).
Then the animation started.

I'm clueless...

Slightly OT:

For the 'generic' code, I used INFORM6 (Object based) before beginning with AGS and I'm actually wondering if it is possible to have some sort of "Classes of Objects" like in Inform, to have a thinner coding...

Something like this:

Code: ags


Class TREASURES
 ---properties---
 ---functions conditions---
 ---attributes---
 ;



then I could have in my code something like this

Code: ags

if(AreThingsOverlapping(ISLANDHERO, OBJECT))
   {if(OBJECT ofClass TREASURES)
       {blah blah blah my code;}
   }


This once for EVERY object that is a children of the Class!

There is a 'simple' way to do things like this in AGS or I do need some advanced scripting knowledge?


EDIT:
I changed the 'debug line' into this:
Code: ags


lblDebug.Text = String.Format("ANIM return value: %d", oScrigno1.Animating);



and it continuosly returned 1 while standing in front of the 'frozen' treasure box, I left to the right, it returned 0 and the animation started.
So apparently AGS continuosly trigger the animation despite of my code.
Now I'm looking deeper into the code...


#27
Hi everyone.
In my mini-game, that I'm stubbornly handling INSIDE the actual game (because of an arcane and obscure reason), I have a little problem with the function AreThingsOverlapping.

When the Hero and a closed treasure box are overlapping I want the trasure box to open with an animation (with also floating scored points) and then add the score and consider that specific box as already collected (until the next game)

Ok, here's my piece of code (in room_RepExec())

Code: ags


  if(AreThingsOverlapping(ISLANDHERO, 1000) && oScrigno1.Graphic==457) // 'Closed' sprite
     {if(Scrigno1==false)  // The box haven't been opened, GameDoOnceOnly is not suitable for my purpose        
          {oScrigno1.SetView(17, 0, 0); // The 'opening' view
              if(!oScrigno1.Animating) // The box isn't animating           
                   {oScrigno1.Animate(0, 6, eOnce, eNoBlock, eForwards);} // Start the animation
          }
      }

  if(oScrigno1.Graphic==465) // 'Opened' sprite && final frame of the animation    
    {if(Scrigno1==false)       
        {Scrigno1=true; // The box have been opened        
          punteggio=punteggio+400;} //add score
     }



Actually all the stuff (animation and scoring) begins when the hero and the treasure are NO MORE overlapping.

If I just stand in front of (overlapping) the treasure nothing happens, until I leave (outside the sprite border)... ???

I want the stuff running even if the hero is still overlapping the treasure.
What am I doing wrong?
What's the thing I don't understand?

Thank You all in advance.

EDIT: Modified the layout hopefully in a tidier way

#28

I'm not an expert when it comes to abbreviations or chat-like typing...

but I guess ''afaik'' means ''as far as I know''.

Cheers
#29

If I understand correctly what you want to do, you want to 'cut' the black background of your Gui.

Try to change the black background colour of your GUI background sprite into a unique colour (different from any other colour used in the sprite) and, while re-importing the image set the transparency colour accordingly (like top-lef pixel or bottom left pixel or so)
In the same way you do for the objects or charachters sprites.

If you wanted your 'entire'  gui to be semi-transparent (for some reason), just set the trsparency accordingly in the GUI menu (to the right) or in game_start():
gMyGui.Transparency=50 (i.e.) (0 = solid - 100 = invisible)

Just checked it with one of my GUIs (AGS 3.2.1 SP1) and it works fine.
#30
Hmmm...
Actually the function, as it is now, changes the object graphic at each cicle, even when the correct sprite is displayed.

If you want AGS to exit the function when it has done what you need (played sound and/or set the bool to false or true) you have to add another if contition to have it checked 'every first time' the player walks on the specified region, like this:

 if (rr.ID == 1 && object.[1].Graphic != 96) \\The sprite isn't #96 otherwise return
{
   object[1].Graphic = 96;
   play_owl_hoot = true;
 
 }

 if (rr.ID == 2 && object.[1].Graphic !=95)  \\Ditto
 {
   object[1].Graphic = 95;
   PlaySoundEx(6, 4);
   SetChannelVolume (4,100);
   play_owl_hoot = false;
 }

 if (rr.ID == 3 && object.[1].Graphic !=97)  \\Ditto
 {
   object[1].Graphic = 97;
   play_owl_hoot = true;
 }

With theese changes, the 'if (play_owl_hoot == true)' etc, becomes redundant, since we have already checked if the sprite has changed we don't need to check also the satate of the bool, we change it when we change the displayed sprite, so we can remove that if condition.

EDIT: I guess, in fact, that you can completely remove the bool, because now you are using the sprite number as discriminating factor...

  if (rr.ID == 1 && object.[1].Graphic != 96) \\The sprite isn't #96 otherwise return
{
    object[1].Graphic = 96;
  }

  if (rr.ID == 2 && object.[1].Graphic !=95)  \\Ditto
  {
    object[1].Graphic = 95;
    PlaySoundEx(6, 4);
    SetChannelVolume (4,100);
  }

  if (rr.ID == 3 && object.[1].Graphic !=97)  \\Ditto
  {
    object[1].Graphic = 97;
  }

Maybe this is a little neater, at least imho, but I'm not the best here around  ;)
#31
Hi Retrojay,
I think you can simply add, where you need your sound to be played, the line:

if(Game.DoOnceOnly("play_eyes_sound"))
  {
    PlaySoundEX (6,4);
    SetChannelVolume (4,100);
  }

This will tell AGS to play that sound effect just ONCE (the first time it come across the condition); because of your instructions are in the repeatedly_execute_always function, AGS will play that sound each cicle (40 per second) because the condition will be continuosly true while the player walk through that specific region.

And if this works properly (it should do) the bool become useless.

Or you can just change this:

  if (rr.ID == 2) etc...

in this:

  if (rr.ID == 2)
  {
    object[1].Graphic = 95;
        if(play_owl_hoot == true)
          { PlaySoundEX (6,4);
             SetChannelVolume (4,100);
             play_owl_hoot = false;
           }
   }


#32


Thanks guys for your hyper-quick response!  ;D ;D ;D


#33
I searched the forum and checked the dynamic help but it seems that i can't find a proper answer.

Since I already encountered the 20-objects-per-room limitation (due to my lack of experience - i.e. handling doors with 2 different objects instead of 1 object with 2 sprites and appropriate coordinates...), this question popped up in my mind.

The fact is that I'm thinking about a sort of minigame/puzzle implemented using several GUIs, buttons, labels and cursors, instead of handling it with rooms, objects, hotspots, inventory items and text overlays.

Each one of the methods have its own scripting issues but I think that what I have in mind will be easier/shorter to handle with GUIs.

But I don't want to unexpectedly run out of GUIs before completion!

Another related question, is there, in the same way, any limitation to the number of buttons a GUI can have?

I thank you all in advance for the answers.
#34
Hi everyone!
I didn't posted for a long time but my project's still under construction.
It's taking longer than I initially expected, but I'm all alone...

ATM I'm really close to releasing a short Italian Demo (I miss about 2 screens, a Gui and some descriptions) and if nothing will go wrong... **cross fingers**

Imho it's time for a small update so here follow some screens to increase your expectations! (???)

A room a house cannot miss:



Our Hero fighting with his fat and lazy dog:



A SHARK!? IN A POOL!? WEARING A LIFEBUOY AND SUNGLASSES!? AM I SERIOUS!?



Crop circles in the backyard meadow!? O_O



#35
The game is progressing at a good pace, so here is a little spoiler for you:

Our hero own an arcade machine in his room, that contains a minigame strongly and heavily inspired by Pitfall II:

ISLAND RAIDER

#36
Oh, don't worry about that...

I'll do my best to make an english version that will live up to the Italian one!  ;)
#37
Thank you guys!  ;D
#38
I like your art style.

looking forward to play the game!
#39
Quote from: Baron on Thu 19/05/2011 00:05:22
I like your main character -he reminds me of something, but I can't put my finger on it....  

Maybe he reminds you of the singer in Guitar Hero III, or the main character of Brutal Legends...
I tried to draw a clichèd metalhead character, and those two games influenced me a lot in doing that.

Quote from: Baron on Thu 19/05/2011 00:05:22
Does your GUI really enable charting (lower left) and sewing (at right)?  That's going to make for one hell of an interesting game!

Ehm...  no. :-[

The lower left icon is my first attempt for an 'options' icon, and for the other one is actually a jeans poket for the inventory...  :-[

But some of the earlier quests are actually including the assembly of the inventions.

Quote from: Baron on Thu 19/05/2011 00:05:22
Good Luck!

Thanks!
#40
Hi everyone!

This is my first game with AGS.
It will be a medium lenght game, I'm programming it in Italian but an english/american version is already in plan, hopefully with the help of someone that can adapt the jokes and the bad language in english...
It is in 16-bit colour with 800x600 res

The story:

An ordinary day our nameless hero enter his kitchen to have a cool beer but, unexpectedly, he can't find any.
Unluckily he soon realize that is Sunday and the nearest supermarket is closed, so he decide to
ask his absent-minded granpa (that lives with him); pointless since he's absent-minded!
But nothing's lost, our hero is an inventor and suddenly remeber that, among his crazy inventions, there might be one that comes in handy to retrieve his lost beer...
This little absence of beer, along with the unbearable thirst, will lead our hero to experience the biggest adventure of his life, filled with nonsense (hopefully funny and laughable) and strong language...

Some pics:

























Release date expected: A.S.A.P.  ;)

EDIT: I resized and updated all the thread screenshots and added all the picture to this post
SMF spam blocked by CleanTalk