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 / 2D RTS function help!

Author
Message
flock
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 12th Jul 2006 16:27
Hey, guys, I've been stressing for the last hour over this code:



All I want is a box select command like "Age of Empires II" but where you click the mouse once and it starts up, then click it again to close the selective box. It's not like the Age of Empires one because you are not supposed to hold down the mouse. My problem is that I can open and start making the "box" (two lines and a dot) but when I click it off it will close but open a new one at the last mousex() and mousey() coordinates.

(hope that wasn't confusing)

Thanks

a.k.a. "flockhound"
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 12th Jul 2006 20:54
Well, without looking to your code, I can have a very good guess of what's going wrong.

If you press your mouse the last time, you reset your var to 0 (probably) and when you click if the variable is 0, it automatically start again.
Unless you have some very fast fingers for clicking the mouse without it reaches the next loop, the box will be drawn again.

My suggestion:
Add another value to the variable.
Like if you have var = 0. If mouse clicked first, var = 1, if mouse clicked twice, you don't go back to 0, but set the variable to 2.
If the variable is 2, and the mouse is not clicked, THEN you can reset your variable to 0.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
flock
20
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 12th Jul 2006 22:59
Thanks, Sven

a.k.a. "flockhound"

Login to post a reply

Server time is: 2026-07-11 18:46:35
Your offset time is: 2026-07-11 18:46:35