weight=60
height=1.65
BMI= weight/(height^2)
ideal_weight=(height*100-100)*.9
print "Body Mass Index"
'BMI>20 and BMI<22
print BMI
print "理想体重は?♪";ideal_weight;"kg"
aisatsu$ = "おはよう"
namae$ = "Mr. 山田"
print aisatsu$ ; ;;; ; namae$
print aisatsu$ ; namae$
rem 数の糸 0.9 = .9 という入力でも意味をなす。 mod = のこぎり波の生成に使える。テレビのブラウン管でも使用されている。 risouTaiju Tを大文字にすることで見やすい変数定義がされている。アンダースコア「 _ 」を使わないで、二単語の変数定義をするのが最近の流行り。(オブジェクト指向のプログラミングにて) ○○○$ ← 文字列の定義
rem BASIC only の定義 + ←文字列をつなぐ ; ←半角スペース付きの+
rem 配列 ばらばらに動かすときに使える。
seiseki(1) =2
seiseki(2) =5
print seiseki(1)
print seiseki(2)
'配列変数の書き込み(代入)
n( 0 ) =1000
n( 1 ) =1100
n( 2 ) =1200
n( 3 ) =1300
'配列変数の読み出し(出力)
print "n( 3 ) =";n( 3 )
print "n( 2 ) =";n( 2 )
print "n( 1 ) =";n( 1 )
print "n( 0 ) =";n( 0 )
'配列変数の書き込み(代入)
melo$( 0 ) ="o4C"
melo$( 1 ) ="E"
melo$( 2 ) ="G"
melo$( 3 ) ="o5C"
'配列変数の読み出し(出力)
rem *repeat
rem for i=0 to 4
rem play melo$(i)
rem next i
rem sleep 3000
rem goto *repeat
for i = 50 to 650 step 50
circle (i, 400), 10, 7,,,,f '半径10ドットの円をかく
sleep 100 '100ミリ秒休む
next i 'ループの先頭に戻る
'文字列のインプット
input "お名前をどうぞ ",yourname$
print "ようこそ"+yourname$+"さん"
'数字型のデータインプット
input "年齢をどうぞ ",age
print "80年生きれるとして、残りの余命は"
print 80-age;"っすね"
'if age < 30 then print "若いですね!" else print "若くもないけど,,,,"
'print "頑張ってください!!"
if age =<15 then gosub *veryYoung
if (age =<30 and age >15) then gosub *wakai
if age>30 then gosub *nagaiki
goto *ganbare
*veryYoung
print "すっごい若いですね"
*wakai
print "若いですね"
*nagaiki
print "長生きですね"
*ganbare
print "頑張ってください"
'gosub はサブルーチンを使って、作業の流れがはっきりしているところがgoto文より優れている。
input "くどいのは好き? yes [3] no [1]",jump
for i=1 to age step age/jump
print "何年も、";; i
play melo$( i mod 4)
next i
print "生きてきたのですね"
'サンプルプログラム 配列変数でdata読込------------
for i=0 to 12
read x(i),y(i),c(i) : x(i)=x(i)+100 : y(i)=y(i)+100
next i
for i=0 to 11
if c(i)=-1 then *next_loop
line (x(i),y(i))-(x(i+1),y(i+1)),c(i)
*next_loop
sleep 100
next i
'外側の線
data 32,0,6,67,0,6,100,100,6,70,100,6,64,80,6,35,80,6,29,100,6,0,100,6,32,0,-1
'内側の線
data 50,25,6,60,60,6,40,60,6,50,25,6
sleep 5000
*hajime
cls 3
print date$ ; time$
sleep 1000
goto *hajime
Pset(320,240),7
Pset(321,240),7
Pset(322,240),7
Pset(323,240),7
Pset(324,240),7
Pset(325,240),7
Pset(326,240),7
Pset(327,240),7
Pset(328,240),7
Pset(329,240),7
Pset(330,240),7
Pset(331,240),7
Pset(332,240),7
for i=1 to 5
Pset (332+i,240),7
x=rnd()*100+300
y=rnd()*100+240
c=rnd()*8
Pset (x,y),c
sleep 100
next i
circle(320,260),10,7
circle(340,260),10,7
circle(360,260),10,7
line (100, 100) -(200, 200) , 7
line (120, 120) -(220, 220) , 7,b
line (100, 100) -(300, 100+5) , 7,bf
line (100, 100) -(100+10, 300) , 0,bf
line (110, 100) -(110+10, 300) , 1,bf
line (120, 100) -(120+10, 300) , 2,bf
line (130, 100) -(130+10, 300) , 3,bf
line (140, 100) -(140+10, 300) , 4,bf
line (150, 100) -(150+10, 300) , 5,bf
line (160, 100) -(160+10, 300) , 6,bf
line (170, 100) -(170+10, 300) , 7,bf
for i=1 to 8
x=10*i
c=i-1
line (180+x, 100) -(180+x+10, 300) , c,bf
next i
'[] は省略可能を意味する。
for i=1 to 5
x=rnd()*100+300
y=rnd()*100+400
c=rnd()*8
circle (x,y),100*rnd(),c,,,,F
sleep 100
next i
sleep 2000
cls 3
circle(20,40),10,7
circle(30,40),10,7,,,,F
for i=1 to 100
x=rnd()*500
y=rnd()*500
c=rnd()*8
circle(x,y),10,c,,,,F
sleep 50
next i
sleep 2000
for i=1 to 100
x=rnd()*500
y=rnd()*500
c=rnd()*8
line (250,250)-(x,y),c
sleep 50
next i
cls 3
for i=1 to 100
x=500- (i*10 mod 500)
y=4*x mod 500
c=rnd()*8
line (250,250)-(x,y),c
sleep 50
next i
for i=1 to 4
b=0.5+(i-1)*0.25
circle(150,150),100,7,,,b
next i
circle(350,150),100,7,,,0.5
circle(350,150),100,7,,,0.25
circle(350,150),100,7,,,2
circle(350,150),100,7,,,4
circle(150,300),100,7,,,0.5,f
circle(150,300),50,0,,,2,f
sleep 2000
cls 3
circle(290,380),50,7,-1,-6
circle(290,380),50,6,-2,-5
For x=0 to 15 step 0.02
y=sin(x)
gy=50*y+200
gx=50*x+50
pset (gx,gy)
next i
For x=0 to 20 step 0.005
y=sin(x)
gy=50*y+200
gx=50*x+50
circle (gx,gy),5,7,,,,f
next i
For x=0 to 300 step 0.02
y=sin(x)
gy = y*50+200
gx = x*30
pset(gx,gy)
next x
pai = 3.14159
n=32
for rd = 0 to 2*pai+.1 step 2*pai/n '+.1は計算誤差解消
x = 320+100*sin(rd) '320,240は中心座標。100は直径(ドット)
y = 240-100*cos(rd)+30*rnd()
if flag=1 then *connect
pset (x,y),7
*connect
line -(x,y),7
flag = 1
next rd
For theta=0 to 6.28 step 0.02
r=rnd()
x=cos(theta)
y=sin(theta)
gy = r*y*50+75
gx = r*x*50+75
pset(gx,gy)
next theta
For theta=0 to 6.28 step 0.02
r=cos(theta-3.14/4)*(theta-3.14/4)
x=sin(theta)
y=cos(theta)
gy = r*y*50+75
gx = r*x*50+150
pset(gx,gy)
next theta
sleep 10000
cls 3
For xshift=50 to 450 step 10
for y=0 to 15 step 0.02
x=sin(y+xshift/50)
gx = x*20+xshift
gy = y*50
pset(gx,gy)
next y
next xshift
For xshift=490 to 600 step 10
for y=0 to 15 step 0.02
x=sin(y-xshift/50+9)
gx = x*20+xshift
gy = y*50
pset(gx,gy)
next y
next xshift
line (100, 100) -(100+10, 300) , rgb(255,0,0),bf
line (110, 100) -(110+10, 300) , rgb(0,255,0),bf
line (120, 100) -(120+10, 300) , rgb(0,0,255),bf
line (130, 100) -(130+10, 300) , rgb(255,255,0),bf
line (140, 100) -(140+10, 300) , rgb(255,0,255),bf
line (150, 100) -(150+10, 300) , rgb(0,255,255),bf
line (160, 100) -(160+10, 300) , rgb(224,238,238),bf
line (170, 100) -(170+10, 300) , rgb(143,188,143),bf
for i=1 to 8
x=10*i
c=i-1
line (180+x, 100) -(180+x+10, 300) , c,bf
next i
'[] は省略可能を意味する。
for i=1 to 5
x=rnd()*100+300
y=rnd()*100+400
c=rnd()*8
circle (x,y),100*rnd(),c,,,,F
sleep 100
next i
for t=1 to 1080 step 0.02
r=t/10
theta=t
x=r*sin(theta)+500
y=r*cos(theta)+200
Pset (x,y),7
next t
cls 3
for j=1 to 3
for i = 50 to 700 step 50
x=i
y=-0.001*(i-400)^2+400
line (400, 100)-(400+(x-400)*0.98, 100+(y-100)*0.98) , rgb(143,188,143)
circle( x , y ),10,7,,,,f
sleep 100
cls 3
next i
for i = 700 to 50 step -50
x=i
y=-0.001*(i-400)^2+400
line (400, 100)-(400+(x-400)*0.98, 100+(y-100)*0.98) , rgb(143,188,143)
circle( x , y ),10,7,,,,f
sleep 100
cls 3
next i
next j
'昔はi と書くと、暗黙のうちに整数(integer)型と考えられた
cls 3
for i = 50 to 650 step 5
circle(i,160),30,rgb(139,69,0),,,,f
next i
for i = 50 to 650 step 50
circle(i,200),10,rgb(238,0,0),,,,f
next i
for i = 50 to 650 step 50
circle(i,240),20,rgb(139,69,19),,,,f
next i
for i = 50 to 650 step 100
circle(i,280),10,rgb(118,238,0),,,,f
next i
for i = 50 to 650 step 5
circle(i,320),30,rgb(139,69,0),,,,f
next i
sleep 2000
cls 3
for x=0 to 400 step 25
for y=0 to 400 step 25
circle(x+200,y+50),10,7,,,,f
sleep 100
next y
next x
cls 3
*start
cls 3
for i=1 to 12
circle(rnd()*700,rnd()*480),10,7,,,,f
next i
sleep 2000
goto *start
Randomize'今日の日付、時間を元に、ランダムな数列を作る
ShowWnd OwnerWnd(), SW_MAXIMIZE
ShowWnd OwnerWnd(), SW_MAXIMIZE
for t =1 to 100 step 0.01
circle (400,400),30,5,,,,f
r=150
x=2*r*sin(2*t)
y=1*r*cos(2*t)
ry=-1/1.414*x +1/1.414*y+400
rx=1/1.414*x +1/1.414*y+400
circle (rx,ry),10,2,,,,f
r=100
x=2*r*sin(t)
y=r*cos(t)
ry=-1/1.414*x +1/1.414*y+400
rx=1/1.414*x +1/1.414*y+400
circle (rx,ry),10,7,,,,f
r2=30
r2x= r2*sin(10*t)+rx
r2y= r2*cos(10*t)+ry
circle (r2x,r2y),5,6,,,,f
sleep 5
cls 3
next t
2009/7/23
*Randomize
ShowWnd OwnerWnd(), SW_MAXIMIZE
circle(i,200),10,7,,,,f
'空
for i=0 to 300
line (0,18) - (1024,18+i),rgb(191,239,255),bf
next i
'浜と海
for i=0 to 500
'浜
line (0,300+i)-(300+0.6*i,300+i),rgb(240,230,140),bf
'海
line (1024,300+i)-(300+0.6*i+1,300+i),rgb(0,0,128),bf
next i
'浜のアクセント 1
for i=1 to 100
circle (rnd()*300,300+rnd()*(860-300)),2,rgb(139,71,38),,,,f
next i
'浜のアクセント 2
for i=1 to 40
t=(860-300)*rnd()
y= 300+t
x= 300+t*0.6*rnd()
circle (x,y),2,rgb(139,71,38),,,,f
next i
'(300+0.6*i+1,300+i
for s=0 to 100
for i=0 to 500
' circle (300+0.6*i+3+100-s,300+i),1,rgb(224,238,238),,,,f
' circle (300+0.6*i+3+100+1-s,300+i),1,rgb(0,0,128),,,,f
x=rnd()*20
x500[i]=x
Pset (300+0.6*i+3+100-s+x500[i],300+i),rgb(224,238,238)
Pset (300+0.6*i+3+100+1-s+x500[i],300+i),rgb(0,0,128)
Pset (300+0.6*i+3+100+2-s+x500[i],300+i),rgb(0,0,128)
Pset (300+0.6*i+3+100+3-s+x500[i],300+i),rgb(0,0,128)
Pset (300+0.6*i+3+100+4-s+x500[i],300+i),rgb(0,0,128)
Pset (300+0.6*i+3+100+5-s+x500[i],300+i),rgb(0,0,128)
next i
'sleep 5
line (300+0.6*i+100-s+10,300)-(300+0.6*i+100-s+10+300,860),rgb(0,0,128),bf
next s
2009/8/14
ShowWnd OwnerWnd(), SW_MAXIMIZE
*Randomize
'空
for i=0 to 300
line (0,18) - (1024,i),rgb(191,239,255),bf
next i
'浜と海
'ただし、左上から右下へ、斜めに浜のラインを引く。そのため、lineコマンドでx座標がy座標(300+i)に比例して増えるようにしている。
'ウィンドウマックスのサイズを1024*860と仮定しておく。
for i=0 to 500
'浜
line (0,300+i)-(300+0.6*i,300+i),rgb(240,230,140),bf
'海
line (1024,300+i)-(300+0.6*i+1,300+i),rgb(0,0,128),bf
next i
'浜のアクセント 1
for i=1 to 100
circle (rnd()*300,300+rnd()*(720-300)),2,rgb(139,71,38),,,,f
next i
'浜のアクセント 2
for i=1 to 40
t=(720-300)*rnd()
y= 300+t
x= 300+t*0.6*rnd()
circle (x,y),2,rgb(139,71,38),,,,f
next i
for d=1 to 3
if d=2 then goto *yuugata else if d=3 then goto *yozora else *soraend
*yuugata
'夕空
for i=0 to 300
line (0,18) - (1024,i),rgb(255,153,0),bf
next i
goto *soraend
*yozora
for i=0 to 300
line (0,18) - (1024,i),rgb(0,0,0),bf
next i
goto *soraend
*soraend
'波
'iが増える→y座標の増加に伴い、x座標をランダムに変化させる
'sが増える→白い波が岸による
for s=0 to 380 step 10
for i=0 to 500
if s=0 then goto *cl else goto *ncl
*cl
line (300-0.05*i+380-s+60,300)-(300-0.05*i+380-s+560*0.6+60,860),rgb(0,0,128)
goto *ncl
*ncl
' circle (300+0.6*i+3+100-s,300+i),1,rgb(224,238,238),,,,f
' circle (300+0.6*i+3+100+1-s,300+i),1,rgb(0,0,128),,,,f
x=rnd()*20
x500[i]=x
Pset (300+0.6*i+3+380-s+x500[i],300+i),rgb(224,238,238)
Pset (300+0.6*i+3+380+1-s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+2-s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+3-s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+4-s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+5-s+x500[i],300+i),rgb(0,0,128)
line (300-0.02*i+380-s+35,300)-(300-0.02*i+380-s+560*0.6+35,860),rgb(0,0,128)
next i
'sleep 5
'花火
if d=3 then goto *firework else *notfirework
*firework
if s<160 then goto *up else *open
*up
line (650,300-s)- (655,300-s-10),rgb(255,255,0),bf
line (650,300-s)- (655,300-s+10),0,bf
if s=10 then goto *bl else *fini
*bl
line (650,300)- (655,300-s),0,bf
goto *fini
*open
if s>300 then goto *fini
line (650,150)- (655,150-10),0,bf
line (650,150)-(650+100*cos(pre),150+100*sin(pre)),0
theta = 2*3.1415*rnd()
pre =theta
c=rnd()*8
line (650,150)-(650+100*cos(theta),150+100*sin(theta)),c
*fini
line (650,150)-(650+100*cos(pre),150+100*sin(pre)),0
sleep 100
goto *notfirework
*notfirework
next s
'波2
'iが増える→y座標の増加に伴い、x座標も比例して増やすが、±20だけランダムに変化させる
'sが増える→白い波が岸から離れる
for s=0 to 400 step 20
for i=0 to 500
' circle (300+0.6*i+3+100-s,300+i),1,rgb(224,238,238),,,,f
' circle (300+0.6*i+3+100+1-s,300+i),1,rgb(0,0,128),,,,f
x=rnd()*20
x500[i]=x
Pset (300+0.6*i+3+s+x500[i],300+i),rgb(224,238,238)
Pset (300+0.6*i+3+1+s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+2-s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+3-s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+4-s+x500[i],300+i),rgb(0,0,128)
'Pset (300+0.6*i+3+100+5-s+x500[i],300+i),rgb(0,0,128)
if s =0 then goto *left else goto *right
*left
line (300+s-0.04*i,300)-(300+s-0.04*i+560*0.6,860),rgb(0,0,128)
goto *tugi
*right
if s=20 then goto *hama else goto *tuduki
*hama
line (300-s+0.04*i,300)-(300-s+0.04*i+560*0.6,860),rgb(240,230,140)
line (300+s+0.04*i-20,300)-(300+s+0.04*i-20+560*0.6,860),rgb(0,0,128)
goto *tuduki
*tuduki
line (300+s+0.04*i-20,300)-(300+s+0.04*i-20+560*0.6,860),rgb(0,0,128)
y=rnd()*20
y500[i]=y
Pset (300+0.6*i+560-(s-260)+y500[i],300+i),rgb(224,238,238)
Pset (300+0.6*i+1+560-(s-260)+y500[i],300+i),rgb(0,0,128)
line (300-(s-260)-0.04*i+560+40,300)-(300-(s-260)-0.04*i+560+560*0.6+40,860),rgb(0,0,128)
goto *tugi
'line (300+s+1,300)-(300+s+560*0.6+1,860),rgb(0,0,128)
'line (300+s+2,300)-(300+s+560*0.6+2,860),rgb(0,0,128)
'line (300+s+3,300)-(300+s+560*0.6+3,860),rgb(0,0,128)
'line (300+s+4,300)-(300+s+560*0.6+4,860),rgb(0,0,128)
'line (300+s+5,300)-(300+s+560*0.6+5,860),rgb(0,0,128)
'line (300+s+6,300)-(300+s+560*0.6+6,860),rgb(0,0,128)
'line (300+s+7,300)-(300+s+560*0.6+7,860),rgb(0,0,128)
'line (300+s+8,300)-(300+s+560*0.6+8,860),rgb(0,0,128)
'line (300+s+9,300)-(300+s+560*0.6+9,860),rgb(0,0,128)
*tugi
next i
next s
next d
最終更新:2009年08月14日 22:08