Clear[s, im1, im2, im3, im4, f]
s[x_] := 
      If[1 ≤ x < 2, x - 1, 
        If[2 ≤ x ≤ 3, 3 - x, 
          0]]
im1[x_] := 
      If[-3 ≤ x < -2, -3 - x, 
        If[-2 ≤ x ≤ -1, x + 1, 
          0]]
im2[x_] := 
      If[9 ≤ x < 10, 9 - x, 
        If[10 ≤ x ≤ 11, x - 11, 
          0]]
im3[x_] := 
      If[-11 ≤ x < -10, 11 + x, 
        If[-10 ≤ x ≤ -9, -9 - x, 
          0]]
im4[x_] := 
      If[13 ≤ x < 14, x - 13, 
        If[14 ≤ x ≤ 15, 15 - x, 
          0]]
f[x_] := (1/2) (s[x + t] + s[x - t] + im1[x + t] + im1[x - t] + 
            im2[x + t] + im2[x - t] + im3[x + t] + im3[x - t] + im4[x + t] + 
            im4[x - t])
Table[
      Plot[f[x], {x, -20, 40}, 
        PlotRange -> {{-12, 20}, {-1.5, 1.5}}, 
        AxesLabel -> {"x", "u(x,t)"}, 
        PlotStyle -> {RGBColor[1, 0.6, 0], Thickness[0.015]}], {t, 0, 
        20, 0.1}]