-
-
Save dockimbel/abb88c6906230411243fc2af13357315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Title: "Bouncing Boxes Connected" | |
Needs: View | |
] | |
Arial: make font! [size: 14 name: "Consolas" style: 'bold] | |
view [ | |
title "Bouncing Boxes Connected" | |
size 400x400 | |
box1: base 30x30 draw [line-width 3 fill-pen red box 0x0 30x30] rate 25 on-time [ | |
face/offset: face/offset + (face/extra * 5x5) | |
if face/offset/x + face/size/x > face/parent/size/x [face/extra/x: -1] | |
if face/offset/y + face/size/y > face/parent/size/y [face/extra/y: -1] | |
if face/offset/x < 0 [face/extra/x: 1] | |
if face/offset/y < 0 [face/extra/y: 1] | |
] | |
do [box1/extra: 1x-1 box1/color: none] | |
box2: base 30x30 draw [line-width 3 fill-pen blue box 0x0 30x30] rate 25 on-time [ | |
face/offset: face/offset + (face/extra * 7x7) | |
if face/offset/x + face/size/x > face/parent/size/x [face/extra/x: -1] | |
if face/offset/y + face/size/y > face/parent/size/y [face/extra/y: -1] | |
if face/offset/x < 0 [face/extra/x: 1] | |
if face/offset/y < 0 [face/extra/y: 1] | |
] | |
do [box2/extra: 1x-1 box2/color: none] | |
line: base 400x400 draw [ | |
font Arial | |
pen 1.125.125 | |
line-width 3 | |
l: line 0x0 30x30 | |
t: text 10x10 "Start" | |
] rate 50 on-time [ | |
l/2: box1/offset + 15x15 | |
l/3: box2/offset + 15x15 | |
either l/2/x > l/3/x [ | |
t/2: ((l/2 - l/3) / 2) + l/3 | |
either l/2/y > l/3/y [ | |
t/3: mold to integer! square-root ((((l/2/x - l/3/x) ** 2) + ((l/2/y - l/3/y) ** 2))) | |
] | |
[ | |
t/3: mold to integer! square-root ((((l/2/x - l/3/x) ** 2) + ((l/3/y - l/2/y) ** 2))) | |
] | |
] | |
[ | |
t/2: ((l/3 - l/2) / 2) + l/2 | |
either l/3/y > l/2/y [ | |
t/3: mold to integer! square-root ((((l/3/x - l/2/x) ** 2) + ((l/3/y - l/2/y) ** 2))) | |
] | |
[ | |
t/3: mold to integer! square-root ((((l/3/x - l/2/x) ** 2) + ((l/2/y - l/3/y) ** 2))) | |
] | |
] | |
] | |
do [line/offset: 0x0 line/color: none] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment