Information about object: obj_system
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
bdd_initialize_items()
initialize_inventory()
add_item_to_inventory(0,10)
add_item_to_inventory(100,1)
show = false
//define main windows
gui_draw_inv_www = 500
gui_draw_inv_hhh = 500
gui_draw_x1 = display_get_gui_width()/2 - gui_draw_inv_www/2
gui_draw_y1 = display_get_gui_height()/2 - gui_draw_inv_hhh/2
gui_draw_x2 = gui_draw_x1 + gui_draw_inv_www
gui_draw_y2 = gui_draw_y1 + gui_draw_inv_hhh
gui_draw_bkcolor = c_white
gui_draw_bkalpha=0.5
gui_draw_ftcolor=c_black
gui_draw_ftalpha=1
startx = gui_draw_x1 +10
starty = gui_draw_y1 + 10
cell_www = 40
cell_hhh = 40
stepx = cell_www +5
stepy = cell_hhh + 5
maxinv = 30 //30 = size of global.inventory, you should use a fonction there, something like 1d_array_get_height() - cannot remember the exact function
//Define items
for(i=0;i<maxinv;i++)
{
idraw[i,0] = startx //x1 of cell
idraw[i,1] = starty //y1
idraw[i,2] = startx + cell_www //x2 of cell
idraw[i,3] = starty + cell_hhh //y2
idraw[i,4] = startx + cell_www/2 //middlex of cell
idraw[i,5] = starty + cell_hhh/2 //middley of cell
idraw[i,6] = startx + cell_www //xlegend
idraw[i,7] = starty - 10 //ylegend
idraw[i,8] = choose(c_white,c_yellow,c_gray) //cell bkcolor random for fun
startx += stepx
if(startx >= gui_draw_x2) //if your x point is larger than windows then start a new line
{
startx = gui_draw_x1 +10
starty += stepy
}
}
Draw GUI Event:
execute code:
///draw inv
//maxinv = 30
if( show == true ) //you can set a condition there if you want
{
//draw the windows
draw_set_color(gui_draw_bkcolor)
draw_set_alpha(gui_draw_bkalpha)
draw_rectangle(gui_draw_x1,gui_draw_y1,gui_draw_x2,gui_draw_y2,false) //read doc to know what does false, make it true if you want
draw_set_alpha(gui_draw_ftalpha)
draw_set_color(c_red) //title in red for fun
draw_text( gui_draw_x1 , gui_draw_y1,"Inventory")
//draw cells
for(i=0;i<maxinv;i++)
{
//cell
draw_set_color(idraw[i,8] )
draw_rectangle( idraw[i,0],idraw[i,1] ,idraw[i,2],idraw[i,3] , false)
//obj if exists
if( global.inventory[i,INV_BDD_ID] != noone)
{
obj_id = global.inventory[i,INV_BDD_ID]
obj_slot = obj_id_to_bdd_slot(obj_id)
//show_debug_message("obj_slot =" + string(obj_slot))
if(obj_slot != noone)
{
obj_sprite = global.bdd_items[obj_slot,OBJ_SPRITE]
obj_name = "test" //global.bdd_items[obj_slot,OBJ_NAME]
obj_nbr = global.inventory[i,INV_QTE]
draw_sprite( obj_sprite,0 ,idraw[i,4],idraw[i,5])
draw_set_color(c_black)
draw_text(idraw[i,0],idraw[i,5],"x" + string(obj_nbr))
}
}
}
}
execute code:
///text
draw_text(10,10,"CTRL to toggle inventory")
draw_text(10,20,"+ To add potions")
Key Press Event for <Ctrl> Key:
execute code:
show = !show
Key Press Event for Keypad + Key:
execute code:
///add red potion
add_item_to_inventory(0,1)