Author Topic: sprite template "ShootInRange"  (Read 4055 times)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
sprite template "ShootInRange"
« on: 2008-03-12, 03:09:30 AM »
this is abouts durnurds sprite template. i found one thing that may be worked over.
the range in which the player must be to activate the shooting script, is calculated so:
System.Math.Abs(this.x-(ParentLayer.m_SpriteCategories.Player[playerIdx]).x)
this works well with small sprites. the center point of this calculation is x of the sprite, not its center. but the bigger the sprite, the more the range is shifting (optically) to the left.

i tried to fix it, but i failed. this was my script:
System.Math.Abs(this.x+this.SolidWidth/2-(ParentLayer.m_SpriteCategories.Player[playerIdx]).x)
maybe this could be fixed and the sprite template be updated. that would be nice.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: sprite template "ShootInRange"
« Reply #1 on: 2008-03-12, 04:58:46 AM »
Did you try this?
System.Math.Abs(this.x-(ParentLayer.m_SpriteCategories.Player[playerIdx]).x +
   (this.SolidWidth - (ParentLayer.m_SpriteCategories.Player[playerIdx]).SolidWidth) / 2)

Tanja

  • Clever
  • Fanatic
  • ***
  • Posts: 606
    • View Profile
Re: sprite template "ShootInRange"
« Reply #2 on: 2008-03-12, 11:24:15 AM »
seems to work the right way! thanks.
System.Math.Abs(this.y-(ParentLayer.m_SpriteCategories.Player[playerIdy]).y +
   (this.SolidHeight - (ParentLayer.m_SpriteCategories.Player[playerIdy]).SolidHeight) / 2)


so, this would work to determine the right vertical range, wouldn't it? (i do not completely understand what is standing there, i only changed x and width.  :laugh:)
of course the sprite must have a parameter called playerldy then, and use it.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: sprite template "ShootInRange"
« Reply #3 on: 2008-03-12, 11:27:39 AM »
You may have gotten a little trigger happy with find/replace there.  Not that it's a problem, but Idx stood for "Index" which has nothing to do with the x coordinate of the sprite.
Edward Dassmesser