From 65a2d6b1a452fe2a545d6cefd0be7efa5ef67648 Mon Sep 17 00:00:00 2001 From: Ljon4ik4 Date: Wed, 6 Jan 2021 20:03:12 +0100 Subject: [PATCH 1/3] going around the edges of the screen option added in the new option the scene item will move to the right and then around the edges in the order: down, left, up, right etc. --- bounce.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/bounce.lua b/bounce.lua index c7f6217..f3bf2d6 100644 --- a/bounce.lua +++ b/bounce.lua @@ -97,6 +97,7 @@ function script_properties() obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_list_add_string(bounce_type, 'DVD Bounce', 'dvd_bounce') obs.obs_property_list_add_string(bounce_type, 'Throw & Bounce', 'throw_bounce') + obs.obs_property_list_add_string(bounce_type, 'Go around the edges', 'go_around') obs.obs_properties_add_int_slider(props, 'speed', 'DVD Bounce Speed:', 1, 30, 1) obs.obs_properties_add_int_slider(props, 'throw_speed_x', 'Max Throw Speed (X):', 1, 200, 1) obs.obs_properties_add_int_slider(props, 'throw_speed_y', 'Max Throw Speed (Y):', 1, 100, 1) @@ -160,6 +161,8 @@ function script_tick(seconds) move_scene_item(scene_item) elseif bounce_type == 'throw_bounce' then throw_scene_item(scene_item) + elseif bounce_type == 'go_around' then + go_around(scene_item) end end end @@ -299,6 +302,33 @@ function throw_scene_item(scene_item) obs.obs_sceneitem_set_pos(scene_item, next_pos) end + +function go_around(scene_item) + local pos, width, height = get_scene_item_dimensions(scene_item) + local next_pos = obs.vec2() + + if moving_right and moving_down then + next_pos.x = math.min(pos.x + speed, scene_width - width) + next_pos.y = pos.y + if next_pos.x == scene_width - width then moving_right = false end + elseif (not moving_right) and moving_down then + next_pos.y = math.min(pos.y + speed, scene_height - height) + next_pos.x = pos.x + if next_pos.y == scene_height - height then moving_down = false end + elseif (not moving_right) and (not moving_down) then + next_pos.x = math.max(pos.x - speed, 0) + next_pos.y = pos.y + if next_pos.x == 0 then moving_right = true end + elseif moving_right and (not moving_down) then + next_pos.y = math.max(pos.y - speed, 0) + next_pos.x = pos.x + if next_pos.y == 0 then moving_down = true end + end + obs.obs_sceneitem_set_pos(scene_item, next_pos) +end + + + --- toggle bouncing the scene item, restoring its original position if stopping function toggle() if active then From 39b6acfcb93da1c743b40f78f3dfd44c6aa1b00c Mon Sep 17 00:00:00 2001 From: Ljon4ik4 Date: Wed, 6 Jan 2021 20:08:06 +0100 Subject: [PATCH 2/3] renamed the label of the speed slider could not think of a better title that does not get too long --- bounce.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bounce.lua b/bounce.lua index f3bf2d6..badcf22 100644 --- a/bounce.lua +++ b/bounce.lua @@ -98,7 +98,7 @@ function script_properties() obs.obs_property_list_add_string(bounce_type, 'DVD Bounce', 'dvd_bounce') obs.obs_property_list_add_string(bounce_type, 'Throw & Bounce', 'throw_bounce') obs.obs_property_list_add_string(bounce_type, 'Go around the edges', 'go_around') - obs.obs_properties_add_int_slider(props, 'speed', 'DVD Bounce Speed:', 1, 30, 1) + obs.obs_properties_add_int_slider(props, 'speed', '(non-throwing) Speed:', 1, 30, 1) obs.obs_properties_add_int_slider(props, 'throw_speed_x', 'Max Throw Speed (X):', 1, 200, 1) obs.obs_properties_add_int_slider(props, 'throw_speed_y', 'Max Throw Speed (Y):', 1, 100, 1) obs.obs_properties_add_bool(props, 'start_on_scene_change', 'Start on scene change') From 5ce10c9631fda34a1d51492240f4a12f8d2c4ed0 Mon Sep 17 00:00:00 2001 From: Ljon4ik4 Date: Wed, 6 Jan 2021 20:09:57 +0100 Subject: [PATCH 3/3] (sliding around the edges) option added --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c19758..5b36710 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # obs-bounce -OBS script to bounce a scene item around, DVD logo style or throw & bounce with physics. +OBS script to bounce a scene item around, DVD logo style, let it slide around the edges or throw & bounce with physics. ## Usage