qmax=1;qmin=0;ubar = 2;
(* najjednoduchsie *) f[q_]:= ubar*q;
(* burgersova rovnica *) g[q_]:= ubar*0.5*q^2;
(* traffic flow *) h[q_] := ubar*q*(1-q);
df[q_] := D[f];
plateau[x_] := (Sign[x+0.5]-Sign[x-0.5])/2;
spike[x_] :=-Abs[-x]+1;
Plot[spike[x],{x,-1,1}]

(**) gridCount = 20;
gridStart = -1;
gridEnd = 1;
gridStep = (gridEnd-gridStart)/gridCount;
grid = Table[i,{i,gridStart,gridEnd,gridStep}];

timeLen = 5;
(**) timeStep = 0.05;
result = Table[Table[0,{i,1,gridCount+1}],{j,1,timeLen}];

(* moznosti: f[a], g[a], h[a] *)
F[a_,b_] := f[a];(*Which[
(df[a]>0)&&(df[b]>0),f[a],
 (df[a]<0)&&(df[b]<0),f[b]
]*)

(* moznosti: plateau[x], spike[x] *)
q0[x_] := plateau[x];
result[[1]] = q0[grid];
For[i=2,i≤timeLen,i++,{
previous = result[[i-1]];
leftShift = Prepend[previous[[1;;gridCount]], previous[[1]]];
rightShift = Append[previous[[2;;gridCount+1]], previous[[gridCount+1]]];
result[[i]]=previous-(timeStep/gridStep)*(F[previous, rightShift]-F[leftShift, previous]);
}]

Animate[ListLinePlot[result[[j]]],{j,1,timeLen,1}]

?? Animate