Si ça ne donne rien, vous pouvez m'informer.
Code : Tout sélectionner
UseJPEGImageDecoder()
UsePNGImageDecoder()
imgIni = LoadImage(#PB_Any, OpenFileRequester("Image", "", "*.JPG", 0) )
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
OpenScreen(DesktopWidth(0), DesktopHeight(0), 32, "", #PB_Screen_SmartSynchronization, DesktopFrequency(0) )
Global.I tileW = 48, tileH = 48
Global.I scrW = ScreenWidth(), scrH = ScreenHeight()
Global.I scrW2 = scrW / 2
Global.I scrH2 = scrH / 2
Global.I Xmax, Ymax
spChk = CreateSprite(#PB_Any, tileW, tileH)
If StartDrawing(SpriteOutput(spChk) )
Box(0, 0, tileW, tileH, RGB(255, 255, 255) )
Box(1, 1, tileW - 2, tileH - 2, RGB(0, 0, 0) )
StopDrawing()
EndIf
Xmax = scrW / tileW
Ymax = scrH / tileH
Global Dim X(Xmax, Ymax)
Global Dim Y(Xmax, Ymax)
Global Dim Sp(Xmax, Ymax)
imgW = ImageWidth(imgIni) / Xmax
imgH = ImageHeight(imgIni) / Ymax
For yi = 0 To Ymax
For xi = 0 To Xmax
sp(xi, yi) = CreateSprite(#PB_Any, tileW, tileH)
imgTmp = GrabImage(imgIni, #PB_Any, xi * imgW, yi * imgH, imgW, imgH)
If StartDrawing(SpriteOutput(sp(xi, yi) ) )
DrawImage(ImageID(imgTmp), 0, 0, tileW, tileH)
StopDrawing()
EndIf
FreeImage(imgTmp)
Next
Next
Define R.D = 400
cx = scrW2
cy = scrH2
Repeat
Delay(14)
ExamineKeyboard()
ExamineMouse()
cx = MouseX()
cy = MouseY()
For Y = 0 To Ymax
For X = 0 To Xmax
X(X, Y) = X * tileW
Y(X, Y) = Y * tileH
DX = X(X, Y) - cx
DY = Y(X, Y) - cy
D.D = Sqr(DX * DX + DY * DY)
A.D = ATan2(DX, DY)
If D < R
If D
D * (R / D)
EndIf
Tx.D = Cos(A) * D
Ty.D = Sin(A) * D
X(X, Y) = cx + Tx
Y(X, Y) = cy + Ty
EndIf
Next
Next
Y = 0
Repeat
X = 0
Repeat
X1 = X(X, Y)
Y1 = Y(X, Y)
X2 = X(X + 1, Y)
Y2 = Y(X + 1, Y)
X3 = X(X + 1, Y + 1)
Y3 = Y(X + 1, Y + 1)
X4 = X(X, Y + 1)
Y4 = Y(X, Y + 1)
TransformSprite(sp(X, Y), X1, Y1, X2, Y2, X3, Y3, X4, Y4)
DisplaySprite(sp(X, Y), 0, 0)
X + 1
Until X >= Xmax
Y + 1
Until Y >= Ymax
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)