Hi there my friend. I think you've just experienced Hypnagogic imagery/hallucinations, it's a natural visual pattern that appears when we try to sleep. It's main purpose is to induce a person to sleep. But a person doesn't just experience it visually, it can also hit any of our 5 senses, which also explains the gun shot you've experienced. Hope this helps