[SOLVED] Inventory Not Drawing To Screen

S

Spencer S

Guest
I have this block of code located in the Draw GUI event of my inventory object:
Code:
if (global.showInv) {
    var x1, x2, y1, y2; // x1 = left side, x2 = right side, y1 = top side, y2 = bottom side   
    x1 = camera_get_view_x(view_camera);
    x2 = x1 + camera_get_view_x(view_camera);
    y1 = camera_get_view_y(view_camera);
    y2 = y1 + camera_get_view_y(view_camera);
    
    draw_set_color(c_aqua);
    draw_set_alpha(0.8);
    draw_rectangle(x1, y1, x2, y2, 0);
    draw_set_alpha(1);
    draw_set_color(c_white);
    
    for (i = 0; i < global.maxItems; i += 1)
    {
        draw_sprite(spr_border, 0, x1 + 2400 + (i * 40), y - 24);
        if (global.inventory[i] != -1)
        {
            draw_sprite(spr_weapons, global.inventory[i], x1 + 2400 + (i * 40), y - 24);
        }
    }
}
And this block of code located in the Create event of my inventory object:
Code:
global.showInv = true; //Display the inventory? toggle true or false

global.maxItems = 10; //Total item slots

for (i = 0; i < global.maxItems; i += 1)/*just as an explanation - initialize the variable i, set the conditions for which the function will loop, and then set the looping function*/ {
    global.inventory[i] = -1;
}
I also followed the tutorial by Shaun Spalding located here:
I have a decent amount of knowledge of GML, and I can understand why and how all the code interacts with itself, but the problem is that his tutorial was made in GMS and I'm making this in GMS2. Is there anything wrong with my code?

The current problem: the inventory does not appear in my game at all, but if any object goes to the specified location of the inventory, they disappear, as if they are located behind the inventory box. Changing this code to be in the Draw or Draw GUI event makes no difference.

Thanks in advance for any help at all!
 

Simon Gust

Member
I don't know gms2 but I suspect that adding any camera related coordinates inside the draw GUI will not work well. The draw GUI draws at view by default.
draw it at x = 0 and y = 0.
 
S

Spencer S

Guest
Unfortunately changing the draw gui coordinates didn't do anything. Is this an issue of depth of layers?
 
S

Spencer S

Guest
Changing the numbers didn't do anything. Fortunately, I figured out why. The inventory object wasn't placed inside the room.
 
Top