  Gamma-ray spectroscopy provides diagnostics of particle acceleration in solar
flares, but care must be taken when interpreting the spectra due to effects of
the angular distribution of the accelerated particles (such as relativistic
beaming) and Compton reprocessing of the radiation in the solar atmosphere. In
this paper, we use the GEANT4 Monte Carlo package to simulate the interactions
of accelerated electrons and protons and study these effects on the gamma-rays
resulting from electron bremsstrahlung and pion decay. We consider the ratio of
the 511~keV annihilation-line flux to the continuum at 200~keV and in the
energy band just above the nuclear de-excitation lines (8--15~MeV) as a
diagnostic of the accelerated particles and a point of comparison with data
from the X17 flare of 2003 October 28. We also find that pion secondaries from
accelerated protons produce a positron annihilation line component at a depth
of $\sim$ 10 g cm$^{-2}$, and that the subsequent Compton scattering of the
511~keV photons produces a continuum that can mimic the spectrum expected from
the 3$\gamma$ decay of orthopositronium.
