Microsoft Small Basic

Program Listing: TXG145-0
' mahreen miangul
' Alphabets MaY 2019
' modified by Nonki Takahashi

GraphicsWindow.Title = "mahreen miangul
GraphicsWindow.Width = 1100
GraphicsWindow.Height = 550
GraphicsWindow.FontSize = 88

'haroon 1
'write Alphabets and Set brush color
GraphicsWindow.Clear()
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
shapeA = Shapes.AddText("A")
Shapes.Move(shapeA,0,200)

GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
shapeB = Shapes.AddText("B")
Shapes.Move(shapeB,60,170)

GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
shapeC = Shapes.AddText("C")
Shapes.Move(shapeC,120,140)

GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
shapeD = Shapes.AddText("D")
Shapes.Move(shapeD,180,110)

GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
shapeE = Shapes.AddText("E")
Shapes.Move(shapeE,240,80)

GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
shapeF = Shapes.AddText("F")
Shapes.Move(shapeF,300,50)

alphabet = "GHIJKLMNOP"
x = 60
y = 260
DrawAlphabet()
alphabet = "QRSTUVWXYZ"
x = 120
y = 320
DrawAlphabet()

'haroon rashid 2
'Drag&Drop Alphabets on GraphicsWindow
GraphicsWindow.MouseDown = OnMouseDown
GraphicsWindow.MouseUp = OnMouseUp

mouseMoving = 0

SPRITE_init() ' <--------- all shape data is input here!!
add_shapes() ' <--------- all shapes are added here!!

'GraphicsWindow.brushColor = GraphicsWindow.GetColorFromRGB(100, 200, 150)
'GraphicsWindow.FontSize = 55
'miangul = Shapes.Addtext("M O U S E")
'Shapes.Move(miangul, 0, 0)
'Shapes.Animate(miangul, 600, 10, 2000)

'GraphicsWindow.brushColor = GraphicsWindow.GetColorFromRGB(500, 100, 150)
'miangul = Shapes.Addtext("D R A G and D R O P")
'Shapes.Move(miangul, 0, 0)
'Shapes.Animate(miangul, 450, 70, 2000)

While ("True")
If (shapeAMoving = 1) Then
Shapes.Move(shapeA,GraphicsWindow.MouseX-shapeA_X,GraphicsWindow.MouseY-shapeA_Y)
EndIf
If (shapeBMoving = 1) Then
Shapes.Move(ShapeB,GraphicsWindow.MouseX-ShapeB_X,GraphicsWindow.MouseY-ShapeB_Y)
EndIF
If (shapeCMoving = 1) Then
Shapes.Move(shapeC,GraphicsWindow.MouseX-shapeC_X,GraphicsWindow.MouseY-shapeC_Y)
EndIf
If (shapeDMoving = 1) Then
Shapes.Move(ShapeD,GraphicsWindow.MouseX-ShapeD_X,GraphicsWindow.MouseY-ShapeD_Y)
EndIf
If (shapeEMoving = 1) Then
Shapes.Move(shapeE,GraphicsWindow.MouseX-shapeE_X,GraphicsWindow.MouseY-shapeE_Y)
EndIf
If (shapeFMoving = 1) Then
Shapes.Move(ShapeF,GraphicsWindow.MouseX-ShapeF_X,GraphicsWindow.MouseY-ShapeF_Y)
EndIf
Program.Delay(20) 'Don't mash cpu in game loop
EndWhile

Sub DrawAlphabet
For i = 1 To Text.GetLength(alphabet)
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
shapeAlphabet = Shapes.AddText(Text.GetSubText(alphabet, i, 1))
Shapes.Move(shapeAlphabet, x, y)
x = x + 60
y = y - 30
EndFor
EndSub

Sub OnMouseDown
mx = GraphicsWindow.MouseX
my = GraphicsWindow.MouseY

'Relative coordinates of mouse to shape - we use these in the drag movement so the shape doesn't recenter, but just drag from current mouse position
shapeA_X = mx-Shapes.GetLeft(shapeA)
shapeA_Y = my-Shapes.GetTop(shapeA)
If (shapeA_X >= 0 And shapeA_X <= 40 And shapeA_Y >= 0 And shapeA_Y <= 100) Then
shapeAMoving = 1
EndIf

ShapeB_X = mx-Shapes.GetLeft(ShapeB)
ShapeB_Y = my-Shapes.GetTop(ShapeB)
If (ShapeB_X >= 0 And ShapeB_X <= 40 And ShapeB_Y >= 0 And ShapeB_Y <= 100) Then
shapeBMoving = 1
EndIf

shapeC_X = mx-Shapes.GetLeft(shapeC)
shapeC_Y = my-Shapes.GetTop(shapeC)
If (shapeC_X >= 0 And shapeC_X <= 40 And shapeC_Y >= 0 And shapeC_Y <= 100) Then
shapeCMoving = 1
EndIf

ShapeD_X = mx-Shapes.GetLeft(ShapeD)
ShapeD_Y = my-Shapes.GetTop(ShapeD)
If (ShapeD_X >= 0 And ShapeD_X <= 40 And ShapeD_Y >= 0 And ShapeD_Y <= 100) Then
shapeDMoving = 1
EndIf

shapeE_X = mx-Shapes.GetLeft(shapeE)
shapeE_Y = my-Shapes.GetTop(shapeE)
If (shapeE_X >= 0 And shapeE_X <= 40 And shapeE_Y >= 0 And shapeE_Y <= 100) Then
shapeEMoving = 1
EndIf

ShapeF_X = mx-Shapes.GetLeft(ShapeF)
ShapeF_Y = my-Shapes.GetTop(ShapeF)
If (ShapeF_X >= 0 And ShapeF_X <= 40 And ShapeF_Y >= 0 And ShapeF_Y <= 100) Then
shapeFMoving = 1
EndIf
endsub

Sub OnMouseUp
shapeAMoving = 0
shapeBMoving = 0
shapeCMoving = 0
shapeDMoving = 0
shapeEMoving = 0
shapeFMoving = 0
EndSub

Sub add_shapes
For M=1 to Array.GetItemCount(s) ' 7 types shapes //Human , House, Tree, duck , cycle, Apple , Bee
For N=1 to Array.GetItemCount(s[M]) ' repeat number //Human=1 ,House=1 ,Tree=12, duck=7 , cycle=1, Apple=16 , Bee=1
ss=s[M][N] ' scale
_shx=shx[M][N] ' base point _X
_shY=shY[M][N] ' base point _Y
_shape=shape[M] ' temporary shape data
NMB=M+":"+N ' shape index
for i=1 To Array.GetItemCount(_shape)
GraphicsWindow.PenWidth = _shape[i]["pw"]
GraphicsWindow.BrushColor = _shape[i]["bc"]
GraphicsWindow.penColor = _shape[i]["pc"]
If _shape[i]["func"]="ell" Then
shp[NMB][i] = Shapes.AddEllipse(_shape[i]["width"]*ss, _shape[i]["height"]*ss)
ElseIf _shape[i]["func"]="rect" Then
shp[NMB][i] = Shapes.AddRectangle(_shape[i]["width"]*ss, _shape[i]["height"]*ss)
ElseIf _shape[i]["func"]="tri" Then
shp[NMB][i] = Shapes.Addtriangle(_shape[i]["x1"]*ss, _shape[i]["y1"]*ss,_shape[i]["x2"]*ss, _shape[i]["y2"]*ss, _shape[i]["x3"]*ss, _shape[i]["y3"]*ss)
ElseIf _shape[i]["func"]="line" Then '<----
shp[NMB][i] = Shapes.Addline(_shape[i]["x1"]*ss, _shape[i]["y1"]*ss,_shape[i]["x2"]*ss, _shape[i]["y2"]*ss)
EndIf
Shapes.Animate(shp[NMB][i], _shape[i]["x"]*ss+_shX, _shape[i]["y"]*ss+_shY, 500)
Shapes.Rotate(shp[NMB][i], _Shape[i]["angle"])
EndFor
endfor
endfor
EndSub
Sub SPRITE_init' 14 Trees
s[1]="1=0.5;2=0.5;3=0.5;4=0.5;5=0.5;6=0.5;7=0.5;8=0.5;9=0.5;10=0.5;11=0.5;12=0.5;13=0.5;14=0.5"
shX[1]="1=0;2=30;3=60;4=90;5=120;6=150;7=180;8=210;9=240;10=270;11=300;12=330;13=360;14=390"
shY[1]="1=340;2=340;3=340;4=340;5=340;6=340;7=340;8=340;9=340;10=340;11=340;12=340;13=340;14=340"
shape[1][1]="func=ell;X=0;Y=188;width=200;height=140;bc=Green;pc=Green;pw=2"
shape[1][2]="func=ell;X=10;Y=277;width=80;height=60;bc=Green;pc=Green;pw=2"
shape[1][3]="func=ell;X=4;Y=255;width=80;height=70;bc=Green;pc=Green;pw=2;"
shape[1][4]="func=ell;X=0;Y=191;width=80;height=80;bc=Green;pc=Green;pw=2;"
shape[1][5]="func=ell;X=40;Y=177;width=80;height=80;bc=Green;pc=Green;pw=2"
shape[1][6]="func=ell;X=100;Y=177;width=120;height=80;bc=Green;pc=Green;pw=2"
shape[1][7]="func=ell;X=130;Y=240;width=100;height=80;bc=Green;pc=Green;pw=2;"
shape[1][8]="func=ell;X=130;Y=260;width=100;height=80;bc=Green;pc=Green;pw=2;"
shape[1][9]="func=rect;X=80;Y=322;width=60;height=100;bc=saddlebrown;pc=darkslatgray;pw=2"
shape[1][10]="func=tri;X1=140;Y1=262;X2=110;Y2=322;X3=140;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0
shape[1][11]="func=tri;X1=140;Y1=262;X2=170;Y2=262;X3=140;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0"
shape[1][12]="func=tri;X1=50;Y1=262;X2=96;Y2=262;X3=80;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0
shape[1][13]="func=tri;X1=96;Y1=262;X2=80;Y2=322;X3=126;Y3=322;bc=saddlebrown;pc=darkslatgray;pw=0"
' 18 Apples
s[2] ="1=0.2;2=0.2;3=0.2;4=0.2;5=0.2;6=0.2;7=0.2;8=0.2;9=0.2;10=0.2;11=0.2;12=0.2;13=0.2;14=0.2;15=0.2;16=0.2;17=.2;18=.2;18=.2"
shX[2] ="1=-40;2=-20;3=0;4=20;5=40;6=60;7=80;8=100;9=120;10=140;11=160;12=180;13=200;14=220;15=240;16=260;17=280;18=300"
shY[2] ="1=420;2=420;3=420;4=420;5=420;6=420;7=420;8=420;9=420;10=460;11=460;12=460;13=460;14=460;15=460;16=460;17=460;18=460"
shape[2][1] = "func=rect;x=626;y=110;width=20;height=60;angle=30;bc=yellowgreen;pw=0;"
shape[2][2] = "func=ell;x=511;y=148;width=150;height=150;bc=crimson;pw=0;"
shape[2][3] = "func=ell;x=603;y=148;width=150;height=150;bc=crimson;pw=0;"
shape[2][4] = "func=ell;x=594;y=188;width=40;height=40;bc=snow;pw=0;"
shape[2][5] = "func=ell;x=633;y=188;width=40;height=40;bc=snow;pw=0;"
shape[2][6] = "func=ell;x=614;y=196;width=15;height=15;bc=darkslategray;pw=0;"
shape[2][7] = "func=ell;x=635;y=196;width=15;height=15;angle=7;bc=darkslategray;pw=0;"
shape[2][8] = "func=rect;x=600;y=250;width=80;height=20;angle=-5;bc=purple;pw=0;"
' Lion//1
s[3] ="1=.7"
shX[3] ="1=350"
shY[3] ="1=280"
shape[3][1] = "func=rect;x=266;y=288;width=166;height=80;bc=gold;pw=0;"
shape[3][2] = "func=ell;x=210;y=40;width=280;height=280;bc=coral;"
shape[3][3] = "func=rect;x=260;y=110;width=66;height=80;angle=80;bc=gold;pw=0;"
shape[3][4] = "func=rect;x=363;y=110;width=66;height=80;angle=-80;bc=gold;pw=0;"
shape[3][5] = "func=tri;x=240;y=40;x1=120;y1=85;x2=147;y2=30;x3=200;y3=85;bc=gold;pw=0;"' 1
shape[3][6] = "func=tri;x=200;y=40;x1=50;y1=85;x2=110;y2=30;x3=140;y3=85;bc=gold;pw=0;"' 2
shape[3][7] = "func=tri;x=230;y=140;x1=120;y1=30;x2=120;y2=-40;x3=80;y3=20;bc=sandybrown;pw=0;"' 3
shape[3][8] = "func=tri;x=250;y=140;x1=140;y1=20;x2=100;y2=-40;x3=100;y3=30;bc=sandybrown;pw=0;"' 4
shape[3][9] = "func=tri;x=155;y=150;x1=100;y1=30;x2=140;y2=60;x3=180;y3=30;bc=snow;pw=0;"
shape[3][10] = "func=tri;x=150;y=150;x1=140;y1=60;x2=160;y2=120;x3=180;y3=60;bc=snow;pw=0;"
shape[3][11] = "func=rect;x=295;y=188;width=100;height=44;bc=snow;pw=0;"
shape[3][12] = "func=tri;x=153;y=154;x1=200;y1=30;x2=240;y2=60;x3=280;y3=30;bc=snow;pw=0;"
shape[3][13] = "func=tri;x=120;y=150;x1=240;y1=60;x2=260;y2=120;x3=280;y3=60;bc=snow;pw=0;"
shape[3][14] = "func=rect;x=310;y=200;width=70;height=70;bc=snow;pw=0;"
shape[3][15] = "func=tri;x=230;y=140;x1=120;y1=30;x2=120;y2=80;x3=80;y3=20;bc=orangered;pw=0;"
shape[3][16] = "func=tri;x=250;y=140;x1=140;y1=20;x2=100;y2=80;x3=100;y3=30;bc=orangered;pw=0;"
shape[3][17] = "func=tri;x=230;y=50;x1=120;y1=30;x2=120;y2=110;x3=80;y3=20;bc=sandybrown;pw=0;"
shape[3][18] = "func=tri;x=250;y=50;x1=140;y1=20;x2=100;y2=110;x3=100;y3=30;bc=sandybrown;pw=0;"
shape[3][19] = "func=tri;x=230;y=140;x1=120;y1=30;x2=120;y2=-40;x3=80;y3=20;bc=sandybrown;pw=0;"
shape[3][20] = "func=tri;x=250;y=140;x1=140;y1=20;x2=100;y2=-40;x3=100;y3=30;bc=sandybrown;pw=0;"
shape[3][21] = "func=tri;x=181;y=272;x1=120;y1=-35;x2=168;y2=-45;x3=171;y3=-55;bc=saddlebrown;pw=0;"
shape[3][22] = "func=tri;x=171;y=272;x1=220;y1=-40;x2=180;y2=-44;x3=177;y3=-55;bc=saddlebrown;pw=0;"
shape[3][23] = "func=tri;x=215;y=90;x1=120;y1=30;x2=80;y2=28;x3=120;y3=40;bc=saddlebrown;pw=0;"
shape[3][24] = "func=tri;x=245;y=90;x1=120;y1=30;x2=160;y2=28;x3=120;y3=40;bc=saddlebrown;pw=0;"
shape[3][25] = "func=line;x=348;y=188;x1=22;y1=0;x2=100;y2=4;pc=gold;pw=2;"
shape[3][26] = "func=line;x=347;y=189;x1=22;y1=2;x2=100;y2=10;pc=gold;pw=2;"
shape[3][27] = "func=line;x=347;y=191;x1=22;y1=3;x2=100;y2=22;pc=gold;pw=2;"
shape[3][28] = "func=line;x=343;y=194;x1=22;y1=4;x2=100;y2=33;pc=gold;pw=2;"
shape[3][30] = "func=line;x=222;y=187;x1=22;y1=6;x2=100;y2=0;pc=gold;pw=2;"
shape[3][31] = "func=line;x=230;y=188;x1=18;y1=11;x2=100;y2=3;pc=gold;pw=2;"
shape[3][32] = "func=line;x=230;y=191;x1=18;y1=18;x2=105;y2=3;pc=gold;pw=2;"
shape[3][33] = "func=line;x=230;y=192;x1=19;y1=28;x2=108;y2=5;pc=gold;pw=2;"
' House//1
s[4] ="1=.7"
shX[4] ="1=250"
shY[4] ="1=-100"
shape[4][1] = "func=rect;x=800;y=280;width=210;height=30;bc=gray;pc=darkslategray;pw=2"'Rec A4
shape[4][2] = "func=rect;x=777;y=310;width=258;height=30;bc=silver;pc=darkslategray;pw=2"'Rec A3
shape[4][3] = "func=rect;x=755;y=340;width=277;height=30;bc=gray;pc=darkslategray;pw=2"'Rec A2
shape[4][4] = "func=rect;x=766;y=370;width=272;height=30;bc=silver;pc=darkslategray;pw=2"'Rec A1
shape[4][5] = "func=tri;x=480;y=340;x1=222;y1=60;x2=262;y2=8;x3=320;y3=60;bc=silver;pc=darkslategray;pw=2"'Tri A1
shape[4][6] = "func=tri;x=480;y=320;x1=244;y1=50;x2=280;y2=6;x3=320;y3=50;bc=gray;pc=darkslategray;pw=2"'Tri A2
shape[4][7] = "func=tri;x=480;y=300;x1=267;y1=40;x2=298;y2=4;x3=320;y3=40;bc=silver;pc=darkslategray;pw=2"'Tri A3
shape[4][8] = "func=tri;x=480;y=280;x1=292;y1=30;x2=320;y2=2;x3=320;y3=30;bc=gray;pc=darkslategray;pw=2"'Tri A4
shape[4][9] = "func=tri;x=480;y=340;x1=530;y1=60;x2=585;y2=8;x3=636;y3=60;bc=silver;pc=darkslategray;pw=2"'Tri A1
shape[4][10] = "func=tri;x=480;y=320;x1=530;y1=50;x2=566;y2=6;x3=608;y3=50;bc=gray;pc=darkslategray;pw=2"'Tri A2
shape[4][11] = "func=tri;x=480;y=300;x1=530;y1=40;x2=548;y2=4;x3=580;y3=40;bc=silver;pc=darkslategray;pw=2"'Tri A3
shape[4][12] = "func=tri;x=480;y=280;x1=530;y1=30;x2=530;y2=2;x3=555;y3=30;bc=gray;pc=darkslategray;pw=2"'Tri A4
shape[4][13] = "func=rect;x=743;y=397;width=333;height=333;bc=snow;pc=darkslategray;pw=2"'Body Structpw=2ure
shape[4][14] = "func=rect;x=766;y=608;width=100;height=122;bc=saddlebrown;pc=darkslategray;pw=2"'DoorA
shape[4][15] = "func=ell;x=766;y=573;width=100;height=80;bc=saddlebrown;pw=2"'pc=saddlebrown;"'DoorB
shape[4][16] ="func=ell;x=788;y=684;width=10;height=10;bc=yellow;pc=darcksategray;pw=2"'DoorC
shape[4][17] ="func=rect;x=944;y=480;width=100;height=122;bc=saddlebrown;darkslategray;pw=2"'WindowA
shape[4][18] ="func=ell;x=944;y=428;width=100;height=122;bc=saddlebrown;darkslategray;pw=2"'WindowB
shape[4][19] = "func=rect;x=955;y=473;width=80;height=111;bc=skyblue;pc=darkslategray;pw=2"'windowC
shape[4][20] = "func=ell;x=955;y=442;width=80;height=88;bc=skyblue;pc=darkslategray;pw=2"'windowD
shape[4][21] ="func=line;x=877;y=451;x1=80;y1=30;x2=155;y2=30;bc=dodgerblue;pc=darkslategray;pw=2"'Widow Grill 1
shape[4][22] ="func=line;x=8977;y=451;x1=80;y1=60;x2=155;y2=60;bc=dodgerblue;pc=darkslategray;pw=2"'Widow Grill 2
shape[4][23] ="func=line;x=877;y=451;x1=80;y1=90;x2=155;y2=90;bc=dodgerblue;pc=darkslategray;pw=2"'Widow Grill 3
shape[4][24] ="func=line;x=900;y=395;x1=95;y1=44;x2=95;y2=188;bc=dodgerblue;pc=darkslategray;pw=2"'Window Grill 4
shape[4][25] ="func=rect;x=922;y=242;width=80;height=100;bc=crimson;pc=darkslategray;pw=2"'Chimny 1
shape[4][26] ="func=rect;x=911;y=241;width=100;height=20;bc=firebrick;pe;fi=False;x=340;y=72;width=200;height=113;pw=0;bc=#80FFFFFF;name=TextBox 2;"
' Tree
s[5]="1=0.5;2=0.5;3=0.5;4=0.5;"
shX[5]="1=900;2=930;3=960;4=990"
shY[5]="1=340;2=340;3=340;4=340" ' 5,6,13,14
shape[5]=shape[1]
'Apple
s[6] ="1=0.2;2=0.2;3=0.2;4=0.2;5=0.2;6=0.2;7=.2;8=.2;"
shX[6] ="1=800;2=840;3=880;4=920;5=820;6=860;7=900;8=940"
shY[6] ="1=400;2=400;3=400;4=400;5=440;6=440;7=440;8=440"
shape[6]=shape[2]
endsub