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 / Something wrong with this function?

Author
Message
Lavalord7
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 24th Nov 2008 23:12
Is there anything wrong with this function? I can't get it to work...



zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 24th Nov 2008 23:25
Not that I can see, except for the fact that the second parameter is really velocity (which is distance/time), and you are using the name distance.

So what is happening, what's not working exaclty?

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
Lavalord7
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 24th Nov 2008 23:33 Edited at: 24th Nov 2008 23:54
Sorry, I have no idea why I called it distance...

I made a function called CheckKeyInput that basically checks the key input, and if you pressed W it moves the character forward. Does it matter that this CheckKeyInput function was defined before the other function?

EDIT: The problem appears to be with this function:


EDIT2: I'd put it in Step Thru mode, but I can't seem to get that to work either.

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Nov 2008 00:06
Can you post the full source? Becuase I really can't see what is going on.

Did you try putting test stubs in your code to print out to the screen, when you reach a function, and what the values are? I've never gotten the debugger to work either,

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
Lavalord7
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 25th Nov 2008 00:22
Well, excuse its sloppiness, but here's the entire source. Also completely ignore the camera stuff... I have no idea whats going on there.



zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 25th Nov 2008 00:38 Edited at: 25th Nov 2008 00:55
Just make your MOVESPEED# at the beginning of the source code global.

The functions had no visibility/access to it, and were hence creating a localized MOVESPEED# variable that had a value of 0. That is why your object was not moving,

In programming this is known as the variable's scope. A variable can have a local scope or a global scope.




note in dbpro arrays are global by default.

By making MOVESPEED# Global, you are basically allowing the variable visible to the entire program (giving the variable a global scope rather than local scope), and allowing functions to access it & change it's value as well.

If it's not global, and you want a function to receive the value, you would need to pass it as a parameter.

"When I look at that square... I wish FPSC noobs would stay on their side of the forums and stop polluting these boards." - Benjamin
Lavalord7
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 25th Nov 2008 00:54
Thanks, it now works!

Lavalord7
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 26th Nov 2008 03:48
Okay, new problem.
I tried to implement sliding collision. Is there something wrong with my sliding collision function? Here is my full source:



All help will be appreciated.

Login to post a reply

Server time is: 2024-11-25 14:49:39
Your offset time is: 2024-11-25 14:49:39