I find that the best way to motivate yourself is to really get stuck in and get your teeth into the project. You may find that if you've not worked on it for a while, you'll find it hard to get back into, but once you're in it, you'll keep wanting to work on it. The idea is to keep this momentum going, because if it stops, it can be harder to re-start it than to keep it going.
Also, having other people in your team (be it artists, musicians, level-designers or even other programmers) can help motivate you, as every time someone else produces a new asset, you get to see your project move forward, and this inspires you to do some more work, which in turn inspires the other people, crating a positive feedback mechanism. However, if someone on your team keeps trying to bring you down by saying that your project is going to fail, throw them off the team ASAP (although you should ask yourself if they really are right, but if after your rationally-thought-out analasys of their comments you still disagree with them, give them the old heave-ho).
As many others have said, divide your project into a large TODO list and gradually cross out the tasks that have been done. No matter how tedious the tasks or how overwhelming the size of the TODO list is, each time you cross off an item, you feel like you've accomplished something. When you're stuck on something or just not sure what to do next, find the smallest tasks you can find on the TODO list and do as many of them as you can in one coding-session.
Also as others have suggested, create several milestones and ask for feedback. However, if you create toomany public-releases, some people might get fed up with being bombarded by incomplete projects. What I suggest you do is to divide the project into "Major milestones" with a fixed set of tasks completed for each milestone, and post them to all your friends, and the allegro.cc depot-forum. If you get any feedback about bugs or features that can easily be imlemented quickly, then release an update to your project. That way, whoever's testing it will see that you care about the users, but be realistic and only implement the features that can be quickly done or don't take the project into a direction it was not meant to go in. Then, there's "minor milestones" where you've just implemented several new features and you want someone to try them out. With those, just send them to the people on your team and the people who have shown the most interest in the project. And if you're working in a team, you can send the other teammates "sub-minor milestones" when you've implemented a feature that will aid the develoment of their contribution to the project.
Thomas Fjellstrom said:
Personally I'd reccomend a nice dose of death metal.
I hate the screaming. And the entire three notes they play on their instruments. Basically I want something that doesn't distract me from what I'm doing.
Personally, I recommend early 80's synth-pop (such as Jean Michel Jarre, Kraftwerk, Hipnosis or to a lesser extent, Koto). Anything with no vocals means less room for distraction. With vocals, your brain is trying to comprehend their meaning (both what is being said and the deeper meaning), and without vocals, the music just sooths you. If you can find it, I would recommend getting hold of an album called Synsation (AKA Inter Synthellite (sp?)) that was released some time in the early-mid 80's. It consists of two medleys of classic synthesizer hits and no lyrics whatsoever (medley #1 starts with a song called Synsation Zero (or Synsation 0) and medley #2 ends with a song called Synsation One (or Synsation 1)).
And finally, I find that I'm the most focused if I keep regular sleep-wake hours. That is, I wake up the same time every day and go to bed the same time every day as well, while giving myself adequate time to sleep. If you get this rythm engraved into your system, the occasional late night out on the town or late night coding-session can easily be absorbed. Save all-nighters for those times when you're really close to a deadline or major-milestone, as usually, you may be a bit disoriented the following day, so it's best to get what you were doing out of the way.
But most importantly, have fun. 'Fun' is a fundamental component of all games, and therefore, you should have fun while develoing the game. Of course, game development does contain those tedious or hard moments where you really wish you were somewhere else, but when you complete them, you'll be glad you did.