Skip to content

Commit

Permalink
TGS Test Merge (#6821)
Browse files Browse the repository at this point in the history
  • Loading branch information
cm13-github committed Aug 2, 2024
2 parents c7fb629 + f8fca5f commit 3a71f04
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,14 @@

//Change the bullet angle to its visual path

var/mutable_appearance/new_appearance = new(appearance)
new_appearance.invisibility = invisibility
new_appearance.plane = plane

var/vis_angle = delta_to_angle(pixel_x_target - pixel_x_source, pixel_y_target - pixel_y_source)
var/matrix/rotate = matrix()
rotate.Turn(vis_angle)
apply_transform(rotate)
new_appearance.transform = rotate

//Determine apparent position along visual path, then lerp between start and end positions

Expand All @@ -326,25 +330,22 @@

//Set pixel offset as from current loc to old position, so it appears to start in the old position

pixel_x = (start_turf.x - current_turf.x) * world.icon_size + start_pixel_x
pixel_y = (start_turf.y - current_turf.y) * world.icon_size + start_pixel_y

//Determine apparent distance travelled, then lerp for projectile fade-in

var/dist_current = distance_travelled + speed * (time_carry * 0.1) //speed * (time_carry * 0.1) for remainder time fade-in
var/alpha_interpolant = dist_current - 1 //-1 so it transitions from transparent to opaque between dist 1-2
var/alpha_new = LERP(0, 255, alpha_interpolant)
new_appearance.pixel_x = (start_turf.x - current_turf.x) * world.icon_size + start_pixel_x
new_appearance.pixel_y = (start_turf.y - current_turf.y) * world.icon_size + start_pixel_y

//Animate the visuals from starting position to new position

if(projectile_flags & PROJECTILE_SHRAPNEL) //there can be a LOT of shrapnel especially from a cluster OB, not important enough for the expense of an animate()
alpha = alpha_new
pixel_x = pixel_x_rel_new
pixel_y = pixel_y_rel_new
return
appearance = new_appearance

var/anim_time = delta_time * 0.1
animate(src, pixel_x = pixel_x_rel_new, pixel_y = pixel_y_rel_new, alpha = alpha_new, time = anim_time, flags = ANIMATION_END_NOW)
if(alpha < 255) //Determine apparent distance travelled, then lerp for projectile fade-in
var/dist_current = distance_travelled + speed * (time_carry * 0.1) //speed * (time_carry * 0.1) for remainder time fade-in
var/alpha_interpolant = dist_current - 1 //-1 so it transitions from transparent to opaque between dist 1-2
var/alpha_new = LERP(0, 255, alpha_interpolant)

animate(src, pixel_x = pixel_x_rel_new, pixel_y = pixel_y_rel_new, alpha = alpha_new, time = anim_time, flags = ANIMATION_END_NOW)
else
animate(src, pixel_x = pixel_x_rel_new, pixel_y = pixel_y_rel_new, time = anim_time, flags = ANIMATION_END_NOW)

/// Flies the projectile forward one single turf
/obj/projectile/proc/fly()
Expand Down

0 comments on commit 3a71f04

Please sign in to comment.