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 Professional Discussion / Very weird problem

Author
Message
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 12th Mar 2011 22:04
I have encountered a very strange problem when using functions.

I have this main file :



and a function file:



My main problem is this ...
I have these lines

CameraSystem()
position mouse screen width()/2,screen height()/2
rotate camera 1,wrapvalue(camera angle x(1)+mousemovey()*sensitivity#),wrapvalue(camera angle y(1)+mousemovex()*sensitivity#),0
rotate camera 0,wrapvalue(camera angle x(1)+mousemovey()*sensitivity#),wrapvalue(camera angle y(1)+mousemovex()*sensitivity#),0

Everything works fine.
However, if I stick the last mouse commands in the function itself, the mouse stops moving. Any idea as to why? I find this very strange.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th Mar 2011 22:47
Welll.... I don't know that much about DBPro and multiple source files... but one thing is for sure: The variable "sensitivity#" ISN'T declared in that function. All undeclared variables have an initial value of 0 - so you're taking "wrapvalue(camera angle x(1)+mousemovey()*0)" which, of course, just leaves camera angle x.

It might help if you declare "sensitivity#" global. You might also have to say 'include "function.dbp"' after you declare sensitivity# global.

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 12th Mar 2011 22:52
It seems the compiler includes it automatically.
If I include it, it gives me an error saying that I declared a function twice. But your variable idea is interesting, however, it should work because the variable is declare on top, so it can be seen throughout all files right? I mean the files anyway get ïncluded into one big file at the end ...
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 12th Mar 2011 23:11
Well, you were right ... it works

Login to post a reply

Server time is: 2026-07-14 22:22:42
Your offset time is: 2026-07-14 22:22:42