Alright so earlier today on the r/roblox reddit I saw a cool function a developer made and in the comments he showed the site he had gotten the idea from (https://codepen.io/jkiss/pen/OVEeqK) and I wanted to recreate it, the problem is that I suck at all java and I would like to know if it was possible for someone to give me tips on how I could turn this:
function getRandomSpeed(pos) {
var min = -1,
max = 1;
switch (pos) {
case "top":
return [randomNumFrom(min, max), randomNumFrom(0.1, max)];
break;
case "right":
return [randomNumFrom(min, -0.1), randomNumFrom(min, max)];
break;
case "bottom":
return [randomNumFrom(min, max), randomNumFrom(min, -0.1)];
break;
case "left":
return [randomNumFrom(0.1, max), randomNumFrom(min, max)];
break;
default:
return;
break;
}
}
as well as this:
function getRandomBall() {
var pos = randomArrayItem(["top", "right", "bottom", "left"]);
switch (pos) {
case "top":
return {
x: randomSidePos(can_w),
y: -R,
vx: getRandomSpeed("top")[0],
vy: getRandomSpeed("top")[1],
r: R,
alpha: 1,
phase: randomNumFrom(0, 10)
};
break;
case "right":
return {
x: can_w + R,
y: randomSidePos(can_h),
vx: getRandomSpeed("right")[0],
vy: getRandomSpeed("right")[1],
r: R,
alpha: 1,
phase: randomNumFrom(0, 10)
};
break;
case "bottom":
return {
x: randomSidePos(can_w),
y: can_h + R,
vx: getRandomSpeed("bottom")[0],
vy: getRandomSpeed("bottom")[1],
r: R,
alpha: 1,
phase: randomNumFrom(0, 10)
};
break;
case "left":
return {
x: -R,
y: randomSidePos(can_h),
vx: getRandomSpeed("left")[0],
vy: getRandomSpeed("left")[1],
r: R,
alpha: 1,
phase: randomNumFrom(0, 10)
};
break;
}
}
into a lua functioning scripts.