Microsoft Small Basic
Program Listing: RWP875
'
' Moving yasuho
'
GraphicsWindow.Show()
'GraphicsWindow.Width = 640
'GraphicsWindow.Height = 480
'img = ImageList.LoadImage(Program.Directory + "\yasuho.jpg")
img = ImageList.LoadImage("http://img.f.hatena.ne.jp/images/fotolife/y/yasuho/20100311/20100311114536.jpg")
me = Shapes.AddImage(img)
'imgw = ImageList.GetWidthOfImage(img)
'imgh = ImageList.GetHeightOfImage(img)
' hardcoded image size because GetXXXOfImage() doesn't work properly on SylverLight runtime environment
imgw = 98
imgh = 133
winw = GraphicsWindow.Width
winh = GraphicsWindow.Height
' debug
GraphicsWindow.DrawText(0, 0, "image=(" + imgw + "," + imgh + ") window=(" + winw + "," + winh + ")")
x = 0
y = 0
xdir = 1
ydir = 1
While 1=1
Shapes.Move(me, x, y)
Program.Delay(5)
If x + imgw >= winw Then
xdir = -1
ElseIf x <= 0 then
xdir = 1
EndIf
if y + imgh >= winh then
ydir = -1
elseif y <= 0 then
ydir = 1
EndIf
x = x + xdir
y = y + ydir
EndWhile