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.

Newcomers DBPro Corner / Code structure?

Author
Message
Mussi
21
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 9th Jul 2003 00:28
I'm making a FPS game with DBpro and what i want to ask if it really matters how you structure your code and if it does then whats the best structure you can have?
Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 10GB HD, Riva TNT2 Ultra 32mb
CrayZemon
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 9th Jul 2003 01:02
Code structure matters in a sense that it helps one to organize one's code. Structured code is easier to debug, and easier for "groups" of programmers to contribute to.

There are numberous ways to do so. Elementary examples include stuff like how you organize your loops:

for y = 1 to max
for x = 1 to max
paste image 1, x*64,y*64
next x
next y

gosub move_player

notice that throughout the for loops, their were indentations for each section of the loop. There was an outter loop: y and an inner loop: x. the move_player subcommand really has nothing to do with drawing the map, so I made sure their was at least a line between that and the for loops. This is just an elementary example.

Oh yeah, don't forget to comment the heck out of it!

"I need gopher-chucks!!"
CrayZemon
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 9th Jul 2003 01:04 Edited at: 9th Jul 2003 01:05
Rats, this forum's text boxes won't allow empty spaces at the beginning of the line. Therefore, my example is all botched up! Hopefully it looks correct in a code snippet.



"I need gopher-chucks!!"
Mussi
21
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 9th Jul 2003 01:22
so putting your code in a different order doesn't affects the performance?

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 10GB HD, Riva TNT2 Ultra 32mb
CrayZemon
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 9th Jul 2003 04:48
Actually it does. Any computer language performs the code in the order that you type it out. Structured coding is merely a way of typing out the code so that it is readable and easily understood/adjusted/changed by you or another person who knows what he's doing.

"I need gopher-chucks!!"
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 9th Jul 2003 06:57
Look at it this way. A computer is like a person in a grocery store. Say you want to go buy some cheedos, your going to go look in the chips section, right? Well if your code is all out of order, those cheedos may be in with the ice cream. Now, you would never look there! It would take you a while to find those cheedos! Thats what the computer does with code. Making organised code helps the computer find out where to go to find the cheedos,,,um I mean code

Hope that helps

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!
Mussi
21
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 9th Jul 2003 13:41
thnx a lot guys, i finaly understand

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 10GB HD, Riva TNT2 Ultra 32mb

Login to post a reply

Server time is: 2024-11-24 22:49:17
Your offset time is: 2024-11-24 22:49:17