most themes use standard codex scripts. You can look at the codex until you go blind because very little of it will be meaningless unless you have a theme open in front of you.
My suggestion for writing your first theme is find a style you like i.e. header, footer and sidebars where you like them. Then start dissecting them to see what each part does. Then do another and another of similar styles. Compare each function and how they work, then look at the options in the wp codex for each function and play with them one at a time.
Don’t worry too much about stepping on people’s toes when it comes to theme building. Don’t claim work that isn’t yours, but know that if you have reordered the functions, changed the colors, and gave it new graphics it is no longer someone else’s theme, it is yours. If you can find your code in the codex or in any list of css styles, then it is yours to use. Anyone who wants to get high handed and claim public code as their own needs to be smacked. The code arrangement may be your work, but the code itself belongs to everyone.