Information about object: obj_inventory
Sprite:
Solid: false
Visible: true
Depth: -1000
Persistent: true
Parent:
Children:
Mask:
Solid: false
Visible: true
Depth: -1000
Persistent: true
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code: ///Set Up global.showInv=true; //Display the inventory? global.maxItems=4;//total item slots for (var i = 0; i < 12; i += 1) { global.inventory[i] = -1; button[i] = instance_create(0,0,obj_invbutton) button[i].slot = i; } global.mouseItem=-1; instance_create(0,0,obj_mouseitem);
Step Event:
execute code: ///Visible switch if keyboard_check_pressed(ord('V')) { global.showInv=!global.showInv; }
Draw Event:
execute code: ///draw the inventory if (global.showInv) { var x1,x2,y1,y2; x1 = view_xview[0]+75; x2 = x1 + view_wview[0]; y1 = view_yview[0]+30; y2 = y1 + 64; draw_set_color(c_black); draw_set_alpha(0.8); draw_sprite(spr_inv_bg,0,x1-50,y1+15); for (var i = 0; i < global.maxItems; i += 1) { var ix = x1+24+(i * 40); var iy = y2-24; draw_sprite(spr_border,0,ix,iy) button[i].x = ix; button[i].y = iy; } draw_text(x1+100,y1+100,"V to show / hide - Click and Drag Items With Mouse##P to Pick Up##Pick Up Bag For Extra Room To Store Items"); }
Information about object: obj_mouseitemSprite:
Solid: false
Visible: true
Depth: -1002
Persistent: false
Parent:
Children:
Mask: No Physics ObjectDraw Event:execute code: if (global.showInv) { var item = global.mouseItem; if (item != -1) { x = mouse_x; y = mouse_y; draw_sprite(spr_items,item,x,y); } }Information about object: obj_invbuttonSprite:
Solid: false
Visible: true
Depth: -1001
Persistent: false
Parent:
Children:
Mask: No Physics ObjectDraw Event:execute code: if (global.showInv) { var item = global.inventory[slot]; var click = mouse_check_button_pressed(mb_left); if (abs(mouse_x - x) < 16) && (abs(mouse_y - y) < 16) { draw_set_colour(c_white); draw_rectangle(x-16,y-16,x+16,y+16,0); if (click) { if (item != -1) { scr_itemdrop_slot(slot); } if (global.mouseItem != -1) { scr_itempickup_slot(global.mouseItem,slot) } global.mouseItem = item; } } if (item != -1) { draw_sprite(spr_items,item,x,y); } }Information about object: obj_playerSprite: spr_idle_down
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask: No Physics ObjectCreate Event:execute code: ///set up enum state { idle, up, down, left, right } dir=state.down; is_moving=false; image_speed=0.5;Step Event:execute code: ///keypress code if (keyboard_check(vk_left)) { dir=state.left; is_moving=true; } else if (keyboard_check(vk_right)) { dir=state.right; is_moving=true; } else if (keyboard_check(vk_up)) { dir=state.up; is_moving=true; } else if (keyboard_check(vk_down)) { dir=state.down; is_moving=true; } else { dir=dir; is_moving=false; }execute code: ///movement if is_moving { switch (dir) { case state.up: y -= 4; break; case state.down: y += 4; break; case state.left: x -= 4; break; case state.right: x += 4; break; } }execute code: ///animation if is_moving { switch (dir) { case state.up: sprite_index=spr_walk_up; break; case state.down: sprite_index=spr_walk_down; break; case state.left: sprite_index=spr_walk_left; break; case state.right: sprite_index=spr_walk_right; break; } } if !is_moving { switch (dir) { case state.up: sprite_index=spr_idle_up; break; case state.down: sprite_index=spr_idle_down; break; case state.left: sprite_index=spr_idle_left; break; case state.right: sprite_index=spr_idle_right; break; } }Information about object: obj_pickupSprite: spr_pickup
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask: No Physics ObjectCreate Event:execute code: ///set up my_id=irandom_range(1,4); image_speed=0; image_index=my_id;Collision Event with object obj_player:execute code: ///Detect Keypress & Check For Empty Slot if keyboard_check_pressed(ord('P')) && scr_itempickup(my_id)//if slot available, add to slot { instance_destroy();//then destroy instance] }Information about object: obj_bagSprite: spr_bag
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask: No Physics ObjectCollision Event with object obj_player:execute code: ///Detect Keypress if keyboard_check_pressed(ord('P')) { global.maxItems+=4;// add four inventory slots instance_destroy(); }
No comments:
Post a Comment