Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Sparky on Mon 12/02/2007 00:11:14

Title: in-engine "emoticons" (working)
Post by: Sparky on Mon 12/02/2007 00:11:14
In comic books and some old RPG's, characters sometimes have tiny drawings over their heads that represent their feelings- stormclouds, flowers, radiating lines, etc.

I'm using this type of drawing during dialog, and I've been unable to figure out how to implement it. Ideally I would have a non-blocking function that would create and animate an "emoticon" for a set amount of time, then delete it.

I've currently got the following:
  RawSaveScreen();
  RawDrawImage(160, 120, 1);
  Wait(80);
  RawRestoreScreen();
This looks exactly how I want it to, but it the timing is interrupting character animation and dialog.

Is there a way to do this in a background process?
Title: Re: in-engine "emoticons"
Post by: Khris on Mon 12/02/2007 01:15:31
Use a DynamicSprite to show the emoticon and turn it off using a Timer.

Edit: My brain is switched back on now, so using a character is of course what I intended to write :)
Title: Re: in-engine "emoticons"
Post by: Kweepa on Mon 12/02/2007 01:36:05
I'm not sure how a DynamicSprite would help.

I'd assign a spare character to be the emoticon, then place the emoticons in views that the character can switch to using cEmoticon.LockView(CLOUDVIEW); This has the advantage that the emoticons are automatically animated.

You can move the emoticon to the appropriate position, or set it to room -1 to hide it. And, as KhrisMUC says, use a timer to switch it off.

If you need one for each character, that is a different story. RawDrawImage isn't a great solution because the emoticons are drawn behind the characters, but if that is good enough, then you need to RawSaveScreen in each player enters screen (before fade in) event, and in the repeatedly_execute function, RawRestoreScreen and draw any active emoticons.
Title: Re: in-engine "emoticons"
Post by: Sparky on Mon 12/02/2007 21:31:21
Thanks for the idea of using a character- it's much better than an object, because I can always move it to the current room.

I'm writing a global function, and I've hit a snag around the use of pointers. I apologize in advance, because I'm more of a visuals person than a programmer and have a less than adequate amount of scripting experience.

the global function looks like this:
function stormcloud(Character *target_person) {
cIcon.ChangeRoom(target_person.Room);
cIcon.x = target_person.x;
cIcon.y = target_person.y - 64;
// timer script will go here
}

In the room script I have this funciton call:
stormcloud(cBirdwoman);

When I compile I get this error: Error (line 43) wrong number of parameters in call to "stormcloud"

Line 43 is the function call I posted above. I suspect it's a pointer syntax problem. I've read through the wiki section on pointers, but there isn't enough detail in the part about using pointers as function parameters to help me here.

Title: Re: in-engine "emoticons"
Post by: Kweepa on Mon 12/02/2007 23:44:09
Looks reasonable to me.
What does the function declaration in the global script header look like?
Title: Re: in-engine "emoticons"
Post by: Sparky on Tue 13/02/2007 00:20:00
In the header I've got an import line: import function stormcloud();
Does that answer your question?
Thanks again for your assistance, I'm sure this is relatively simple but I'm just not sure what's going wrong.
Title: Re: in-engine "emoticons"
Post by: Ashen on Tue 13/02/2007 00:28:42
The import line for functions have to include the parameters (in this case, the Character pointer). Try:

import function stormcloud(Character *target_person);


However, I'm surprised it got as far as the function call before generating an error - when I do that it refuses to compile, with a 'Function declaration has wrong number of arguments' error. It almost reads like you've declared stormcloud without the Character parameter - although it's clearly there, leaving it out is the only way I can replicate your error. Odd, huh?
Title: Re: in-engine "emoticons"
Post by: Sparky on Tue 13/02/2007 02:36:03
Thanks Ashen, everything is working perfectly now.

At certain points in my effort to get this to work I did receive the "Function declaration has wrong number of arguments to prototype" error. I was fiddling with syntax quite a bit at the time of the post, it's quite possible I made changes after posting but before replying to SteveMcCrea.

Thanks again to everyone who replied, I'm happy to have this working. I think it will be a fun addition to the project I'm working on.
Title: Re: in-engine "emoticons" (working)
Post by: Khris on Tue 13/02/2007 03:12:39
You could add an enum to the header to avoid having a seperate function for every emoticon:
// header
enum Emoticon {
  Stormcloud,
  Smiley,
  Tear,
  Confused
};

import function ShowEmoticon(Character*target_person, Emoticon e);

// global script
function ShowEmoticon(Character*target_person, Emoticon e) {
  if (e==Stormcloud) cIcon.ChangeView(11);
  if (e==Smiley) cIcon.ChangeView(12);
  ...
  cIcon.ChangeRoom(player.Room, target_person.x, target_person.y-64);
  SetTimer(1, 80); // show for two seconds
}
export ShowEmoticon;