'==================
'UNSCRAMBLE-ROT.BAS
'==================
'Unscramble the picture puzzle
'Rotate pieces until they fit.
'Coded by Dav, JAN/2021
'Use mouse, click on squares to rotate them.
'SPACE key gives a little half second cheat look.
'korea2.jpg picture was taken by Dav in South Korea
'CREDITS: Thanks to whoever made and shared the RotoZoom SUB.
'Use your own image here....
'NOTE: USE A SQUARED IMAGE (ie: 600x600, 700x700, etc...)
SLEEP 2 'show picture couple of secs
row = 6: col = 6 '6x6 grid of pieces - increase for more pieces
DIM SHARED tile&
(row
* col
), tile.x
(row
* col
), tile.y
(row
* col
)
'=== split picture up into tile pieces
bc = 1
x1 = (r * xsize) - xsize: x2 = x1 + xsize
y1 = (c * ysize) - ysize: y2 = y1 + ysize
tile.x(bc) = x1: tile.y(bc) = y1
'make pieces images
tilepuz(bc) = bc
bc = bc + 1
'=====
main:
'=====
'=== show current puzzle
RotoZoom tile.x(t) + (xsize / 2), tile.y(t) + (ysize / 2), tile&(t), 1, angle
'=== check if puzzle done
done = 1
IF tilepuz
(t
) <> 1 THEN done
= 0
'wait until mouse button up to continue
'If user clicked mouse
'see where they clicked
tx = tile.x(t): tx2 = tile.x(t) + xsize
ty = tile.y(t): ty2 = tile.y(t) + ysize
LINE (tx
, ty
)-(tx2
, ty2
), _RGB(0, 0, 0), BF
RotoZoom tile.x(t) + (xsize / 2), tile.y(t) + (ysize / 2), tile&(t), 1, angle
RotoZoom tile.x(t) + (xsize / 2), tile.y(t) + (ysize / 2), tile&(t), 1, angle
RotoZoom tile.x(t) + (xsize / 2), tile.y(t) + (ysize / 2), tile&(t), 1, angle
RotoZoom tile.x(t) + (xsize / 2), tile.y(t) + (ysize / 2), tile&(t), 1, angle
'Space give a little cheat look
px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2
sinr!
= SIN(-Rotation
/ 57.2957795131): cosr!
= COS(-Rotation
/ 57.2957795131) x2& = (px(i&) * cosr! + sinr! * py(i&)) * Scale + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) * Scale + Y
px(i&) = x2&: py(i&) = y2&