in-engine "emoticons" (working)

Started by Sparky, Mon 12/02/2007 00:11:14

Previous topic - Next topic

Sparky

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

  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?

Khris

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

Kweepa

#2
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.
Still waiting for Purity of the Surf II

Sparky

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

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

	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.


Kweepa

Looks reasonable to me.
What does the function declaration in the global script header look like?
Still waiting for Purity of the Surf II

Sparky

In the header I've got an import line:
Code: ags
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.

Ashen

The import line for functions have to include the parameters (in this case, the Character pointer). Try:
Code: ags

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?
I know what you're thinking ... Don't think that.

Sparky

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.

Khris

You could add an enum to the header to avoid having a seperate function for every emoticon:
Code: ags
// 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;


SMF spam blocked by CleanTalk