From b1ac1abcdbe11c0bb465fe042eaba2ab9e012a5a Mon Sep 17 00:00:00 2001 From: realtradam Date: Sat, 8 May 2021 05:21:24 -0400 Subject: tiles fit to menu --- run.rb | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'run.rb') diff --git a/run.rb b/run.rb index 8d30724..a5a100b 100644 --- a/run.rb +++ b/run.rb @@ -7,8 +7,9 @@ require_relative 'ui' require_relative 'input' set width: 640, height: 480 -#set width: 1280, height: 720 -#set width: 1920, height: 1080 +set width: 1280, height: 720 +set width: 1920, height: 1080 + set background: 'navy' UI.load @@ -42,7 +43,7 @@ end (0...@yep.rows).each do |row| (0...@yep.columns).each do |column| - Camera << @yep.create_image(column: column, row: row, x: (column * (128 + 12)), y: (row * (128 + 12))) + #Camera << @yep.create_image(column: column, row: row, x: (column * (128 + 12)), y: (row * (128 + 12))) end end @@ -54,6 +55,9 @@ Camera.zoom = 0.25 UI::Main.mouse_follow.objects.each do |object| Camera << object end + +UI::Popup.menubox.base.color = ['orange', 'yellow', 'red', 'maroon'] + @timer = 0 update do Camera.x += 10 if Input.held('d') @@ -68,17 +72,17 @@ update do #@selected_image.remove UI::Main.mouse_follow.x = (Camera.mouse[0] - (Camera.mouse[0] % (128 + 12) + 12)) UI::Main.mouse_follow.y = (Camera.mouse[1] - (Camera.mouse[1] % (128 + 12) + 12)) - UI::Main.history_slots.each do |item| - # Ignore if to the left of UI boxes - if (Window.mouse_x - 30).positive? && \ - # Ignore if to the right of UI boxes - (Window.mouse_x < (UI::Main.history_slots.length * 75) + 15) && \ - # If within a box, and not between 2 boxes - (((Window.mouse_x - 30) % 75) <= 60) && \ - # Ignore below boxes - (Window.mouse_y >= Window.height - 90) && \ - # Ignore above boxes - (Window.mouse_y <= Window.height - 30) + # Ignore if to the left of UI boxes + if (Window.mouse_x - 30).positive? && \ + # Ignore if to the right of UI boxes + (Window.mouse_x < (UI::Main.history_slots.length * 75) + 15) && \ + # If within a box, and not between 2 boxes + (((Window.mouse_x - 30) % 75) <= 60) && \ + # Ignore below boxes + (Window.mouse_y >= Window.height - 90) && \ + # Ignore above boxes + (Window.mouse_y <= Window.height - 30) + UI::Main.history_slots.each do |item| if item[0].contains(Window.mouse_x, Window.mouse_y) item[0].base_color = 'lime' else @@ -86,14 +90,32 @@ update do end end end + if UI::Main.popup_button.contains(Window.mouse_x, Window.mouse_y) + if Input.down('left') + UI::Main.popup_button.swap_colors = true + if UI::Popup.showing_menu = !UI::Popup.showing_menu + UI::Popup.tiles.each do |tile| + tile.add + end + UI::Main.mouse_follow.remove + else + UI::Popup.tiles.each do |tile| + tile.remove + end + UI::Main.mouse_follow.add + end + elsif Input.up('left') + UI::Main.popup_button.swap_colors = false + end + else + UI::Main.popup_button.swap_colors = false + end + #@selected_image = @yep.create_image(column: @selected_item[0], # row: @selected_item[1], # x: (Camera.mouse[0] - (Camera.mouse[0] % (128 + 12))), # y: (Camera.mouse[1] - (Camera.mouse[1] % (128 + 12)))) #Camera << @selected_image - puts "yep" if Input.down('left') - puts "yup" if Input.down('middle') - puts "yorp" if Input.down('right') Input.reset Camera.redraw end -- cgit v1.2.3