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 / Selection rings for rts problem

Author
Message
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 11th Jul 2005 09:40 Edited at: 11th Jul 2005 09:41
ok. i'm making a real time strategy game, and i just started yesterday (so i haven't gotten far). so far i have only made the soldier selection system, you know with the click and drag box that you drag around your soldiers and the little green circle appears under them? i have it pretty much down, but i encountered one problem. when the units are withing the box, they are selected and the ring shows up and everything works. but when i release the mouse button and the box dissapears, they are no longer selected.

i know what the problem is, but i don't know how to fix it. the part that checks if the object is inside the box on the screen is inside the if endif statement "if mouseclick()=1". now, that is the only place that i can put it that makes it work. the problem with that is that when mouseclick()=0, it is no longer selected because the declaration of its selection is inside the "if mouseclick()=1" statement.

how can i change my code so that the objects stay selected after they have had the box dragged around them even if the box no longer exists? here is my code (it's not much yet, but is completely functional)



PLEASE HELP

Your Head A-Splode
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 11th Jul 2005 14:46 Edited at: 11th Jul 2005 14:49
ChozoMufin,

There is a problem, that you are declaring the select array each loop. In DarkBasic, if an array is declared and then declared again, the values it did hold will be reset to 0. Therefore, in your program, only when the selection box is surrounding an object will it be set as selected.

An array only needs to be declared once for it to function throughout the life of your program's current execution. So, move your array declaration somewhere above the do of the do loop.

The rest of your code is setup correctly, and will function properly once you move your array declaration.


+NanoBrain+
Leeorg
19
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 11th Jul 2005 15:46
Just wanted to add to Nanobrain's comments, you may find is easier to avoid problems like that in the future if you had a subroutine that sorted out or your Vaibles and Arrays when the program starts i.e.

REM ***** REAL TIME STRATEGY *****
Set Display Mode 800,600,16
Gosub Varibles

And if you ever need more varibles (which you undoubtably will), you will always know where to find them.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 12th Jul 2005 00:14
Since i can't create a function to add/remove an item from an array list. I created a sub...



press left mouseclick to increase the number of arrays
press right mouseclick to decrease the number of arrays

hope this helps...

Immunity and Annihalation makes Immunihalation...
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 12th Jul 2005 02:25
ok thanks nanobrain and everyone else! i knew it would be some obvious thing that i just forgot to do , so thanks for pointing it out to me !

Your Head A-Splode
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 12th Jul 2005 07:15
yeah i have another question. i have the selectoin stuff down, but how do i have a 3d object place at the mouse pointer? so like, if i click on a spot, they go there. do i just hide the mouse and make a 3d object that moves when i move the mouse, or is there a way to position it where the mouse is on the screen? i'm not sure how to do that. i know it's possible to do in db, because in magicworld (in the showcase) there is one. so if anyone could help me there, i would appreciate it.

Your Head A-Splode
RUCCUS
20
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 12th Jul 2005 08:57
You could do what you suggested using Pick Object if you have DBP, or you could covert the mouse coordinates to the world coordinates by using a formula I mnade up a long time ago, search the code snippets for GMS, it's in there.


Current Projects: SHADE - Game Maker | Mecho - TGC Puzzle Entry | Halo Physics Engine | COLD - Polygonal Collision Detection
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 12th Jul 2005 22:02
For everyone that can't read: this is a DBC forum.

Immunity and Annihalation makes Immunihalation...
ChozoMufin
20
Years of Service
User Offline
Joined: 19th Apr 2005
Location: Columbus, OH
Posted: 13th Jul 2005 02:18
yeah i think i figured it out. i just used an object that moved when the mouse moved, and could not go off the screen. so i have that figured out.

Your Head A-Splode

Login to post a reply

Server time is: 2025-05-22 19:33:42
Your offset time is: 2025-05-22 19:33:42