• 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!

Windows Collisions - Check if No Objects are Touching the Active Object

A

AppDude27

Guest
Goal:
Check to see if no objects are touching the active object.

Issue:
My code scripts are not working. I've looked into the collisions section on yoyo games documentation, but everything I've tried doesn't work.

Failed attempts:
if (position_empty(obj_ActiveInventoryItem.x, obj_ActiveInventoryItem.y))
if (place_meeting(x,y, all)
if (place_meeting(x,y,obj_ActiveInventoryItem)

Suggestions would be appreciated.
 

Roderick

Member
It sounds like you're trying to make an inventory system, similar to Diablo or WoW, where the items take up one or more slots in a bag.

If that's the case, I'd recommend using a ds_list, ds_map or ds_grid instead.
 
A

AppDude27

Guest
It sounds like you're trying to make an inventory system, similar to Diablo or WoW, where the items take up one or more slots in a bag.

If that's the case, I'd recommend using a ds_list, ds_map or ds_grid instead.
That's actually exactly what I'm doing, minus the slots and grid system. I'm trying to make my game more "touch screen friendly" by seeing how far I could go without the grid system. This collision thing is just giving me a headache.
Is there really no way to check if all instances in the room are touching a single instance?

In pseudo code:

//Default: nothing is equipped
if (any instance in the room is not touching the active item box)
{
Set the variable activeItemEquipped = false;
Set sprite of inventory box to show an empty box;
}
else if (a specific instance in the room IS touching the active item box)
{
Set the variable of activeItemEquipped = true;
Set the sprite of the inventory box to show that specific item
}

and so on...
 
Last edited by a moderator:

Roderick

Member
I would just use code to figure out which cell the mouse (finger) was over, and directly referencethe corresponding ds_ entry.
 
A

AppDude27

Guest
I would just use code to figure out which cell the mouse (finger) was over, and directly reference the corresponding ds_ entry.
Update:

I actually solved this issue by flipping my logic. I'll explain in pseudo code:

if (a specific instance in the room IS touching the active item box)
{
Set the variable of activeItemEquipped = true;
Set the sprite of the inventory box to show that specific item
}
else
{
Set the variable activeItemEquipped = false;
Set sprite of inventory box to show an empty box;
}

Thanks for helping!
 
Top