don't use a while loop, use a timer!

Since you mentioned lasers and a ship, I assume you're writing an action game of some sort. It's possible to write such a game without using a timer, but it doesn't make much sense.