I think you more or less answered your own questions - make a plan!
Without a plan, the only goal you have is your rather blurry idea of the final product. And that goal is so distant, and the road there unclear, that the goal will feel like it is unreachable which has the effect that you lose motivation.
Instead try to set the scope from the beginning. Make a plan where you specify your v1.0 of the project and what it should include (this is to avoid feature creep during development). Make sure to start small and get things done rather than aim too big and never finish anything (you may always release a v1.1 later).
Then set smaller (reachable) subgoals where you implement a subset of the features. Having these subgoals assures you always have a milestone not too far away, which makes you more motivated to reach it. And for each milestone you get the feeling of accomplishment and actually moving forward to the final goal.
When setting these goals, make sure they are clear and non-ambiguous, otherwise you will not reach them and get that sense of accomplishment. Having a goal like "the gui should feel fast" is typically bad, since then you will get stuck in optimizations and never feel it is "fast enough".
And remember, the last 10% does usually take 90% of the time - so hang in there!