This program teaches the basics of animation by animating text with sine wave. To keep program simple I made many parameters fixed.
Things to try:
- change the animated text or better make the user enter the text (LINE 50)
- change sine wave magnitude (LINE 2020)
- change the animation resolution D (LINE 1130)
- change the wave frequency F (LINE 1120)
full program:
10 SCREEN 1
20 TITLE "Text Wave"
30 W = 1024
40 H = 768-20
50 T$ = "CBM Hand BASIC"
60 L = LEN(T$)
70 DIM CC(5)
80 CC(0) = 3
90 CC(1) = 1
100 CC(2) = 6
110 CC(3) = 3
120 CC(4) = 2
130 CC(5) = 1
140 DIM P(20, 3)
150 FSET "Commodore_64_Angled", 64
1000 C = 0
1010 FOR I = 0 TO L-1
1020 E$ = MID$(T$, I+1, 1)
1030 P(I, 0) = ASC(E$)
1040 P(I, 1) = CC(C)
1050 P(I, 2) = 180 + 50 * I
1060 P(I, 3) = 0
1070 IF P(I, 0) <> 32 THEN C = C + 1
1080 IF C = 6 THEN C = 0
1090 NEXT I
1100 PI = 3.14159
1110 T = PI * 3/4
1120 F = PI / 8
1130 D = PI / 220
2000 REM [WAVE MOVE]
2010 FOR I = 0 TO L-1
2020 P(I, 3) = H/2 + 120*SIN(T - F * I)
2030 T = T + D
2040 IF T >= 2*PI THEN T = T - 2 * PI
2050 NEXT I
3000 REM [DRAW]
3010 BEGINFRAME
3020 CLS
3030 FOR I = 0 TO L-1
3040 R$ = CHR$( P(I, 0) )
3050 C = P(I, 1)
3060 X = P(I, 2)
3070 Y = P(I, 3)
3080 GPRINT R$, X, Y, C
3090 NEXT I
3100 ENDFRAME
4000 GOTO 2000
20 TITLE "Text Wave"
30 W = 1024
40 H = 768-20
50 T$ = "CBM Hand BASIC"
60 L = LEN(T$)
70 DIM CC(5)
80 CC(0) = 3
90 CC(1) = 1
100 CC(2) = 6
110 CC(3) = 3
120 CC(4) = 2
130 CC(5) = 1
140 DIM P(20, 3)
150 FSET "Commodore_64_Angled", 64
1000 C = 0
1010 FOR I = 0 TO L-1
1020 E$ = MID$(T$, I+1, 1)
1030 P(I, 0) = ASC(E$)
1040 P(I, 1) = CC(C)
1050 P(I, 2) = 180 + 50 * I
1060 P(I, 3) = 0
1070 IF P(I, 0) <> 32 THEN C = C + 1
1080 IF C = 6 THEN C = 0
1090 NEXT I
1100 PI = 3.14159
1110 T = PI * 3/4
1120 F = PI / 8
1130 D = PI / 220
2000 REM [WAVE MOVE]
2010 FOR I = 0 TO L-1
2020 P(I, 3) = H/2 + 120*SIN(T - F * I)
2030 T = T + D
2040 IF T >= 2*PI THEN T = T - 2 * PI
2050 NEXT I
3000 REM [DRAW]
3010 BEGINFRAME
3020 CLS
3030 FOR I = 0 TO L-1
3040 R$ = CHR$( P(I, 0) )
3050 C = P(I, 1)
3060 X = P(I, 2)
3070 Y = P(I, 3)
3080 GPRINT R$, X, Y, C
3090 NEXT I
3100 ENDFRAME
4000 GOTO 2000
No comments:
Post a Comment