Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Wed 07/12/2016 10:45:01

Title: Scaling bullet issue
Post by: Slasher on Wed 07/12/2016 10:45:01
Slightly off cuff but still on the object of Scaling.

This happens in both d3d and DD...

Say the player has a gun. The gun fires a bullet (object) positioned at players x y to place its position on the gun barrel (rep always). The player can shoot out these bullets and we see it zoom across the screen. This is ok except for if you are on scaling walkable area then the bullet related to players x y gets thrown out of the window...

Has this ever been looked into?

Title: Re: Scaling bullet issue
Post by: Crimson Wizard on Wed 07/12/2016 11:12:37
I had to move this question into separate thread, because it was completely off-topic where it was originally posted.

Title: Re: Scaling bullet issue
Post by: Khris on Wed 07/12/2016 12:41:32
The offset from the character's pivot simply has to be scaled along with the character.
Which means you need to multiply it by the character's current scaling level, then divide it by 100.

  int sc = GetScalingAt(player.x, player.y);
  // calculate offset based on loop and scaling
  int ox = ((player.Loop == 2) - (player.Loop == 1)) * 30; // facing left: -30, facing right: 30
  ox = (sc * ox) / 100;
  int oy = (sc * -80) / 100;
  // position bullet
  oBullet.X = player.x + ox - Game.SpriteWidth[oBullet.Graphic] / 2;
  oBullet.Y = player.y + oy + Game.SpriteHeight[oBullet.Graphic] / 2;


(Assuming your bullet sprite used transparent borders to align it, you need to crop it.)