diff options
| author | realtradam <[email protected]> | 2021-05-05 06:45:59 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-05-05 06:45:59 -0400 |
| commit | 200d6ec73caf9c070375a972677c4c0af7c444ba (patch) | |
| tree | c1740919c86904ddf35701dc922fb763b528073d /run.rb | |
| parent | a62ac5e77570516c399f9bad114aaba7bf20ff67 (diff) | |
| download | tileset-map-editor-200d6ec73caf9c070375a972677c4c0af7c444ba.tar.gz tileset-map-editor-200d6ec73caf9c070375a972677c4c0af7c444ba.zip | |
.
Diffstat (limited to 'run.rb')
| -rw-r--r-- | run.rb | 41 |
1 files changed, 32 insertions, 9 deletions
@@ -3,9 +3,12 @@ require 'ruby2d' require_relative 'lib/camera/camera' require_relative 'tileset' +require_relative 'ui-tools' set width: 1024, height: 720 +set background: 'navy' + @eks = 0 @why = 0 @@ -26,17 +29,21 @@ end on :mouse_up do |event| case event.button when :left - @new = @yep.create_image(column: @selected_item[0], - row: @selected_item[1], - x: Window.mouse_x - (Window.mouse_x % 128), - y: Window.mouse_y - (Window.mouse_y % 128)) + @new = @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 << @new end end on :mouse_scroll do |event| @selected_item[0] += event.delta_y - @selected_item[1] += @selected_item[0] / @yep.columns + if @selected_item[0] >= @yep.columns + @selected_item[1] = (@selected_item[1] + 1) % @yep.rows + elsif @selected_item[0].negative? + @selected_item[1] = (@selected_item[1] - 1) % @yep.rows + end @selected_item[0] %= @yep.columns - @selected_item[1] %= @yep.rows end @yep = Tileset.new('./assets/kenny/PNG/128', 128, 128) @@ -48,7 +55,7 @@ end ([email protected]).each do |row| ([email protected]).each do |column| - Camera << @yep.create_image(column: column, row: row, x: (column * 128) + (12 * column), y: (row * 128) + (row * 12)) + Camera << @yep.create_image(column: column, row: row, x: (column * (128 + 12)), y: (row * (128 + 12))) end end @@ -57,12 +64,28 @@ end Camera.zoom = 0.25 +@textbox = UIToolkit::Textbox::RoundedTextbox.new(y: Window.height - 100, height: 100, width: Window.width, border_width: 35, base_color: 'fuchsia') +@borderbox = UIToolkit::Borderbox.new(height: 100, width: Window.width - 30, border_width: 15, base_color: 'fuchsia') + +@timer = 0 update do + @timer += 1 + @timer %= 60 + if (@timer % 30).zero? + @textbox.base_color = Color.new 'random' + @textbox.x += 1 + @textbox.y -= 1 + @textbox.width -= 15 + @borderbox.base_color = Color.new 'random' + puts @textbox.x + end + Camera.remove @selected_image @selected_image.remove @selected_image = @yep.create_image(column: @selected_item[0], row: @selected_item[1], - x: (Window.mouse_x - (Window.mouse_x % 128)), - y: (Window.mouse_y - (Window.mouse_y % 128))) + x: (Camera.mouse[0] - (Camera.mouse[0] % (128 + 12))), + y: (Camera.mouse[1] - (Camera.mouse[1] % (128 + 12)))) + Camera << @selected_image Camera.redraw end |
