A
Ash Ketchum
Guest
Hello everyone.
The problem with my inventory is when my player is in motion and the view is following him, i am not able to put items in the inventory.
So like.. I have 20 inventory slots, all follow the view in a 'top down' world. When the inventory slots are not forced to follow the view due to the player object moving. The slots work fine, i can pick up items and drop/take out them just fine.
But when there in motion it struggles to place them in because of how i coded it.
I'm not good with code at all, so it's all just bodged to get to work with what i know.
Sorry if that's a bad explanation.
Here's my code:
Cursor_obj
step event:
end step:
global left pressed:
slotP (parent for all inventory slots)
create event:
end step
I know i haven't done this in the best way, but i tried, and failed
so i ask for help.
Thanks
The problem with my inventory is when my player is in motion and the view is following him, i am not able to put items in the inventory.
So like.. I have 20 inventory slots, all follow the view in a 'top down' world. When the inventory slots are not forced to follow the view due to the player object moving. The slots work fine, i can pick up items and drop/take out them just fine.
But when there in motion it struggles to place them in because of how i coded it.
I'm not good with code at all, so it's all just bodged to get to work with what i know.
Sorry if that's a bad explanation.
Here's my code:
Cursor_obj
step event:
Code:
a = instance_nearest(mouse_x-16,mouse_y-16,PickUpParent_obj)
b = instance_nearest(mouse_x-16,mouse_y-16,slotP)
if item = 0
{
holding = 0
}
Code:
if item <> 0
{
item.x = x
item.y = y
}
Code:
if position_meeting(mouse_x,mouse_y,a) and !position_meeting(mouse_x,mouse_y,b)
{
item = a
a.sprite_index = a.spr
a.sprite_index = invisible
}
if position_meeting(mouse_x,mouse_y,a) and position_meeting(mouse_x,mouse_y,b)
{
holding+=1
item = a
a.sprite_index = a.spr
a.sprite_index = invisible
b.item = 0
}
if holding = 2
{
if position_meeting(mouse_x,mouse_y,b)
{
if b.item = 0
{
b.item = item
item = 0
holding = 1
b.item.mask_index = invBox
b.item.sprite_index = b.item.spr
}
else
{
if b.item <> 0
{
c = b.item
b.item = item
item = c
holding = 1
if item = 0 {holding = 0}
b.item.mask_index = invBox
b.item.sprite_index = b.item.spr
}
}
}
}
////drop
if !position_meeting(mouse_x,mouse_y,b)
{
holding +=1
}
if holding = 2
{
if !position_meeting(mouse_x,mouse_y,b)
{
holding +=1
item.sprite_index = item.floorspr
item.mask_index = smallMask
item = 0
holding = 0
}
}
create event:
Code:
item = 0
Code:
if item <> 0
{
item.x = x
item.y = y
}
so i ask for help.
Thanks