From 1ee935e406b048277d68d290847fdcf5755508be Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Thu, 10 Sep 2020 11:53:11 +1200 Subject: [PATCH] Fix crafting --- Spaceinator.project.gmx | 4 +- objects/obj_bullet.object.gmx | 50 +++---- objects/obj_crafting.object.gmx | 191 +++++++++++++++++++++++++++ objects/obj_inventory.object.gmx | 26 ++++ objects/obj_player.object.gmx | 68 +++++----- sprites/images/spr_broken_ship_0.png | Bin 327 -> 346 bytes 6 files changed, 279 insertions(+), 60 deletions(-) create mode 100644 objects/obj_crafting.object.gmx diff --git a/Spaceinator.project.gmx b/Spaceinator.project.gmx index cc42410..b3ad1a6 100644 --- a/Spaceinator.project.gmx +++ b/Spaceinator.project.gmx @@ -3,6 +3,7 @@ Configs\Default + sound\snd_engine @@ -13,7 +14,6 @@ sprites\spr_player sprites\spr_bullets sprites\spr_blocks - sprites\spr_blackhole sprites\spr_broken_ship sprites\spr_asteroid sprites\spr_boom @@ -24,6 +24,7 @@ sprites\spr_hotbar sprites\spr_intentory sprites\spr_crafting + sprites\spr_blackhole sprites\spr_final @@ -61,6 +62,7 @@ objects\obj_exit objects\obj_gameover_overlay objects\obj_inventory + objects\obj_crafting objects\obj_hotbar diff --git a/objects/obj_bullet.object.gmx b/objects/obj_bullet.object.gmx index 3da98d7..6c8bcc4 100644 --- a/objects/obj_bullet.object.gmx +++ b/objects/obj_bullet.object.gmx @@ -57,31 +57,6 @@ if(step_counter == 60*room_speed || instance_position(x,y,obj_chunk) == noone) { instance_destroy(self); } - - - - - - - - 1 - 603 - 7 - 0 - 0 - -1 - 2 - - - self - 0 - 0 - - - 1 - instance_destroy(other); -instance_create(other.x,other.y,obj_boom_fx) -instance_destroy(id); @@ -128,6 +103,31 @@ instance_destroy(id); 0 + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + instance_destroy(other); +instance_create(other.x,other.y,obj_boom_fx) +instance_destroy(id); + + + + + 1 diff --git a/objects/obj_crafting.object.gmx b/objects/obj_crafting.object.gmx new file mode 100644 index 0000000..7e7bc14 --- /dev/null +++ b/objects/obj_crafting.object.gmx @@ -0,0 +1,191 @@ + + + spr_crafting + 0 + -1 + -4000 + 0 + <undefined> + <undefined> + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 0; + +move_slot = false; +selected_item = 0; +selected_total = 0; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + x = view_xview[0]+view_wview[0]/2 - (424/2); +y = view_yview[0]+view_hview[0]/2 - (254/2) - 200; + + +var i = 0; +if((mouse_x >= x && mouse_x <= x+140) && (mouse_y >= y && mouse_y <= y+140)) +{ + for(yy = 8; yy < (5*44); yy+=45) + { + for(xx = 6; xx < (9*45); xx+=45+1) + { + if((mouse_x >= x+xx && mouse_x <= x+xx+45) && (mouse_y >= y+yy && mouse_y <= y+yy+45)) + { + selected_slot = i; + } + i++; + } + } + +} + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + if(!move_slot) +{ + selected_item = obj_inv_controller.inventory[selected_slot]; + if(selected_item == 0) + return false; + selected_total = obj_inv_controller.inventoryCount[selected_slot]; + obj_inv_controller.inventory[selected_slot] = 0; + obj_inv_controller.inventoryCount[selected_slot] = 0; + move_slot = true; +} +else +{ + if(obj_inv_controller.inventory[selected_slot] == 0) + { + + obj_inv_controller.inventory[selected_slot] = selected_item; + obj_inv_controller.inventoryCount[selected_slot] = selected_total; + + move_slot = false; + selected_item = 0; + + } +} + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + draw_self(); +var xx = 6; +var yy = 8; +var i = 0; +for(yy = 8; yy < (5*44); yy+=45) +{ + for(xx = 6; xx < (9*45); xx+=45+1) + { + if(i == selected_slot) + { + draw_set_color(make_colour_rgb(100,100,100)); + draw_rectangle(x+xx,y+yy,x+xx+45,y+yy+44,false) + } + + draw_sprite(spr_blocks,obj_inv_controller.inventory[i],x+xx+6,y+yy+7); + var count = obj_inv_controller.inventoryCount[i]; + + var xoffset = string_width(string(count)) + if(count > 1) + { + draw_set_color(c_white); + draw_text(x+xx+45-xoffset,y+yy+30,string(count)); + } + i++ + } +} + +if(selected_item != 0) +{ + draw_sprite(spr_blocks,selected_item,mouse_x-(TILE_SIZE/2),mouse_y-(TILE_SIZE/2)); +} + + + + + + + 0 + 0 + 0 + 0.5 + 0.100000001490116 + 0 + 0.100000001490116 + 0.100000001490116 + 0.200000002980232 + -1 + 0 + + diff --git a/objects/obj_inventory.object.gmx b/objects/obj_inventory.object.gmx index 800be95..b6de0e8 100644 --- a/objects/obj_inventory.object.gmx +++ b/objects/obj_inventory.object.gmx @@ -30,6 +30,32 @@ move_slot = false; selected_item = 0; selected_total = 0; + +crafting_menu = instance_create(0,0,obj_crafting); + + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + instance_destroy(crafting_menu); diff --git a/objects/obj_player.object.gmx b/objects/obj_player.object.gmx index 0307686..06a4111 100644 --- a/objects/obj_player.object.gmx +++ b/objects/obj_player.object.gmx @@ -258,40 +258,6 @@ if((mouse_check_button_pressed(mb_left) && os_type != os_psvita) || game } - - - - - - - - 1 - 603 - 7 - 0 - 0 - -1 - 2 - - - self - 0 - 0 - - - 1 - damage_player(5); - -instance_create(other.x,other.y,obj_boom_fx); -other.direction = direction; -other.image_angle = image_angle; -other.speed = 20; - -speed = -20; - - - - @@ -370,6 +336,40 @@ if(didAdd) 1 damage_player(hp_max); + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + damage_player(5); + +instance_create(other.x,other.y,obj_boom_fx); +other.direction = direction; +other.image_angle = image_angle; +other.speed = 20; + +speed = -20; + + + + diff --git a/sprites/images/spr_broken_ship_0.png b/sprites/images/spr_broken_ship_0.png index da20d495a8b1f70a096fccceed79097f39a77b6b..5cb114aba4d54a6cb6998c262ff8163107fb82ea 100644 GIT binary patch delta 330 zcmX@kbc<<%WIZzj1B1(wu46!ou{g-xiDBJ2nU_EgOS+@4BLl<6e(pbstU$g*fKP}k zkZy2rXaE8Rh64uvZeYE*2||H(U{{#NZs#Il$9oKd-pII6b*R@zMyeD-w!;v!<9s-%K-p^yv>sitK@QyggAz#-& zNxKXt99q1jqOQr2h2dl=!(+SWJ00w|-922*t#Vzq=Vrr=Ox`u&9h@ilE;w)Nl;n7L zmG_?b)KZ2ssk{u0J9Ts;uB!`76-;nTW%<}FH}Us;X@Q=W78Gi-<0047(dh`GQ0S-w-K~#90?bcxqg&+t3V2;+&I9fNeG;n6J z0GaJ=&yDpbXSjwxv&tb9@Ha_dOxNdH@$M0L1l(T#y0FyO4{OIG?-)EJKuq zM;&Od%NAo@{oDyE{Hng