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.

Code Snippets / [DBC] select and move objects in 3d space using the mouse.

Author
Message
Attila
FPSC Reloaded TGC Backer
20
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 19th Mar 2008 22:19 Edited at: 20th Mar 2008 00:46
Sometime it would be handy to use the mouse to select or to move a object in 3d space. Imagine writing a checker game or a real time strategy game. One of the problems is that the mouse moves over the screen (a 2d plane) but the objects are located in a 3d space.
DarkBASIC makes it possible to get the position of any given object on the screen, therefore it is possible to write code to determine when the mouse moves over an objects representation on the screen.

here is a example in DarkBASICclassic:



You can cut and paste the code into your DarkBASIC-Editor and try it out. The code does not need any media (it creates the necessary bitmaps) itself.

- Select the objects with a mouse click and push them around.
- A click on the Exit sign will exit the program.

You can add more objects in the code, but you then must increase the variable MaxObjects.

The program will work in DarkBASICpro too, but the "SET OBJECT no,1,0,0" commands (for cull and transparency) must be changed then to the appropriate DarkBASICpro-commands.

For your convenience the code is although attached as RAR-file (aprox. 2kB), which allows for a comfortable download.

enjoy
Attila

Attachments

Login to view attachments
Attila
FPSC Reloaded TGC Backer
20
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 19th Mar 2008 22:24 Edited at: 19th Mar 2008 22:25
Here is a screen print of the program.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 02:27:59
Your offset time is: 2024-11-25 02:27:59