Proggies
#38
Celtic Knot Puzzle
Click tiles in top left figure to make a 6 x 6 tile Celtic Knot much like my Avatar ;-))

Press escape and the image will be copied and rotated 45 degrees and be drawn in bottom right corner, to compare to my Avatar. Hint: I needed a solution image to use when building, it's not easy!


Code: (Select All)
_Title "A Celtic Knot Puzzle - click the piece build a knot!" ' b+ 2022-06-06
Screen _NewImage(1200, 700, 32)
_ScreenMove 130, 20
d& = _LoadImage("D tile.png")
d2& = _LoadImage("D2 tile.png")
_PutImage (0, 1), d&, 0
Bg~& = Point(3, 3)

iw = _Width(d&): ih = _Height(d&)
_PrintString (10, 280), Str$(iw) + Str$(ih)
For i = 0 To 6
    Line (0, i * 44)-(iw, i * 44), &HFFFFFF00
Next
For i = 0 To 16
    Line (i * 44, 0)-(i * 44, ih), &HFFFFFF00
Next
iw2 = _Width(d2&): ih2 = _Height(d2&)
iw2 = 16 * 44: ih2 = 8 * 44
_PutImage (1, 300), d2&, 0
For i = 0 To 8
    Line (0, i * 44 + 300)-(iw2, i * 44 + 300), &HFFFFFF00
Next
For i = 0 To 16
    Line (i * 44, 0 + 300)-(i * 44, ih2 + 300), &HFFFFFF00
Next
_PrintString (10, 660), Str$(iw2) + Str$(ih2)

For i = 0 To 8
    Line (0 + 800, i * 44)-(ih2 + 800, i * 44), &HFFFFFF00
Next
For i = 0 To 8
    Line (i * 44 + 800, 0)-(i * 44 + 800, ih2), &HFFFFFF00
Next

Do
    While _MouseInput: Wend
    mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
    If mx < 800 Then
        cellx = Int(mx / 44)
        If my >= 300 Then
            celly = Int((my - 300) / 44): fig = 2
        Else
            celly = Int(my / 44): fig = 1
        End If
    Else
        fig = 3
        cellx = Int((mx - 800) / 44)
        celly = Int(my / 44)
    End If
    If mb Then
        _PrintString (800, 400), Space$(50)
        _PrintString (800, 400), "Fig:" + Str$(fig) + " cell:" + Str$(cellx) + Str$(celly)

        If fig = 1 Then
            If cellx >= 0 And cellx <= 15 And celly >= 0 And celly <= 5 Then
                _PutImage (850, 450)-Step(44, 44), 0, 0, (cellx * 44, celly * 44)-Step(44, 44)
            End If
        ElseIf fig = 2 Then
            If cellx >= 0 And cellx <= 15 And celly >= 0 And celly <= 7 Then
                _PutImage (850, 450)-Step(44, 44), 0, 0, (cellx * 44, celly * 44 + 300)-Step(44, 44)
            End If
        ElseIf fig = 3 Then
            If cellx >= 0 And cellx <= 7 And celly >= 0 And celly <= 7 Then
                _PutImage (cellx * 44 + 800, celly * 44)-Step(44, 44), 0, 0, (850, 450)-Step(44, 44)
            End If
        End If
        _Delay .2
    End If
    ' 800, 450 step 44, 44  ' will be transfer spot   from fig 1 or 2 to fig 3
Loop Until _KeyDown(27)
_PrintString (800, 400), Space$(50) ' erase note
Line (850, 450)-Step(45, 45), &HFF000000, BF ' cover last puzzle piece
' grab image and twist 45 degrees!
trans& = _NewImage(264, 264, 32) 'container to hold image
_PutImage , 0, trans&, (800, 0)-Step(264, 264)
RotoZoom _Width - 190, _Height - 190, trans&, 1, 45
Sleep

Sub RotoZoom (X As Long, Y As Long, Image As Long, Scale As Single, degreesRotation As Single)
    Dim px(3) As Single, py(3) As Single, W&, H&, sinr!, cosr!, i&, x2&, y2&
    W& = _Width(Image&): H& = _Height(Image&)
    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(-degreesRotation / 57.2957795131): cosr! = Cos(-degreesRotation / 57.2957795131)
    For i& = 0 To 3
        x2& = (px(i&) * cosr! + sinr! * py(i&)) * Scale + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) * Scale + Y
        px(i&) = x2&: py(i&) = y2&
    Next
    _MapTriangle (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
    _MapTriangle (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub


Here is the Puzzle with Solution:
   

Here is the zip with source, exe and 3 images 2 images are used for tiles but never used bottom left and you will want to use solution image to help tile solution.


Attached Files
.zip   Celtic Knot Puzzle.zip (Size: 948.46 KB / Downloads: 45)
b = b + ...
Reply


Messages In This Thread
Proggies - by bplus - 04-24-2022, 04:02 PM
RE: Proggies - by bplus - 04-26-2022, 03:23 PM
RE: Proggies - by bplus - 04-26-2022, 04:24 PM
RE: Proggies - by bplus - 05-01-2022, 12:10 AM
RE: Proggies - by dcromley - 05-01-2022, 04:00 AM
RE: Proggies - by bplus - 05-01-2022, 02:52 PM
RE: Proggies - by bplus - 05-01-2022, 02:56 PM
RE: Proggies - by bplus - 05-01-2022, 08:05 PM
RE: Proggies - by bplus - 05-03-2022, 01:43 AM
RE: Proggies - by vince - 05-03-2022, 02:13 AM
RE: Proggies - by bplus - 05-03-2022, 02:16 AM
RE: Proggies - by bplus - 05-08-2022, 02:13 AM
RE: Proggies - by OldMoses - 05-08-2022, 12:40 PM
RE: Proggies - by bplus - 05-08-2022, 03:16 PM
RE: Proggies - by bplus - 05-16-2022, 12:21 AM
RE: Proggies - by bplus - 05-16-2022, 12:58 AM
RE: Proggies - by PhilOfPerth - 05-16-2022, 01:40 AM
RE: Proggies - by bplus - 05-16-2022, 01:28 AM
RE: Proggies - by SMcNeill - 05-16-2022, 12:49 PM
RE: Proggies - by bplus - 05-16-2022, 02:44 PM
RE: Proggies - by bplus - 05-17-2022, 11:16 PM
RE: Proggies - by vince - 05-25-2022, 05:08 AM
RE: Proggies - by bplus - 05-17-2022, 11:23 PM
RE: Proggies - by bplus - 05-17-2022, 11:42 PM
RE: Proggies - by bplus - 05-18-2022, 01:14 AM
RE: Proggies - by bplus - 05-19-2022, 06:43 PM
RE: Proggies - by bplus - 05-20-2022, 01:52 AM
RE: Proggies - by SierraKen - 05-20-2022, 03:44 AM
RE: Proggies - by bplus - 05-20-2022, 07:59 PM
RE: Proggies - by bplus - 05-20-2022, 08:34 PM
RE: Proggies - by Dav - 05-21-2022, 12:48 AM
RE: Proggies - by bplus - 05-25-2022, 12:47 AM
RE: Proggies - by bplus - 05-29-2022, 11:32 PM
RE: Proggies - by bplus - 05-30-2022, 01:41 PM
RE: Proggies - by bplus - 06-04-2022, 10:01 PM
RE: Proggies - by triggered - 06-05-2022, 03:44 AM
RE: Proggies - by bplus - 06-05-2022, 03:03 PM
RE: Proggies - by bplus - 06-06-2022, 08:04 PM
RE: Proggies - by bplus - 06-07-2022, 02:18 AM
RE: Proggies - by dbox - 03-03-2023, 09:14 PM
RE: Proggies - by bplus - 06-07-2022, 10:51 AM
RE: Proggies - by SierraKen - 06-09-2022, 07:04 PM
RE: Proggies - by bplus - 06-09-2022, 10:40 PM
RE: Proggies - by bplus - 06-22-2022, 02:59 PM
RE: Proggies - by vince - 06-23-2022, 08:04 PM
RE: Proggies - by SierraKen - 06-24-2022, 06:28 PM
RE: Proggies - by bplus - 07-13-2022, 06:19 PM
RE: Proggies - by bplus - 07-17-2022, 11:38 PM
RE: Proggies - by bplus - 07-19-2022, 07:16 PM
RE: Proggies - by vince - 07-22-2022, 10:40 PM
RE: Proggies - by dbox - 07-23-2022, 12:47 AM
RE: Proggies - by SierraKen - 07-23-2022, 05:16 PM
RE: Proggies - by bplus - 07-24-2022, 04:16 PM
RE: Proggies - by dbox - 07-24-2022, 11:33 PM
RE: Proggies - by SierraKen - 07-24-2022, 11:38 PM
RE: Proggies - by bplus - 09-19-2022, 07:16 PM
RE: Proggies - by bplus - 09-20-2022, 03:42 PM
RE: Proggies - by James D Jarvis - 09-21-2022, 12:22 PM
RE: Proggies - by bplus - 09-21-2022, 02:39 PM
RE: Proggies - by mnrvovrfc - 09-24-2022, 03:25 AM
RE: Proggies - by James D Jarvis - 09-21-2022, 02:55 PM
RE: Proggies - by bplus - 09-21-2022, 03:46 PM
RE: Proggies - by James D Jarvis - 09-21-2022, 05:46 PM
RE: Proggies - by bplus - 09-21-2022, 06:29 PM
RE: Proggies - by bplus - 10-09-2022, 08:17 PM
RE: Proggies - by vince - 10-09-2022, 09:20 PM
RE: Proggies - by bplus - 10-10-2022, 01:52 PM
RE: Proggies - by vince - 10-10-2022, 04:20 PM
RE: Proggies - by bplus - 10-18-2022, 02:54 PM
RE: Proggies - by bplus - 01-16-2023, 03:53 PM
RE: Proggies - by bplus - 01-16-2023, 03:59 PM
RE: Proggies - by bplus - 01-16-2023, 04:05 PM
RE: Proggies - by bplus - 01-16-2023, 04:09 PM
RE: Proggies - by bplus - 01-16-2023, 04:13 PM
RE: Proggies - by bplus - 01-17-2023, 08:18 PM
RE: Proggies - by bplus - 03-06-2023, 07:04 PM
RE: Proggies - by bplus - 03-24-2023, 02:41 AM
RE: Proggies - by vince - 03-24-2023, 05:22 AM
RE: Proggies - by bplus - 03-24-2023, 05:32 AM
RE: Proggies - by mnrvovrfc - 03-24-2023, 05:54 AM
RE: Proggies - by vince - 04-09-2023, 06:49 AM
RE: Proggies - by bplus - 04-09-2023, 03:05 PM
RE: Proggies - by bplus - 07-23-2023, 12:16 PM
RE: Proggies - by GareBear - 07-23-2023, 05:47 PM
RE: Proggies - by bplus - 07-23-2023, 07:35 PM
RE: Proggies - by bplus - 07-24-2023, 07:04 PM
RE: Proggies - by bplus - 07-24-2023, 07:09 PM
RE: Proggies - by bplus - 08-17-2023, 07:17 AM
RE: Proggies - by johnno56 - 08-17-2023, 10:32 AM
RE: Proggies - by bplus - 08-28-2023, 03:24 PM
RE: Proggies - by Dav - 08-28-2023, 05:28 PM
RE: Proggies - by PhilOfPerth - 08-28-2023, 11:47 PM
RE: Proggies - by johnno56 - 08-29-2023, 07:11 AM
RE: Proggies - by bplus - 08-29-2023, 12:39 PM



Users browsing this thread: 15 Guest(s)