• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How to loot only 1 monster at a time?

Jihl

Member
Hey there!

I am trying to make a loot system for my game, I'd like to just open the loot of the sprite that's in front of the picture.

Explicative image:


As you can see here, there are several corpses stacked, if I click on one of those, all of the ones that are touching the mouse will be opened too. How can I make this to just focus one of the objects?

Thank you everyone :D

PD: Those are dead slimes of my project
 

Slyddar

Member
Use instance_place and it will return one id only. Use that and collision_rectangle() to detect where the mouse has clicked, to process the pickup.
 

Dr_Nomz

Member
Pro tip: Try formatting better, those are two separate links and they aren't displaying, I have to right click on them and open them in a new tab just to look at them. Moreover I don't feel they're very helpful since I don't know what I'm looking at, and there's no UI or anything that fits with your question so it's doubly confusing.

Honestly, it's either something you just have to deal with, or you need to have a system where the monster that's layered the closest to the screen gets priority, but I'm not sure how to do that. Or how well that would work. You could also just make the die in a way that makes them forcibly move away from eachother so that looting them both at once is impossible, though that may not be good for your particular art direction. (Again, unless that would be fine to deal with.)

EDIT: Oh looks like The Sly got in a good response while I was typing. Yeah work with what he suggested, that should be the answer right there.
 

Jihl

Member
Pro tip: Try formatting better, those are two separate links and they aren't displaying, I have to right click on them and open them in a new tab just to look at them. Moreover I don't feel they're very helpful since I don't know what I'm looking at, and there's no UI or anything that fits with your question so it's doubly confusing.

Honestly, it's either something you just have to deal with, or you need to have a system where the monster that's layered the closest to the screen gets priority, but I'm not sure how to do that. Or how well that would work. You could also just make the die in a way that makes them forcibly move away from eachother so that looting them both at once is impossible, though that may not be good for your particular art direction. (Again, unless that would be fine to deal with.)

EDIT: Oh looks like The Sly got in a good response while I was typing. Yeah work with what he suggested, that should be the answer right there.
"As you can see here, there are several corpses stacked, if I click on one of those, all of the ones that are touching the mouse will be opened too." I don't see where the explanation is not clear here.

Also I don't know what you are reffering to by saying "those are two separate links and they arent displaying"

- "I have to right click on them and open them in a new tab just to look at them."
That's strange, the post looks perfectly fine for me.

And also I am pretty sure that there are several ways of dealing with this, this is clearly not a thing that I have to just pass it by, it can be solved.
 

Jihl

Member
Use instance_place and it will return one id only. Use that and collision_rectangle() to detect where the mouse has clicked, to process the pickup.
Thank you for your reply!

I will try it to see if it works as I need it O:
 

Slyddar

Member
Here's a simple way to do it, in case you have trouble.

Code:
if (mouse_check_button_pressed(mb_left)){
    var obj = instance_position( mouse_x, mouse_y, o_object);
    if (obj != noone){
        with (obj) {
            //place code here to run inside the object.
        }
    }  
}
 
Last edited:

Dr_Nomz

Member
Also I don't know what you are reffering to by saying "those are two separate links and they arent displaying"

- "I have to right click on them and open them in a new tab just to look at them."
That's strange, the post looks perfectly fine for me.
Weird, it works fine now. Before it was two broken images displayed as errors with a [/IMG] next to both of them, and they both lead to different websites showing the same one. It's working fine now though, maybe it was just a glitch.
 

Jihl

Member
Weird, it works fine now. Before it was two broken images displayed as errors with a [/IMG] next to both of them, and they both lead to different websites showing the same one. It's working fine now though, maybe it was just a glitch.
It wasnt a glitch, I edited the post just after I posted it because I didn't know how the image system worked, it was unedited
 
Top