[Add] Take into account outfit sprite size when creating outfit.
This commit is contained in:
		
							parent
							
								
									5e34b27baa
								
							
						
					
					
						commit
						d06e4a6383
					
				| @ -722,7 +722,7 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer, | ||||
|  */ | ||||
| static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2* pos, | ||||
|                              const Vec2* vel, unsigned int parent, const unsigned int target) { | ||||
|   Vec2 v; | ||||
|   Vec2 v, vp; | ||||
|   double mass, rdir; | ||||
|   Pilot* pilot_target; | ||||
|   double x, y, t, dist; | ||||
| @ -780,11 +780,15 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2* | ||||
| 
 | ||||
|     if((rdir > 2.*M_PI) || (rdir < 0.)) rdir = fmod(rdir, 2.*M_PI); | ||||
| 
 | ||||
|     /* Set the position to include sprite size. */ | ||||
|     vect_cset(&vp, pos->x + cos(rdir)*w->outfit->u.blt.gfx_space->sx/2., | ||||
|         pos->y + sin(rdir)*w->outfit->u.blt.gfx_space->sy/2.); | ||||
| 
 | ||||
|     mass = 1; /* Lasers are presumed to have unitory mass. */ | ||||
|     vectcpy(&v, vel); | ||||
|     vect_cadd(&v, outfit->u.blt.speed*cos(rdir), outfit->u.blt.speed*sin(rdir)); | ||||
|     w->timer = outfit->u.blt.range/outfit->u.blt.speed; | ||||
|     w->solid = solid_create(mass, rdir, pos, &v); | ||||
|     w->solid = solid_create(mass, rdir, &vp, &v); | ||||
|     w->voice = sound_playPos(w->outfit->u.blt.sound, | ||||
|         w->solid->pos.x + w->solid->vel.x, | ||||
|         w->solid->pos.y + w->solid->vel.y); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis