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.

PureGDK / Camera Move with Mouse

Author
Message
Arbrakan
13
Years of Service
User Offline
Joined: 10th Oct 2010
Location: Geneva
Posted: 24th Feb 2011 14:32 Edited at: 18th Jun 2011 23:27
Hello guys !

I making a map editor with PureGDK.
First,I all made with DarkBasic and I just bought PureBasic and PureGDK, now I convert my code to pureGDK, but the camera movement don't work, and i don't know why.

I think I have a problem with "inc", I don't know how I must translate this in PureGDK..., there no "inc" command in PureGDK.

need your help...

DarkBASIC code:

if mouseclick()=2


hide mouse
xMouseMove# = mousemovex()
yMouseMove# = mousemovey()
inc xCameraAngle#, yMouseMove# / 5.0
inc yCameraAngle#, xMouseMove# / 5.0
if xCameraAngle# < -85.0 then xCameraAngle# = -85.0
if xCameraAngle# > 90.0 then xCameraAngle# = 90.0

rotate camera 1, xCameraAngle#, yCameraAngle#, 0.0
show sprite 1

endif


And my PureGDK code :

If dbMouseClick()=2
;dbHideMouse()
xMouseMove = dbMouseMoveX()
yMouseMove = dbMouseMoveY()

xCameraAngle = xCameraAngle+1
yMouseMove = yMouseMove+1 / 5.0

yCameraAngle = yCameraAngle+1
xMouseMove = xMouseMove+1 / 5.0

If xCameraAngle < -85.0
xCameraAngle = -85.0
EndIf

If xCameraAngle > 90.0
xCameraAngle = 90.0
EndIf

dbRotateCamera (xCameraAngle,yCameraAngle, 0.0,1)
dbShowSprite (1)

EndIf


Sorry for my bad English.. And thanks for the reply !
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 25th Feb 2011 20:56
Well, this is only a strong guess becasue I know nothing about Dark Basic or Pure Basic, but in this line:



Do you want to first increase yMouseMove by one and then divide it by 5.0? Because then you should probably do this:



In every programming language I know, multiplication and division is executed before addition and subtraction, according to mathematical operator precedence rules. So your code line will first divide 1 by 5.0 and then increase yMouseMove with the result (0.2). The second code line, with brackets, will first add 1 to yMouseMove and then divide it by 5.0. The order of execution changes the final result.

Another thing, in this line:



Are you sure about the order of the parameters? Shouldn't the camera ID be the first parameter, not the last?
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 26th Feb 2011 07:54
I can't help you unless you provide a full example that I can compile. You can also see an example of camera movement in the stereoscopic project in the examples directory.

I would also agree with Mireben's theory about your code.

DarkBasic Professional is also known to have a strange way of evaluating expressions. There is an example of this with float evaluations in the PureGDK documentation under "How to -> Fundamental Differences"

Arbrakan
13
Years of Service
User Offline
Joined: 10th Oct 2010
Location: Geneva
Posted: 16th Jun 2011 13:22
I finally get it !
Hope it will help some one else.

Thanks PureGDK

Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 17th Jun 2011 09:52
Glad to see you got it worked out.

Login to post a reply

Server time is: 2024-04-19 09:25:09
Your offset time is: 2024-04-19 09:25:09