Skip to content

Commit a9d0135

Browse files
authored
Update rolling cube.red
1 parent e0b751d commit a9d0135

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

rolling cube.red

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
Red [
22
Title: "Rolling box"
3-
Author: "Galen Ivanov"
4-
Date: 02-09-2021
3+
Author: "Galen Ivanov"
4+
Date: 02-09-2021
55
]
66
rot: 0
77
trans: 0x0
88
st-time: 0
99

1010
easeInOutQubic: function [x][
1111
either x < 0.5 [x ** 3 * 4][1 - (-2 * x + 2 ** 3 / 2)]
12-
;x ** 3
1312
]
1413

1514
update: func [
1615
/local frame val
1716
]
1817
[
19-
now/precise
20-
frame: to float! difference now/precise st-time
21-
frame: frame % 1.0
22-
23-
rot: 90 * val: easeInOutQubic frame
24-
if val > 0.98 [
25-
st-time: now/precise
26-
rot: 0
27-
trans: trans + 100x0 % 700x10
28-
roll/2: trans
29-
]
30-
roll/4: rot
18+
now/precise
19+
frame: to float! difference now/precise st-time
20+
frame: frame % 1.0
21+
22+
rot: 90 * val: easeInOutQubic frame
23+
if val > 0.98 [
24+
st-time: now/precise
25+
rot: 0
26+
trans: trans + 100x0 % 700x10
27+
roll/2: trans
28+
]
29+
roll/4: rot
3130
]
3231

3332
view [
3433
title "Rolling box"
3534
base 600x200 teal rate 120
36-
draw [
37-
line 0x180 600x180
38-
fill-pen yello
39-
roll: translate 0x0 rotate 0 0x180 [box -100x80 0x180]
40-
]
41-
on-time [ update ]
42-
on-create [st-time: now/precise]
43-
]
35+
draw [
36+
line 0x180 600x180
37+
fill-pen yello
38+
roll: translate 0x0 rotate 0 0x180 [box -100x80 0x180]
39+
]
40+
on-time [ update ]
41+
on-create [st-time: now/precise]
42+
]

0 commit comments

Comments
 (0)