Scaling bullet issue

Started by Slasher, Wed 07/12/2016 10:45:01

Previous topic - Next topic

Slasher

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?


Crimson Wizard

#1
I had to move this question into separate thread, because it was completely off-topic where it was originally posted.


Khris

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.

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

SMF spam blocked by CleanTalk