The Daily Click ::. Forums ::. Klik Coding Help ::. Detecting uppermost object (TGF)
 

Post Reply  Post Oekaki 
 

Posted By Message

Weston L



Registered
  16/12/2002
Points
  1603
22nd December, 2004 at 19:47:54 -

In my game I have a system where you can drag objects around, but in the engine it drags two objects at the same time if they are overlapping. Here's a link to the open-source, hoping that someone here might be able to help!

http://www.socketsink.com/temp/dragthebox.gam

Note: I removed everything in the game except what's giving me trouble for now.

I'm using TGF, please make no replies telling me to upgrade to MMF! Thanks!

 
n/a

ChrisB

Crazy?

Registered
  16/08/2002
Points
  5457
22nd December, 2004 at 20:42:51 -

Use an 'Only one action when event loops' condition, that *should* fix it. Maybe. Alternatively, store the fixed value of the object in a counter, and select the object by its fixed value in the next event.

 
n/a

Weston L



Registered
  16/12/2002
Points
  1603
22nd December, 2004 at 21:31:40 -

Thanks FireMonkey for helping!
Well just adding "Only one action when event loops" didn't work. Doing the other thing works fairly well if each object is a seperate active object, but I forgot to mention that my game will use multiples of 1 active object.

So, it doesn't work quite yet. Here is the pregress, doing both of the things you mentioned:

http://www.socketsink.com/temp/dragthebox1.gam

Also, even if all the objects were sperate, the mouse still positions both objects initially, even though it drags only the uppermost.

 
n/a

Noyb



Registered
  31/05/2004
Points
  1117

VIP Member
23rd December, 2004 at 15:37:38 -

Setup: getting alterable value to correspond with layer.
Create all objects (either in level editor or in-game) in the order you want them layered (back-to-front).
Spread value 0 in the active object's alterable value A.
Start loop "layer" for the number of Object times.
On loop "layer" & Object's value A = loopstep of "layer": set object to front.

Checking: finding highest alterable value A of those clicked on.
Make 2 counters: goCheck, and Highest, setting them each to 0 initially.
User clicked on Object + Object's Flag 2 is off: set flag 2 on, add 1 to counter goCheck.
Counter goCheck = 1: set goCheck to 0.
Counter "goCheck" > 1: run loop "findHighest" number of Object times.
On loop "findHighest" & alterable value A of Object = loopstep of highest & Object's Flag 2 is on & Object's alterable value A > Highest: set Highest to Object's alterable value A.
On loop "findHighest" & alterable value A of Object = loopstep of highest & Object's Flag 2 is on: set Object's flag 2 off.
Loop "findHighest" ends & Object's alterable value A = highest: set Object's flag 2 on & set highest to 0 & set goCheck to 0.

Coming out of the loop findHighest, which only triggers if you click on more than one object at once, only the highest layered object clicked on will have its flag 2 on.

 
"Omg. Where did they get the idea to not use army guys? Are they taking drugs?" --Tim Schafer on originality in videogames

Long John Kickbag



Registered
  26/08/2002
Points
  148
23rd December, 2004 at 21:58:22 -

Using that fixed value method does work with multiples of the same object because I remember finding that method using the same object, with the added benefit that it picks the top object (at least I remember it doing that).

The reason its not working in your file is because you're using the Counter object's compare condition. You need to use the compare condition of the active object to get it to pick an instance of it. In the active object's conditions its Alterable Values>Compare to fixed value.

 
Resize! - www.clicksplat.com/comparison.html

AsparagusTrevor

Mine's a pint of the black stuff

Registered
  20/08/2002
Points
  2364

Game of the Week WinnerHas Donated, Thank You!VIP MemberEvil kliker
24th December, 2004 at 08:57:23 -

Wouldn't the "Only one action when event loops" work if the object were both of the same qualifier and the conditions involved the qualifier instead of two separate objects?

 
Image

Long John Kickbag



Registered
  26/08/2002
Points
  148
24th December, 2004 at 11:40:01 -

I doubt it, it would need to be like only one action per object since both actions are in the same event.

 
Resize! - www.clicksplat.com/comparison.html

Weston L



Registered
  16/12/2002
Points
  1603
24th December, 2004 at 21:32:24 -

Ohhhh man.. Well, I'll try that Noyb, but it looks hellishly complicated :\ and I've never done anything with loops and loopsteps before. I'll give it a try though, since you were kind enough to put forth the effort for it. Thanks to everyone involved!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click