Well, it depends on what you mean by "gun". There are medieval representations of things that look much like guns around the time there are things that look like cannon. But it's not quite enough to have something that is "gunoid" in a picture. Small arms we now assume to be aimed, and these were not capable of that. The gunpowder made in the first hundred years or so ( in the 14th.c.) was not very consistent, because they hadn't worked out how to manufacture consistent stuff: they especially hadn't worked out how to refine saltpeter. Without consistent gunpowder, accuracy was impossible: it was hard to predict whether a ball would come out fast, or slow, and so the point of impact varied a lot. For a cannon, that's not as critical: a cannon can shoot at a castle wall, because with a target so big , accuracy is not too important. Thus you find that cannon ( like Mons Meg and Dulle Griet) were big tubes with a small, strong combustion chamber in the back, and their carriages were simple things that couldn't be aimed carefully. Likewise small arms circa 1350 were basically hand cannon: simple things mounted on poles and pointed at a large target, like a mass of soldiers. By sometime early- mid 15th century, however, enough had been discovered about manufacturing gunpowder ( especially refining saltpeter) that there was a point to aiming a gun, because it was possible to predict where the ball would hit. Cannon became stronger, longer thinner tubes with carriages that allowed for better aiming, and hand-cannon tuned into shoulder arms, with stocks and sights for aiming. By the late 15th c. there were guns used for hunting, and even rifles appeared.