T
Tran Thi Huyen Trang
Guest
Hello everyone! I'm having trouble with my inventory system that I can't seem to fix. I've tried a lot of different things but nothing seems to work. so I'm just going to show you my code and hopefully you can help. If your not sure what some of the code means, ask me and I will explain it The problem is: the sprite of items and text of item amount are not the correct in the slot of inventory(backpack) that's mean: when i put the items in the slot 1 of Backpack, items will storage at slot 1, but the sprite and text of items amount will storage in the slot number 2 and slot number 8 (see in the image).
Create:
DRAW:
You can see the image I attached.
Thanks for the help!
Create:
Code:
///initialize inventory
slot_number = 20;
inventory_width =4;
///new
backpack_slot_number = 9;//6;
backpack_slot_width = 9;//1
backpack_slot_height = 1;
backpack_slot = noone;
backpack_slot_n = 0;
//----For-Loop emptying all slots----
for(var i = 0; i < slot_number; i++)
{
slot[i] = noone;
slot_n[i] = 0;
weapon_slot = noone;
shield_slot = noone;
backpack_slot[i] = noone;
backpack_slot_n[i] = 0;
}
mouse_slot = noone;
mouse_slot_n = 0;
x_off = 200;
backpackx_off = view_xview[0] + 8;
backpacky_off = view_yview[0] + 468;
Code:
//----Drawing backpack slots----
//Checking backpack_slot_number and draw as many sprites as backpack_slot_number provides
for(i = 0; i < backpack_slot_number; i++)
{
var xx = i mod backpack_slot_width;
var yy = i div backpack_slot_width;
//Drawing backpack slots
//draw_sprite(spr_backpack_slot, 0, 8 + xx * 64, 468 + yy );
//draw_sprite(spr_backpack_slot, 0, 8 + xx * 64, 468 + yy * 64);
draw_sprite_ext(spr_backpack_slot,0,8 + xx * 64,468 + yy ,2,2,0,c_white,1);
if(backpack_slot[i] != noone)
{
//Drawing item and number etc.
draw_sprite_ext(sprite[backpack_slot[i]],0,backpackx_off+xx *64+16,468+yy+16,2,2,0,c_white,1);
//draw_sprite_ext(sprite[backpack_slot[i]], 0, 8 + xx * 32 + 16 + 3, 468 + yy * 32 + 16 + 2, 1, 1, 0, c_black, .4);
draw_text(backpackx_off +xx *64, 468+yy *64, string(backpack_slot_n[i]));
//draw_text( backpackx_off + (xx*64)/6 , 2 + 468 + yy , string(backpack_slot_n[i]));
draw_set_font(fnt_slot_number);
draw_set_color(c_white);
draw_set_font(-1);
draw_set_color(-1);
}
}
Thanks for the help!
Attachments
-
26.1 KB Views: 9