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 / problem with my SELECT UNIT function :P

Author
Message
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 25th Jan 2004 03:09
i am making a RTS game, and i've been writing my code for the select unit



and heres how i call it:

the code seem to work fine when i look thru it, but when i click on an object ( i have two on the matrix, 1 and 2, and they are in two differnt places ) it selects both of them.

in the function 'size' is the radius of the imaginary circle that is around the circle, you have to click inside of that "circle" to select an object. obj is the object number.

if you need me to post the entire program i could, i only have one texture for the matrix. other than that, i have no media what so ever

Neil Young
21
Years of Service
User Offline
Joined: 6th Jan 2004
Location:
Posted: 25th Jan 2004 11:48
So is that pythagorean's theorem you're using for distance? What is the point of that? Shouldn't you just need to check the distance with the screen position rather than it's 3d position?

I have had problems where I click or press a button. Since its processing so fast, it loops several times in the period which I have the button done. Maybe since both units are within the 5 range distance, it is picking them both up when you click the mouse button. Try adding a switch - the switch needs to be off (by default a variable switch would be off) in order for it to be clicked, then once you click it, it is turned on which doesn't allow any other unit to be selected during that particular click.
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 26th Jan 2004 04:09
that is the distance formula its so i can tell if the mouse is 5 units on an angle, rather than just up/down and left/right.

i'll think about doing that. but the thing is, they are NOT within the five unit radius. they are probably 100 units away from each other

GameKit
22
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 27th Jan 2004 16:48
Instead of making object selected equal to 1, make it equal to the object you have selected...

if mouseclick()=1
objectselected=obj
endif

that way, when you click on object one, it selects object one, if you click object two it selects object two... then change your code so that the selected object has a box around it and is "controlled"... I think that might fix your problem... well... i hope i helped...

Do not thwart the way of the dragon. For thou tasteth like chicken.
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 28th Jan 2004 02:52
oh, i forgot about this post, i got it working, thanx guys. im just using an array

Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 28th Jan 2004 07:37
I'd like to suggest that you post your working code into the codebase. Select units is a question that comes up time and time again. It'd be good to have some examples of code that addresses this question in the codebase.

Philip

What do you mean, bears aren't supposed to wear hats and a tie? P1.3ghz / 384 megs / GeForce MX 5200 128meg / WinXP home
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 30th Jan 2004 01:18 Edited at: 30th Jan 2004 01:19
hrm...i'll probibly get around to making a small demo for it and post it there...but yeah
and i'm still constantly changing it, making it look better, feel better and im currently adding a click/drag selection function

Login to post a reply

Server time is: 2025-05-22 11:52:49
Your offset time is: 2025-05-22 11:52:49