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 / Need Help - Functions Bug

Author
Message
QueQue
20
Years of Service
User Offline
Joined: 4th Apr 2005
Location:
Posted: 16th Apr 2005 06:11
When i put one peice of code into a function, when it hits the "endfunction" command it returns to where the function was called, but when i put different peice of code into the same function it quits out when it hits "endfunction" command.

Btw - My program does not contain an "end" command.

Does anyone know why the "endfunction" command would make a program end?


Thanks in advance for any help.

http://www.quickerwit.com/que/JsGallery/Games.htm
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 16th Apr 2005 09:47
QueQue,

If I could view your source code, I might be able to lead you to your problem. However, without your code there is no way for us to figure it out.

+NanoBrain+
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 16th Apr 2005 10:49
Ya, post the code and we'll see what we can do.

QueQue
20
Years of Service
User Offline
Joined: 4th Apr 2005
Location:
Posted: 16th Apr 2005 20:56
Ok, it requires lots of media files to run - I could attach them if you want.



http://www.quickerwit.com/que/JsGallery/Games.htm
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 17th Apr 2005 04:26
QueQue,

There seems to be a problem with your source code. Try to re-paste it by editing your last post above. Also, no code is within your 'Code Snippet'. In end, when you fix these problems, please let us know the name of the function you are having trouble with. This will enable us to find the problem much more efficiently.

+NanoBrain+
QueQue
20
Years of Service
User Offline
Joined: 4th Apr 2005
Location:
Posted: 17th Apr 2005 19:47
Sorry, i must have done something wrong.


http://www.quickerwit.com/que/JsGallery/Games.htm
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 18th Apr 2005 07:49
QueQue,

I'm not sure what might be the problem. So, please do include your media for testing. Also, I would like to suggest a more efficient way to setup your code.

I see that you have created a whole level, full of do loops and labels, within a single function. A function is there to keep an individual from having to 'hard-code' the same lines of code for each level. It is used in a manner as to where inside of it is a few lines of code, sometimes many, to do a calculation on a set of numbers and then return the value. Sometimes, functions can be used to manipulate something without returning a value.

I am saying all of this because if you were to make good use of functions, you would probably not have such a hard time figuring out this problem. Functions keep a program 'clean', and easy to maintain. For example, let's say that I have a program with a.i. within it. There are several steps to making the a.i. work. Therefore, I could create several functions to make individual calculations for specific tasks. One function could calculate the angle between characters, another could calculate if the characters are 'within range' of eachother. Again, other than a.i., a seperate function could make a bullet shoot from a gun.

When using functions, if any function needs to be reiterated or improved upon, then one can easily touch it up without destroying a program. If a program is created upon function by function, then as something becomes buggy, the creator would know where it lies. However, placing a 'whole game' inside of a single function depletes it's reason, and makes the program very confusing to try to read and debug.

Functions can also be reused over and over again, without the creator having to 'hard-code' every line over and over to make the game work for each instance, or level. If within a certain level, an a.i. calculation needs to be made, then a function can simply be called, with passing values to it.
I have attached to this post a simple program that makes use of multiple functions. The program doesn't quite work correctly, but this is not the point of it. Note the use of my functions within it.

On a last note, if you wish, learn and try using #include files, to include functions from other programs. This will clean your programs up much more.

+NanoBrain+
QueQue
20
Years of Service
User Offline
Joined: 4th Apr 2005
Location:
Posted: 20th Apr 2005 05:06
Ok thx, I just wanted to use functions as an easy way to reset all the varibles and arrays. Does anyone know another easy way to reset all the varibles and arrays?, or delete all the objects?

There are a lot of media files(Maps, Images, Textures, Objects ect.) and even if compressed they will total over the 1mb limit.

http://www.quickerwit.com/que/JsGallery/Games.htm
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 23rd Apr 2005 07:47
You have a website, why not upload the zipped file onto there?

How's my typing? Phone 0800-GO-TO-HELL

Login to post a reply

Server time is: 2025-05-23 10:40:16
Your offset time is: 2025-05-23 10:40:16