I started learning C++ 10 months ago, when I figured that there is no any programming in high school program. After 5 months of learning syntax and solving various beginner exercises I started working on my first (and only) project.
It was just a simple 2D RPG for "young programmers contest". It took me 2 months to finish it. Ofcourse, it failed it purpose as it wasn't accepted to national level (keep in mind that I live in very small country).
After contest, I noticed that my code is ugly as hell. So I started re-writing whole thing. Every few days I would notice that new code was still ugly/inefficient, so I would rewrite it again.
Today, after 3 months and hundreds of rewrites later, with 50% smaller .exe, running in handful of RAM and loading stuff in much less time I still notice how my code can still be better!
So I just got sick of it and wondered: Do I suck at programming? Why the hell I need more than 5 months to write good code for such a small project (3.5k lines). And that good code will become bad code in few days, when I realise that there is a better way to write that. Looking at some other indie games on Github, I notice that they don't make such mistakes and never rewrite the code every few days. And worst part is, from users point of view, my game hasn't changed a slighest bit! I'm not adding anything new, just fixing old mistakes.
What should I do? Do I need to read a book on design? Scrap this project and try something new? Or I just suck at this?
Generalising your entire knowledge of programming down to "sucking" is quite a poor evaluation of yourself. In my opinion, no-one is bad at anything; people simply lack the knowledge of the subject in hand.
Initially, I thought bad design was the cause. A bad design leads to bad code, if I'm honest. Here's what you could do: Re-design your game. Convince yourself why data-structure X would be the beneficial option in scenario Y. Make use of charts, diagrams, et cetera. When you feel the plan is solid, begin developing it.
Though, multiple failed attempts would cause the project to go stale. I recommend either creating a new game based on the existing project, or, creating a new game based on an entirely new idea.
@Catfish2
Untill now, I never felt that it was a torture, infact, it was quite fun.
However, today I came to conclusion that can probably never make this program (really) perfect (thus this topic was created.)
@Framework
I guess you're right. I do lack knowledge (and maybe practise, as rapidcoder says). But I'm not sure where to gain it(do I need advanced book? On what topic?)
I think I'll start new project based on this one. Maybe turn it into orpg.
RPGs are deceptively hard. Making it online will only complicate matters further.
As for sucking at programming? You're on the right track to doing exactly what you should to improve your skills. I'd say if you're burned out on this project you should set it aside for a while and go pick up something else, maybe check out someone else's code for a similar project (reading another's code is a good way to learn too).
I wouldn't worry about it too much. I've started a lot of projects with a few hundred or thousand lines of code each and then left them, or else deleted them, because I got bored. Be glad that you're such a perfectionist for one thing, and for another, be glad that you don't change projects as often as I do.
@xander
I thought making it orpg would be good idea because I would base it on old code and this time avoid some huge design mistakes I made. But yeah, I agree, it would surely make things more complicated.
@others
Thanks. Reading your replies made me think that I am actually not that bad :)
@Krofna:
same experience here mate. I think I have rewritten every single line of code I ever produced, and lots of it is still crap. 3.5k lines of code may be a small project, but 3.5k lines of *good* code is not that easy at all.
Plot down on paper how you plan to structure your code. Do this before ever touching your computer. And once you start actually programming it, keep it in mind to organize your code and keep it from being ugly. Having a conscious effort in doing this will eventually translate to a subconscious effort and it will come naturally to you.
That being said, you're already at a more advanced level than me. I'm just getting started with graphics programming.
Thanks guys. Its nice to know that I'm on right track.
@Smalltock
I also thought that would be good idea, so i planned before I started working on new project (this time, orpg). Though, it proved to be very ineffective. After few days of planning, 2 days into coding, I ran into some problems I couldnt possibly predict!
For example, I still fail to understand how to make use of multithreading. When I was planning program, I knew I will need it, and what for, but in practise, it breaks stuff!
Don't you love planning? This is why things such as agile planning have came around. People started to realize that you can spend 6 months planning a project, but then when you get to programming a ton of unforeseeable problems arise.
The multithreading issue just comes with experience and researching multithreading. Contrary to what you may think, you don't need threading at all. Games managed without it for quite awhile.
There is no set standard for good or bad so I think you are just being hard on yourself. Everyone learns at a different pace and if you think you are bad now then you will just see room for improvement in different areas. Nothing to worry about though.