Author Topic: Display an icon over a character (SOLVED)  (Read 389 times)  Share 

alkis21

  • AGS rocks
  • alkis21 worked on a game that was nominated for an AGS Award!
Display an icon over a character (SOLVED)
« on: 03 Aug 2006, 10:57 »
On some occasions, I want to have an animated object (a lightbulb) displayed briefly a few pixels over a character.
I thought it would simply be a case of displaying the object at player.x, player.y-... But this idea does not work in rooms with scalable walking areas, for obvious reasons: when the character is at 80% zoom, the object appears a few pixels above him, but if he's at 60% zoom it appears way above him.
Any ideas on how to solve this?
« Last Edit: 04 Aug 2006, 21:35 by alkis21 »

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: Display an icon over a character
« Reply #1 on: 03 Aug 2006, 11:22 »
Something like below (you may need to figure out the true values though) ?

object[5].Y = cEgo.y - ((cEgo.Scaling * 30)/100);

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    •  
  • SSH worked on a game that was nominated for an AGS Award!
Re: Display an icon over a character
« Reply #2 on: 03 Aug 2006, 14:25 »
Make a new character view with the lightbulb? You could have the character look pensive then lightbulb appears then character looks happy...

alkis21

  • AGS rocks
  • alkis21 worked on a game that was nominated for an AGS Award!
Re: Display an icon over a character
« Reply #3 on: 03 Aug 2006, 19:42 »
Make a new character view with the lightbulb? You could have the character look pensive then lightbulb appears then character looks happy...

I tried that too, but the result was not satisfactory because the object looked zoomed out as well.
I'll try Gilbot's suggestion, it sounds like it will take me some time to get it right but it sounds doable.

Ashen

Re: Display an icon over a character
« Reply #4 on: 03 Aug 2006, 22:30 »
What about:

[code]
function GetScale() {
  int aHeight = GetGameParameter (GP_SPRITEHEIGHT, GetGameParameter (GP_FRAMEIMAGE, player.View, player.Loop, player.Frame), 0, 0); // Add an amount here ('aHeight = GetGame........... + 5') to have it a scaled amount above his head
  float pScale = IntToFloat(player.Scaling)/100.0;
  pScale = pScale*IntToFloat(aHeight);
  return FloatToInt(pScale);
}

...

object[5].Y = player.y - GetScale(); // Or 'player.y - (GetScale() + 5)' to have it a fixed amount above his head
[/code]

The float is used for accuracy - you could try it with an int, but I'm not sure how it'd turn out. Probably not very well, I think it'd always return the normal, 100%, height or 0.
« Last Edit: 03 Aug 2006, 22:32 by Ashen »
I know what you're thinking ... Don't think that.

alkis21

  • AGS rocks
  • alkis21 worked on a game that was nominated for an AGS Award!
Re: Display an icon over a character
« Reply #5 on: 04 Aug 2006, 21:35 »
Thanks Ashen, your suggestion worked as usual.
By the way, I added

[code]import function GetScale();[/code]

in the Script Header, that was what I was supposed to do, wasn't it?

Ashen

Re: Display an icon over a character (SOLVED)
« Reply #6 on: 07 Aug 2006, 12:34 »
Only just seen this, but I'll post for completeness:

It depends. If you want to be able to use GetScale() in room scripts, then yes, you need to import it in the header. If you just need to use it in the Global Script, called in rep_ex(_always) (which I assumed was the case), then you don't NEED to import it, but it does no harm.
I know what you're thinking ... Don't think that.

alkis21

  • AGS rocks
  • alkis21 worked on a game that was nominated for an AGS Award!
Re: Display an icon over a character (SOLVED)
« Reply #7 on: 07 Aug 2006, 19:57 »
That's what I thought, cheers. I do want to use it in room scripts.