1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
-
|
|
|
!
| #include "d3m.hsp"
#module
#deffunc sp_calc array data, array cft, int num
n=num-2
cft(0, 2)=0.0
cft(num-1, 2)=0.0
repeat n
cft(cnt+1, 2)=3.0*(data(cnt)-2.0*data(cnt+1)+data(cnt+2))
loop
repeat n, 1
cft(cnt, 2)=(cft(cnt, 2)-cft(cnt-1, 2))/4.0
loop
repeat n, 1
cft(cnt, 2)-=cft(cnt+1, 2)/4.0
loop
repeat num
cft(cnt, 0)=data(cnt)
loop
n++
cft(n, 1)=0.0
cft(n, 3)=0.0
repeat n
cft(cnt, 3)=(cft(cnt+1, 2)-cft(cnt, 2))/3.0
cft(cnt, 1)=data(cnt+1)-data(cnt)-cft(cnt, 2)-cft(cnt, 3)
loop
return
#defcfunc sp_retXY array cft
i = int(t)
d = t - i
return cft(i, 0) + (cft(i, 1) + (cft(i, 2) + cft(i, 3) * d) * d) * d
#deffunc sp_Draw array x, array y, int num
t = 0.0
d3initlineto
while t < num
d3lineto sp_retXY(x), 0, sp_retXY(y)
t += 0.01
wend
return
#global
#const CAM_DISTANCE 500.0
#const GRID_SPAN 50
#const ANG_SPEED 0.05
n = 3
ddim x, n : ddim y, n
ddim cX, n, 4 : ddim cY, n, 4
x = -200.0, 0.0, 200.0
y = -200.0, 200.0, 0.0
sp_calc x, cX, n
sp_calc y, cY, n
theta = 1.0
title "カーソルキー左右でカメラの回転"
gosub *set_camera
need_to_redraw = 1
repeat
stick keys, 15
gosub *move_camera
gosub *draw
wait 1
loop
*move_camera
if keys & 0b101 {
theta += ANG_SPEED * ((keys >> 2 & 1) - (keys & 1))
gosub *set_camera
need_to_redraw = 1
}
return
*set_camera
d3setcam cos(theta)*CAM_DISTANCE, sin(theta)*CAM_DISTANCE, 0, 0, 0, 0
return
*draw
if need_to_redraw == 0 : return
redraw 0
color 255, 255, 255 : boxf
color 192,192,192
repeat 11, -5
d3line -GRID_SPAN * 5, 0, GRID_SPAN * cnt, GRID_SPAN * 5, 0, GRID_SPAN * cnt
d3line GRID_SPAN * cnt, 0, -GRID_SPAN * 5, GRID_SPAN * cnt, 0, GRID_SPAN * 5
loop
color : sp_Draw cX, cY, n
color ,255
repeat n
d3circle x(cnt), 0, y(cnt), 10
loop
d3pos x(0), 0, y(0) : mes "始点"
d3pos x(1), 0, y(1) : mes "オンカーブ点"
d3pos x(2), 0, y(2) : mes "終点"
redraw
need_to_redraw = 0
return
|