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 / good undersatandable code for beginers!!!!!

Author
Message
Gamer Making
19
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 4th Nov 2006 03:14
heres a code if it doesnt work tell me:



Bach Tran
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 4th Nov 2006 03:46 Edited at: 4th Nov 2006 03:50
lets take a look and see whats right and wrong.

Quote: "
sync rate 20
sync on
"


the actual rate you have chosen is probably too slow for a 3d application.
usually 30 or 60 is chosen for smoother looking animations.


Quote: "
make object cube 1,100
"


you have made a cube at 100 units, and relying on Darkbasic to use the auto camera pointing to visualize the object, your also relying on darkbasic to place it at world center 0,0,0


Quote: "
do
hide object 1
if mouseclick()>0
show object 1
sync
loop
"


you have created in infinte loop that will never end.
within this loop every cycle your using the hide command.
this means even if it is hidden your asking it to be hidden again.


your using an if statement without an endif tag thats essential for use together

your using a operator to say if mouseclick is greater then zero where as you could use a simpler operator to say if mouseclick = 1 : perform action ; endif

closing your loop and adding sync at the end is correct however when you terminate your program or want to restart your game there is no clean up.

a good loop breaker is the while endwhile command tags used in unison




and then when you press escape it will escape from the loop, delete your object and end your program.


clearly a bad example that wouldnt run due to the endif error.
time to learn some more before posting stuff your not focusing on.

however dont let that stop you from learning new commands, just make sure your focusing on what your doing.

Lucifer
20
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 4th Nov 2006 03:51
Quote: " good undersatandable code for beginers!!!!!"


what!!? i dont understand, whats "make object"?



One is the lonliest number...
Gamer Making
19
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 4th Nov 2006 04:08
Thanks indi.

Bach Tran
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 4th Nov 2006 10:12
good luck with your learning process. take care.

Gamer Making
19
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 4th Nov 2006 16:08
indi I still have a question can this work:

sync on : sync rate 30

make object cube 1,100
position object 1,0,0,0
do
hide object 1
if mouseclick()=1
show object 1
endif
sync loop

Bach Tran
Gil Galvanti
21
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 4th Nov 2006 16:55
It works, but doesn't fix all the problems indi was talking about .
Quote: "sync on : sync rate 30"

as far as I know, you don't need to turn sync on at all if your using sync rate, because it's automatic.

You should also add "autocam off" at the top, and position the camera manually, like, "position camera 0, 150, 0".

Quote: "hide object 1
if mouseclick()=1
show object 1
endif"

you should put "hide object" into an if...endif statement so it only hides if your not clicking the mouse, like:


also, I don't think you need to put in "sync", because it automatically does that with "sync rate" .

Pirates of Port Royale
Live the life of a pirate.
RUCCUS
21
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 4th Nov 2006 17:04 Edited at: 4th Nov 2006 17:05
Yes you have to put in sync, otherwise it'll sync everytime a 3D object is manipulated. Thats the reason for turning sync on. Though IIRC, sync must be on it's own line to work. You should also practise good indentation, otherwise you'll get very cluttered, ugly code;



Your signature has been erased by a mod because it's larger than 600x120...
Gamer Making
19
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 7th Nov 2006 23:41
indi has the coolest code ever!

Bach Tran
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 8th Nov 2006 00:18
thanks mate, you should listen to the others as well, they are really trying to help and explain it.

Mr Tank
23
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 9th Nov 2006 23:02
A lot of these "mistakes" i do too. If reliance on autocam and objects initially being located at the origin works, then why not take advantage of this?

Also, is there really an advantage to "cleaning up" and deleting stuff before closing the program?


You'll be able to click on this someday.
RUCCUS
21
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 9th Nov 2006 23:31
IIRC DBP wipes all data when the program ends (it didnt before though), but I might be wrong.

Even if it does, its a good habit to get into, as when dealing with higher end languages like C++, it wont do you any favours, you'll have to delete it manually.

Your signature has been erased by a mod because it's larger than 600x120...

Login to post a reply

Server time is: 2026-07-07 00:09:53
Your offset time is: 2026-07-07 00:09:53