diff --git a/Spaceinator.project.gmx b/Spaceinator.project.gmx index c0a6f0f..932f6a2 100644 --- a/Spaceinator.project.gmx +++ b/Spaceinator.project.gmx @@ -22,6 +22,7 @@ sprites\spr_gameover sprites\spr_button sprites\spr_hotbar + sprites\spr_intentory @@ -33,6 +34,7 @@ + @@ -51,9 +53,12 @@ objects\obj_button objects\obj_respawn objects\obj_gameover_overlay + objects\obj_inventory + objects\obj_hotbar objects\obj_dropped_item + objects\obj_dropped_stone @@ -62,7 +67,7 @@ 32 16 - 0 + 0 1 diff --git a/objects/obj_asteriod.object.gmx b/objects/obj_asteriod.object.gmx index d342e3d..179a607 100644 --- a/objects/obj_asteriod.object.gmx +++ b/objects/obj_asteriod.object.gmx @@ -32,6 +32,29 @@ angle = random_range(0,180); direction = angle; image_angle = angle; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + instance_create(x,y,obj_dropped_stone); diff --git a/objects/obj_controller.object.gmx b/objects/obj_controller.object.gmx index 850b39f..3225f6d 100644 --- a/objects/obj_controller.object.gmx +++ b/objects/obj_controller.object.gmx @@ -58,9 +58,7 @@ if(!global.debug) draw_healthbar(10,40,300,60,(obj_player.hp/obj_player.hp_max)*100,c_gray,c_red,c_green,0,true,false); draw_text(11,43,string(obj_player.hp)+" / "+string(obj_player.hp_max)); - - // Draw hotbar - draw_sprite(spr_hotbar,0,960/2,544); + } diff --git a/objects/obj_controller_world_gen.object.gmx b/objects/obj_controller_world_gen.object.gmx index a10ad3e..09a1c19 100644 --- a/objects/obj_controller_world_gen.object.gmx +++ b/objects/obj_controller_world_gen.object.gmx @@ -25,8 +25,7 @@ 1 - global.allchunks = ds_list_create(); - + @@ -57,7 +56,7 @@ for(var i = 0; i < 16; i ++) { show_debug_message("Generating Chunk: "+string(cX[i])+","+string(cY[i])); var chunkInstId = instance_create(cX[i],cY[i],obj_chunk); - ds_list_add(global.allchunks,chunkInstId); + } else // load { diff --git a/objects/obj_dropped_item.object.gmx b/objects/obj_dropped_item.object.gmx index c467ce8..ac1d27a 100644 --- a/objects/obj_dropped_item.object.gmx +++ b/objects/obj_dropped_item.object.gmx @@ -5,9 +5,108 @@ -1 0 0 - <undefined> + self <undefined> - + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + image_xscale = 0.5; +image_yscale = 0.5; +image_speed = 0; + +item_id = 0; +image_index = item_id; + +alarm[0] = 5*60*room_speed; + + + + + + + + 1 + 203 + 0 + 0 + 0 + -1 + 1 + action_kill_object + + self + 0 + 0 + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + pull_towards_black_holes(); + +var distance = distance_to_point(obj_player.x,obj_player.y) +if(distance <= 100) +{ + direction = point_direction(x,y,obj_player.x,obj_player.y); + speed = 10; +} +else +{ + speed = 0; +} + + + + + + + + + + 1 + 203 + 0 + 0 + 0 + -1 + 1 + action_kill_object + + self + 0 + 0 + + + 0 0 0 diff --git a/objects/obj_dropped_stone.object.gmx b/objects/obj_dropped_stone.object.gmx new file mode 100644 index 0000000..efbe5ba --- /dev/null +++ b/objects/obj_dropped_stone.object.gmx @@ -0,0 +1,53 @@ + + + spr_blocks + 0 + -1 + 0 + 0 + obj_dropped_item + <undefined> + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + image_xscale = 0.5; +image_yscale = 0.5; +image_speed = 0; + +item_id = STONE; +image_index = item_id; + + + + + + + + 0 + 0 + 0 + 0.5 + 0.100000001490116 + 0 + 0.100000001490116 + 0.100000001490116 + 0.200000002980232 + -1 + 0 + + diff --git a/objects/obj_hotbar.object.gmx b/objects/obj_hotbar.object.gmx new file mode 100644 index 0000000..a8694eb --- /dev/null +++ b/objects/obj_hotbar.object.gmx @@ -0,0 +1,338 @@ + + + spr_hotbar + 0 + -1 + 0 + 0 + <undefined> + <undefined> + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 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]-59; + + +if((mouse_x >= x && mouse_x <= x+424) && (mouse_y >= y && mouse_y <= y+59)) +{ + var i = 0; + + for(var xx = 5; xx < (9*45); xx+=45) + { + if(mouse_x >= x+xx && mouse_x <= x+xx+45) + { + selected_slot = i; + } + + i++; + } + + +} + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + draw_self(); +var i = 0; +var yy = 7; +for(var xx = 5; xx < (9*45); xx+=45+1) +{ + draw_sprite(spr_blocks,obj_inv_controller.inventory[i],x+xx+6,y+yy+7); + 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) + } + 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++ +} + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 8; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 7; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 6; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 5; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 4; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 3; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 2; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 1; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + selected_slot = 0; + + + + + + + 0 + 0 + 0 + 0.5 + 0.100000001490116 + 0 + 0.100000001490116 + 0.100000001490116 + 0.200000002980232 + -1 + 0 + + diff --git a/objects/obj_inv_controller.object.gmx b/objects/obj_inv_controller.object.gmx index eeed8ac..55a48bd 100644 --- a/objects/obj_inv_controller.object.gmx +++ b/objects/obj_inv_controller.object.gmx @@ -7,7 +7,67 @@ 0 <undefined> <undefined> - + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + inventory = array_create(9*5); +inventoryCount = array_create(9*5); + +is_open = false; +inv_obj = 0; + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + if(!is_open) +{ + inv_obj = instance_create(0,0,obj_inventory); + is_open = true; +} +else +{ + instance_destroy(inv_obj); + is_open = false; +} + + + + + + 0 0 0 diff --git a/objects/obj_inventory.object.gmx b/objects/obj_inventory.object.gmx new file mode 100644 index 0000000..6fe8bc0 --- /dev/null +++ b/objects/obj_inventory.object.gmx @@ -0,0 +1,87 @@ + + + spr_intentory + 0 + -1 + -4000 + 0 + <undefined> + <undefined> + + + + 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); + + + + + + + + 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+1) +{ + for(xx = 6; xx < (9*45); xx+=45+1) + { + 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_text(x+xx+45-xoffset,y+yy+30,string(count)); + i++ + } +} + + + + + + + + 0 + 0 + 0 + 0.5 + 0.100000001490116 + 0 + 0.100000001490116 + 0.100000001490116 + 0.200000002980232 + -1 + 0 + + diff --git a/objects/obj_player.object.gmx b/objects/obj_player.object.gmx index 6f758c4..be1fa15 100644 --- a/objects/obj_player.object.gmx +++ b/objects/obj_player.object.gmx @@ -161,6 +161,33 @@ if(invuln_counter != invuln_counter_max) 1 ///pull_towards_black_holes(); pull_towards_black_holes(); + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + var didAdd = add_item_to_inventory(other.item_id); +if(didAdd) +{ + instance_destroy(other); +} diff --git a/rooms/rm_game.room.gmx b/rooms/rm_game.room.gmx index e4b05d5..892e135 100644 --- a/rooms/rm_game.room.gmx +++ b/rooms/rm_game.room.gmx @@ -54,6 +54,8 @@ + + 0 diff --git a/scripts/add_item_to_inventory.gml b/scripts/add_item_to_inventory.gml new file mode 100644 index 0000000..11f780c --- /dev/null +++ b/scripts/add_item_to_inventory.gml @@ -0,0 +1,21 @@ +///add_item_to_inventory(itemId) +var itemId = argument0; + +for(var i = 0; i < (9*4); i ++) +{ + var itm = obj_inv_controller.inventory[i]; + + if(itm == 0) + { + obj_inv_controller.inventory[i] = itemId; + obj_inv_controller.inventoryCount[i] = 1; + return true; + } + else if(itm == itemId) + { + obj_inv_controller.inventoryCount[i] ++; + return true; + } +} +return false; + diff --git a/sprites/images/spr_blocks_0.png b/sprites/images/spr_blocks_0.png index 806f5a8..4cea42c 100644 Binary files a/sprites/images/spr_blocks_0.png and b/sprites/images/spr_blocks_0.png differ diff --git a/sprites/images/spr_hotbar_0.png b/sprites/images/spr_hotbar_0.png index b1db597..53bd3a6 100644 Binary files a/sprites/images/spr_hotbar_0.png and b/sprites/images/spr_hotbar_0.png differ diff --git a/sprites/images/spr_intentory_0.png b/sprites/images/spr_intentory_0.png new file mode 100644 index 0000000..be676e3 Binary files /dev/null and b/sprites/images/spr_intentory_0.png differ diff --git a/sprites/spr_hotbar.sprite.gmx b/sprites/spr_hotbar.sprite.gmx index 924bcc2..599ecbc 100644 --- a/sprites/spr_hotbar.sprite.gmx +++ b/sprites/spr_hotbar.sprite.gmx @@ -1,14 +1,14 @@ 0 - 194 - 59 + 0 + 0 1 0 0 0 0 - 388 + 423 0 58 0 @@ -17,7 +17,7 @@ 0 0 - 389 + 424 59 images\spr_hotbar_0.png diff --git a/sprites/spr_intentory.sprite.gmx b/sprites/spr_intentory.sprite.gmx new file mode 100644 index 0000000..f299ff2 --- /dev/null +++ b/sprites/spr_intentory.sprite.gmx @@ -0,0 +1,25 @@ + + + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 423 + 0 + 238 + 0 + 0 + + 0 + + 0 + 424 + 239 + + images\spr_intentory_0.png + +