Skip to content

Commit 7984b90

Browse files
committed
Demo
1 parent ad1576d commit 7984b90

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

json/graphics-demo.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"#": [
3+
4+
"Photo",
35
"BlueRect",
4-
"RedEllipse",
5-
"Photo"
6+
"RedEllipse"
67
],
78
"BlueRect": {
89
"type": "rectangle",

scripts/graphics-demo.ecs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@
55
rectangle BlueRect
66
ellipse RedEllipse
77
ellipse GreenCircle
8-
text WhiteText
98
file File
109
variable Spec
1110
variable UpDown
1211
variable Left
1312
variable Top
13+
variable Steps
14+
variable Step
15+
variable DX
16+
variable DY
1417
variable N
18+
variable X
19+
variable Y
20+
variable L
21+
variable T
1522

1623
! debug step
1724

@@ -29,9 +36,8 @@
2936
on click RedEllipse print `Click Red`
3037
attach GreenCircle to `greencircle`
3138
on click GreenCircle print `Click Green`
32-
33-
put attribute `left` of RedEllipse into Left
34-
put attribute `top` of RedEllipse into Top
39+
40+
gosub to InitEllipse
3541

3642
clear UpDown
3743
put 0 into N
@@ -48,8 +54,6 @@
4854
put 0 into N
4955
clear UpDown
5056
end
51-
move RedEllipse to Left Top
52-
add 5 to Left
5357
end
5458
else
5559
begin
@@ -62,10 +66,34 @@
6266
put 0 into N
6367
set UpDown
6468
end
65-
move RedEllipse to Left Top
66-
take 5 from Left
6769
end
6870
increment N
71+
gosub to MoveEllipse
6972
end
7073
show screen
7174
stop
75+
76+
InitEllipse:
77+
put attribute `left` of RedEllipse into Left
78+
put attribute `top` of RedEllipse into Top
79+
put random 340 into X
80+
put random 280 into Y
81+
add 50 to X
82+
add 50 to Y
83+
take Left from X giving DX
84+
take Top from Y giving DY
85+
put 20 into Steps
86+
put 0 into Step
87+
return
88+
89+
MoveEllipse:
90+
multiply DX by Step giving X
91+
divide X by Steps
92+
add X to Left giving L
93+
multiply DY by Step giving Y
94+
divide Y by Steps
95+
add Y to Top giving T
96+
move RedEllipse to L T
97+
increment Step
98+
if Step is Steps gosub to InitEllipse
99+
return

0 commit comments

Comments
 (0)