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 Discussion / Anyone know how to do a click and drag effect.

Author
Message
Stinger
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location:
Posted: 6th Jul 2004 13:36
Hey im makin a stradegy or tryin to this my third day lol so it not goin well...anyway i need to know how to click and drag, and also when the little box the click and drag creates is over the unit it selects that unit. If you could help that would be great, thx.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 6th Jul 2004 15:16
Stinger,
I'm not too sure what you're after.

If you need something like the selection box that is common in an RTS, then what you want to do is get the coordinates of where the mouse is first pressed, then get the cordinates of where the mouse is currently, and draw lines between them.

If you want to have the objects inside that selected, then you'll need to use an intersect object, or pick object function.

Do a bit of a search for those on this board, and you should find something.

Alternatively, have a look at Sparky's dll in the Program announcements board.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Stinger
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location:
Posted: 7th Jul 2004 04:46
ok thx jess
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 7th Jul 2004 10:48
I can help out, but I need to know something first: is this going to be a 2D or 3D game?

A game in 3D can still be top down or isometric view, but uses 3D objects which need to be modeled. A 2D game will most likely be top down view, or isometric, but uses animated pictures called sprites that are drawn to the screen.

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
Stinger
20
Years of Service
User Offline
Joined: 3rd Jul 2004
Location:
Posted: 7th Jul 2004 15:13
it will be 3d.
Axelman
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location: Parallel Universe
Posted: 7th Jul 2004 17:59 Edited at: 7th Jul 2004 18:00
do you have the models? maybe you could show us your code and maybe a bit of your storyline.

CURRENT PROJECT: Enemy At The Gates
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 8th Jul 2004 13:08
Okay...3D...Just make sure that your camera is at a fixed angle. If it is not then mouse control can be extrememly difficult.
Also, to do it in 3D, you can either have a 3D object as a cursor, or use trigonometry to position the mouse to a 3D plain, which can be very complex.

I am writing this on the fly, so I hope you understand it. First I will explain, then I will write it in pseudo-code. I will write some code for you later, I can't at the moment...

1-When the mouse is clicked, store its position and tell the program that the mouse button is down
2-Wait until the mouse button is unclicked, then store the new mouse position
3-Use the two mouse positions to see if any of the units are within the rectangle that was selected.
4-When the mouse button is being held down, draw a box around the selection area

The following code is not a program, but should help you out a little


This is quite simple, you should be able to understand it if you understand simple code. It uses arrays, if-then statements, a for-next loop, and a do-loop. I used mousex() and mousey() positions just for simplicity, if you use a 3D cursor then mousex() and mousey() will be replaced with object screen x(cursorobject) and object screen y(cursorobject).

Sorry if this was confusing, I will cut some code from Firewall to show you how to do it as soon as I get some time. In the mean time, check out Firewall for a sample of a Dark Basic 3D RTS game (web site below)

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]

Login to post a reply

Server time is: 2025-05-25 07:28:52
Your offset time is: 2025-05-25 07:28:52