v=1;
L=10;
S=5;
H=3;

f[z_]:=If[#<S,H#/S,H(2L-#)/(2L-S)]&[Mod[z,2L]]

Plot[f[z],{z,-4L,4L},AspectRatio->.2,Axes->{True,False},PlotRange->{-H,H},PlotStyle->Directive[Red,Thick]]

s[x_,t_]:=f[x+v t]-f[-x+v t]

wave=Table[Plot[s[x,t],{x,0,L},AspectRatio->.3,Axes->{True,False},PlotRange->{-H,H},PlotStyle->Directive[Red,Thick],ImageSize->600],{t,0,2L,.2}];

slinky=Table[Plot[Sin[50(x-s[x,t])],{x,0,L},AspectRatio->.05,Axes->False,PlotRange->{-1.1,1.1},PlotStyle->Directive[Black,Thickness[.002]],ImageSize->600],{t,0,2L,.2}];

ListAnimate[wave,10.]

ListAnimate[slinky,10.]