Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Being a code mechanic is fun!

Author
Message
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Mar 2010 21:22
I've found that taking other people's code and modifying it can be just as rewarding as making your own programs (especially if the code was badly written to start with). You might think I'm crazy willingly taking on spaghetti code but it is really satisfying when you come out with something that works well and is better structured to allow you to add your own ideas to the program.
I think I understand why people who renovate old sports cars love it so much.

I've also learned some things that will help with my own programs.
For instance, writing as many remarks as possible helps, even if it is obvious what a piece of code does.
My coding process is to write code inside the main loop until I see a block that I can turn into a function or subroutine. Commenting on what each bit of code does makes it easy to find blocks you can turn into subroutines or functions.

There was something else I learnt but I've forgotten what it was.

I stumbled across a charming little game called Bounce, written by Databug, and I have been tinkering with it since yesterday.
Here is the original code:


As you can see it is pretty messy and doesn't use a single subroutine or function! Everything is crammed inside the main loop. There are lots of loops here and it was quite a job to untangle them but here is my effort so far:

I haven't added any new features yet, it should work exactly the same as the original.

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 25th Mar 2010 22:18
Quote: "There was something else I learnt but I've forgotten what it was."


Did you learn to write stuff down but forgot to write it down?

I think being able to read, understand and modify other people's code is an important part of being a good programmer. It's a good way to learn coding as you don't have to worry about coming up with a game idea because someone's already done that for you. Also, if all you want to do is a bit of coding then it's good for the same reason.

It's also nice to have other people modify your own code, because you have knowledge of the basic idea but then someone gives you a better way of implementing it, like you did for Ashingda 27 with his (her's?) triangle collision check code and what Latch did for me with my make box function.
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 25th Mar 2010 22:40 Edited at: 25th Mar 2010 22:43
Yah not only you yourself but the original coder could benefit from it. But it sure is tough taking on spaghetti codes, I've done very few and never want to do it again!

Quote: "
his (her's?) "

It would be "his"
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 26th Mar 2010 22:51
Quote: "It would be "his""


I didn't want to presume
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 2nd Apr 2010 04:23 Edited at: 2nd Apr 2010 04:23
Quote: "he? "

Reminds me of something else that zeus and obese87 would know about...........Anybody remember geek culture and "girlfriend # 2"? ROTFLMAO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 3rd Apr 2010 16:33
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 3rd Apr 2010 17:19
What made it funny was when you somehow stuck in that "he?" at the end, LOOL.

(\__/) HHAHAHAHAHAH!
(O.o ) / WORLD DOMINATION!!!!!!!!!!
(> < )

Login to post a reply

Server time is: 2024-03-29 05:00:57
Your offset time is: 2024-03-29 05:00:57