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 / Moving objects

Author
Message
Asteric
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Geordie Land
Posted: 17th Mar 2009 22:57
Hey, im coding a little project in dark basic pro, and i need to be able to move objects with the arrow keys, but i will have more than 1 model so i would need to use a selection tool, so basically, you click the object you want to move with the mouse, is this possible?
any help would be great, thanks

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 17th Mar 2009 23:32
Well, to start you could use the upkey(), downkey(), leftkey() and rightkey() commands to check if the arrow keys are pressed or not. This is the simplest way for a beginner

Once you've found out if the button has been pressed, then you can decide whether you need to change the x or z co'ords of the object, and reposition the object with the position object command.

And as for object selection, pick object is a command for you to look up

Hope that helps

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Asteric
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Geordie Land
Posted: 17th Mar 2009 23:40
Ok, but i need to be able to pick an object anywhere, so after i have moved it etc, sorry for being a total noob( i am one) but could you help me with it?

HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 17th Mar 2009 23:48
look up the pickobject command that should get you going so far.

Dark Physics makes any hot drink go cold.
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 17th Mar 2009 23:52
Did you look in the DBPro Help files for the Pick Object command as I suggested?

I'm pretty sure that does what you need, however, if you allow the user to move the object out of camera view; you'll need to move the camera as it only works with objects on screen.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Asteric
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Geordie Land
Posted: 18th Mar 2009 00:27
yeah i understand how to pick an object but im stuck here

i have the arrow keys already taken up by camera controls, so how would i make it so, when the object is selected, the arrow keys move the object instead?

sorry for the questions

Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 18th Mar 2009 01:04
Set a variable. Near the top of your code, create a variable, and set it to false:

global objectSelected as boolean
objectSelect = false

When you have detected that the user has clicked on an object, set the variable to true.

Change your movement code so that:

if objectSelect then
*move object code*
else
*move camera code*
endif

You will also need a way of deselecting an object so that you can set the variable back to false, and allow camera movement. Maybe a right click can do that.
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 18th Mar 2009 02:07
Is this the code your looking for.



life is short but so am i
Asteric
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Geordie Land
Posted: 18th Mar 2009 17:55
Hey, i tried that and i get an error saying object illegal at line 23, which is this :



z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 18th Mar 2009 18:03
Try this


life is short but so am i
Asteric
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Geordie Land
Posted: 18th Mar 2009 18:47
Thanks, work mostly with my program but i cant seem to select other objects, i just get pretty much the same error, i can only select my sphere

here is my code so far




=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 18th Mar 2009 19:38
That works fine for me, altho you have to click on the sphere 1st before you move, otherwise it tries to move object 1 which doesn't exist in the snippet above.

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Asteric
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Geordie Land
Posted: 18th Mar 2009 19:40
yeah, but i want to select say the box too, but i cant, what do i need to do?

z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 18th Mar 2009 19:54
What do you mean i dont understand.

life is short but so am i
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 18th Mar 2009 20:11
I could happily switch between the box and the sphere by clicking on them.

Do you want to select both at once?

Without Music or Love the world would be a very empty place... Thank god I still have music.. --'-<@
Asteric
16
Years of Service
User Offline
Joined: 1st Jan 2008
Location: Geordie Land
Posted: 18th Mar 2009 20:28
huh, doesnt want to work for me, i can either move the sphere, or try to move the box, resulting in it crashing

z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 18th Mar 2009 21:09
Ive edited the code now the only reason you were getting an error was because you had


When you should have the object number as one becuse in this part of the code
it looks for the object with a number 1 but there wasnt one made so now it is so it should work for you. Heres the code.


life is short but so am i
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 18th Mar 2009 21:14
Asteric ive added you on msn to see if i can help you further with your problem. I wont get offended if you dont accept because i know this is abit off key.

life is short but so am i

Login to post a reply

Server time is: 2024-09-28 04:21:27
Your offset time is: 2024-09-28 04:21:27