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 / Final Project in Beginner's Guide to Dark Basic

Author
Message
VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 11th May 2012 20:51 Edited at: 17th May 2012 19:47
Hello fellow Gamers!

I have just finished the final project from the Beginner's Guide to DarkBASIC book. It took awhile but I finally finished coding it. However I have a few errors and I don't understand why they're being called. If someone could help that would be great. Thank you.
It is 1369 lines long, so it will probably be easier to try and do correct through using a coder.



EDIT LOG (5/15/12):
Thanks for that MrValentine.
I changed it like you suggested.

EDIT LOG (5/15/12):
Thank you 29 games for spotting those errors.
I still learning about DarkBASIC and video game development. I know that's no excuse for my typos though. I implemented the changes you highlighted and it seems to run but then it hangs up at the line in the code I marked kinda of like you did. What's puzzling me though is that the line of code that it is calling a syntax error at, the line of code is commented out.

EDIT LOG (5/17/120:
Okay, I think I almost have it. I figured out the problem with that last syntax error. (I'm an idiot for not noticing that I missed line of code. Have to implement the steps that nonZero suggested) Anyways...I put in the piece of code I missed, but now another syntax error is occurring. I've tried to take out the line of code that is causing the error, but that only causes another error to occur a few lines down. I will add my code that has the correction suggested earlier as long with a section on where the error is occurring.

Code where error is occurring.


When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!

Attachments

Login to view attachments
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th May 2012 21:36 Edited at: 11th May 2012 21:37








EDIT

Someone has already told you to enclose your code in the CODE blocks...

place [CODE] before and [/ CODE] without the space after all your code...

nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 11th May 2012 21:46


You really need to use these. Optional "lang=dbp" to highlight dbpro commands. As for your code, it needs to be indented to make it more legible.

VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 14th May 2012 19:10 Edited at: 17th May 2012 19:47
Ignore this post...

When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 14th May 2012 21:04
Hey VGHero11 you can go back to your first post and at the end of it on the left you will find an edit button... Well text...then place the code into it also an EDIT log to tell future readers whata changed is helpful this is also optional... I just feel it helps future readers to know whats changed...

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 15th May 2012 03:35
The good news is, after about forty minutes of trying to compile and subsequently editing your code (litterally just pressing F4 and seeing what syntax error was highlighted next), I managed to get your code to compile. The bad news is that I have no idea if it will actually run (I've not downloaded the media) and to be quite honest it's all been a bit of a nightmare. But here is your edited code:




Where I've changed something I've put "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" followed by a brief note of what I changed. Where I've written "was written incorrectly" it means that what you wrote was incorrect and I've changed it to what's there now (this was normally array variable been written incorrectly and thus not matching the array as declared.

For example: you have an array declared as "carinfoCarObjectNumber" but mispell this as "carinfoObjectNumber" missing out the word "car" before "objectnumber" (this happened quite frequently). Another example: line 39 where you have "projectileObjecsSpeed(30)" it should have been "projectileObjectSpeed(30)". You have put an "s" instead of a "t" in the word "object".

I appreciate that you did a lot of typing but you really need to pay attention to this sort of detail. Did you write the whole thing before trying to compile it or did you compile it once you finished each section? I generally compile and run my code when I complete each section (which is generally no more than a hundred lines at a time), this makes it easier to debug, even when the length get to many thousands of lines. I don't know if the structure of the tutorial allow you to do it this way or whether you dived in at the end.

As I said, I haven't run the code so I don't know if it'll work but at least it should now hopefully do something.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 15th May 2012 12:24 Edited at: 15th May 2012 12:26
Ah, I see 29 games hath beaten me to it...

Well, here's my fixes anyway. I dunno if it will run coz your media references don't match the file structure of your media archive and I can't mess around with that (I have mountains of work of my own. You'll find an error log at the top mentioning errors and changes.



I have made many assumptions but got it working to the point where if I press F4 it works.In otherwords the code compiles. What it deoes is anybody's guess.

Quote: "to be quite honest it's all been a bit of a nightmare"

I think that's an understatement - the 99th circle of hell perhaps.

But yeah, what 29 games said is right. VGHero11, you need to revise the entire way you code, especially if you intend to do large projects or any team work.
Here are some suggestions for future endeavors:

Firstly:
      INDENT YOUR CODE CODE (DOUBLE INDENT IF YOU USE UPPERCASE).

2. Never ever ever ever share variable names, ie var, var$, var(10)
3. Don't use naming conventions that cause typos if you make many typos yourself. Using an underscore may help make variable legible.
4. The best way to name your variables is the Hungarian naming system. For DBPro, I use my own derivative:

This lets you know just by looking at it, exactly what it is and what it's for. Locals aren't that important because they're bound by the function/module's scope so they are easy to track and you know they are local because they are without prefix. Ultimately how you name variables is up to you, but you should think about rule sets.
5. If an array has 1 dimension, make it a global. In general you shoud pick your type carefully which brings me to...
6. If you have an "object", rather than haveing objectABC, objectDEF, objectQWERTY, objectnumber, consider using UDTs, ie: object.abc, object.def, etc. It mey help tracking although it can require more management.
7. ECHO
Quote: "I appreciate that you did a lot of typing but you really need to pay attention to this sort of detail."

Be mindful. Check for spelling errors, etc. every 20 lines.
8. ECHO
Quote: "I generally compile and run my code when I complete each section (which is generally no more than a hundred lines at a time)"


Quote: "also an EDIT log to tell future readers whata changed is helpful this is also optional"

I don't bother unless it's a significant edit and if somebody has posted before my edit. I usually use "[EDIT]....[/EDIT]" to enclose my appends or edit logs.

29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 17th May 2012 01:23 Edited at: 17th May 2012 01:34
No, it's the next post down.
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 17th May 2012 01:26
Quote: "Ah, I see 29 games hath beaten me to it..."


If I'd have know it was a race I would've let you win

Quote: "I implemented the changes you highlighted and it seems to run but then it hangs up at the line in the code I marked kinda of like you did"


Almost didn't see your edit. If you mean the

:`<<<<<<<<<<<<<<<

that I was using at the end of the lines. The character after the colon is not an apostrophe but whatever the key is next the 1 on the far left of the keyboard. Or you could just write

:rem <<<<<<<<<<<<<<<<<

What was the syntax error?

Quote: "What's puzzling me though is that the line of code that it is calling a syntax error at, the line of code is commented out."


It sometimes does that, especially with more lines of code. Think of it as a kind of zen training exercise, i.e. stay calm and figure out the cryptic message and you too will find inner peace. It'll set you up nicely to deal with the day the pipes burst and the ceiling falls down.

If you can't get the code to work in the next couple of days, my advice would be to forget about it and start doing your own stuff. If you've gone through the rest of the book then you probably know enough to get started, spending too much time on the current exercise probably won't teach you much new. It's suprising how little you really need to know in order to make a simple game.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 17th May 2012 08:38 Edited at: 17th May 2012 08:45
Quote: "What's puzzling me though is that
the line of code that it is calling a syntax
error at, the line of code is commented out."


Usually, it's an error in the line just above the comment.
Occasionally, it's a few lines up, sometimes the line that jumped to the code segment, sometimes at the nest's start. It's to do with how the output asm code is strutured (I presume) vs your structure.
Anyhow your error message is because:
a) you are missing an IF in the statement above and
b) you have the 3 dots of hell in a comment above that.

EDIT: Bonus, example:
Quote: "
` If the player isn't colliding, Quit...
objectnumcolide = 0 THEN EXITFUNCTION
"


DBP reads it like this now:


nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 17th May 2012 23:23 Edited at: 17th May 2012 23:24
Quote: "I've tried to take out the line of code that is causing the error, but that only causes another error to occur a few lines down."


Then the error probably lies above the faulty line. For example, here's another error I picked up in you latest update:
I assume by "carinfoCarObjectNumbe(playernumber)", you meant carinfoCarObjectNumber(playernumber). If another error pops up, try and remember what the error window says too.

Bonus debug information:
1. Spelling is usually the cause of most "syntax errors"
2. If not spelling, then usually wrong parameters.
3. Comment problems (using the wrong markers for comments or using the wrong symbols in comments
- that's all I can think of.
4. In a typical scenario, the program's flow is down and so therefore, if the line causing the error is not at fault, look for the error above the fault line.
5. "Computers always do what they are told, but not always what we want them to do" - Dunno who wrote that


Btw, if you have another problem it's okay to make a new post, you don't have to keep editing your original one (MrV just meant that if you did an edit, logging it may help readers make sense). In fact it's better if you make a new post for each new error that shows up as it helps keep the flow of the thread logical as right now it looks as though I'm replying to nothing, lol ... Maybe I am and I'm going crazy.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 17th May 2012 23:47
Quote: "Maybe I am and I'm going crazy."


Nothing wrong with that... Crazy = normal no?

VGHero11
13
Years of Service
User Offline
Joined: 15th Nov 2011
Location:
Posted: 18th May 2012 18:50
THANK YOU NONZERO!!!

That simple miss spelling of the variable carinfoCarObjectNumber(playernumber) was the problem. Thanks to putting in that missing r, it FINALLY complied sucessfully.

When we all lend our power together, there is nothing we
can't do!
Please Lend me your STRENGTH!
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 18th May 2012 20:20
Glad it works now

Login to post a reply

Server time is: 2024-11-23 20:55:08
Your offset time is: 2024-11-23 20:55:08