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 / Mouse Move Object Problem

Author
Message
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 26th Nov 2013 11:03
Why does this not work?

Quote: "
objx# keeps becoming equal to 2000 when mouse is clicked. Not sure why?
"

Full code:
*Should: Pick the screen for an object when mouse is not clicked, and get its original position(and 3D vectors). When mouse is clicked, it should ise its original position to calculate a new position by the mouse's movement, and position the object cpatured before the mouse click from its original position(objx#..) to its new position.. Or something like that



Need some help to make this work.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 26th Nov 2013 14:18 Edited at: 26th Nov 2013 14:18
What is positionobjectpro()?

"Get in the Van!" - Van B
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 26th Nov 2013 14:33 Edited at: 26th Nov 2013 14:34
It just positions the pobject exact like 'Position Object num,x,y,z'
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 26th Nov 2013 14:47
Um... why? I'm just thinking in terms of efficiency if it only does the same thing then why not just use position object since a function call is a very tiny tiny bit slower.

I thinking the issue could be somewhere else in your code then.

"Get in the Van!" - Van B
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 26th Nov 2013 14:51 Edited at: 26th Nov 2013 14:51
Quote: "
Um... why? I'm just thinking in terms of efficiency if it only does the same thing then why not just use position object since a function call is a very tiny tiny bit slower.
"


Its from NGC's collision functions, but I've into it and all it really does is call a dll to calculate collision checks before the object is positioned.
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 26th Nov 2013 15:28
Quote: "Its from NGC's collision functions, but I've into it and all it really does is call a dll to calculate collision checks before the object is positioned."


Aha now it makes sense! So it doesn't affect the position of the object... um... yep, must be somewhere else in the code. Have you tried this bit of the code by itself to see if it throws any errors?

"Get in the Van!" - Van B
BlackChaos
16
Years of Service
User Offline
Joined: 2nd May 2010
Location: London
Posted: 27th Nov 2013 13:53
I've even tried just using the native Position Object Command but still get the same result. I'm going to have to look deeper into to the rest of the code.

If I find out why, I will re-post.
Thansks
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th Nov 2013 12:53
Not sure if this is relevant but right at the start of your code you have this:



In some circumstances repeated attempts to call mouse functions within the inner game loop can return incorrect results - especially if they happen to change in between calls. Just call them once. Indeed why have two variables for the same thing?

As a general rule, it makes for cleaner code to call all these functions just once and immediately store the result in a variable which you shouldn't change till the next time you go through the game loop. You can then be sure that the rest of the code is referring to the same value when you use the variable. The same applies to things like MouseX(), etc.

That snippet above might be better written as:



which is not only shorter but safer.

Just as an aside it might be a good idea to check your spellings of various variable names. You only need one of those to be wrong for everything to go awry.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 07:51:03
Your offset time is: 2026-07-06 07:51:03