QB64 Phoenix Edition
Goals(1) = New Tile() - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Works in Progress (https://qb64phoenix.com/forum/forumdisplay.php?fid=9)
+---- Thread: Goals(1) = New Tile() (/showthread.php?tid=1952)

Pages: 1 2


RE: Goals(1) = New Tile() - bplus - 09-01-2023

```Dim Shared row, col As Integer
Dim Shared levelMap(1 To 12) As String
Dim Shared tileSymbol As String

Sub LoadLabel (numLevel)
    ' ??µ??????a ???t? t?? pa????d???
    levelMap(1) = "    ############ "
    levelMap(2) = "    #          # "
    levelMap(3) = "    #          # "
    levelMap(4) = "    #    $$    # "
    levelMap(5) = "    #  $  $  # "
    levelMap(6) = "    #    $$    # "
    levelMap(7) = " ###############"
    levelMap(8) = "#              #"
    levelMap(9) = "#              #"
    levelMap(10) = "#              #"
    levelMap(11) = "#              #"
    levelMap(12) = "############### "

    ' ??as??ste t?? ???t? ?a? ???ste ta ?a?a?t???st??? t?? p?a??d???

    For row = 1 To MapHeight ' <<<<<<<<<<<<<<<<<<<<<<< what is MapHeight?
        For col = 1 To MapWidth ' <<<<<<<<<<<<<<<<<<<<<< what is MapWidth
            tileSymbol = Mid$(levelMap(row), col, 1)

            MapTiles(col, row).Symbol = tileSymbol  ' what is .Symbol ? no type definition given
            MapTiles(col, row).IsBox = 0            ' what is .IsBox ? no type definition given
            MapTiles(col, row).IsGoal = 0            ' what is .IsGoal ? no type definition given

            If tileSymbol = "$" Then
                MapTiles(col, row).IsBox = 1
            ElseIf tileSymbol = "." Then
                MapTiles(col, row).IsGoal = 1
            End If
        Next col
    Next row
End Sub```

```
MapTiles(col, row).Symbol = tileSymbol  ' what is .Symbol ? no type definition given
MapTiles(col, row).IsBox = 0            ' what is .IsBox ? no type definition given
MapTiles(col, row).IsGoal = 0            ' what is .IsGoal ? no type definition given```
This kind of stuff needs a UDT = User Defined Type which is what people tried to show you in posts above.


RE: Goals(1) = New Tile() - gaslouk - 09-01-2023

Code: (Select All)
Screen _NewImage(640, 480, 32)

Const MapWidth = 30
Const MapHeight = 22
TileWidth = 20
TileHeight = 13

Type GoalType
    Score As Integer
    Description As String
    IsComplete As Integer
End Type
Type Tile
    Symbol As String * 1 'use higher numbers if you need more chars
    IsBox As Integer ' 0 for False, 1 for True
    IsGoal As Integer ' 0 for False, 1 for True
    HasBox As Integer ' 0 for False, 1 for True
    HasPlayer As Integer ' 0 for False, 1 for True
    X As Integer
    Y As Integer
End Type

Dim Shared row, col As Integer
Dim Shared levelMap(0 To 20) As String
Dim Shared tileSymbol As String
Dim Shared MapTiles(MapWidth, MapHeight) As Tile
Dim Shared Map(MapWidth, MapHeight) As Integer
Dim Shared PlayerX, PlayerY
Dim Shared NumGoals, GoalsCompleted
Dim Shared GoalsCoveredCount As Integer
Dim Shared boxTile As Tile
Dim Shared currentTile As Tile
Dim Shared prevX As Integer
Dim Shared prevY As Integer
Dim Shared newBoxTile As Tile
Dim Shared positionAfterBox As Tile
Dim Shared prevSymbol As String
Dim Shared prevIsGoal As Integer
Dim Shared possibleMove As _Unsigned _Byte
Dim Shared otherGoal As Tile
Dim Shared goal As Tile
Dim Shared j As Integer
Dim Shared Goals(6) As Tile
Dim Shared GoalArr(10) As GoalType

' Initialize MapTiles
' Set up walls

InitializeGame
LoadLabel

' Initialize GoalsCoveredCount to 0
GoalsCoveredCount = 0

Do
    _Limit 60
    DrawMap
    _Display

    Do
        key$ = InKey$
        If Len(key$) > 0 Then Exit Do
    Loop

    If key$ = Chr$(27) Then Exit Do

    newX = PlayerX
    newY = PlayerY

    Select Case UCase$(key$)
        Case "W", Chr$(0) + Chr$(72) ' "w" key or up arrow
            newY = PlayerY - 1
        Case "S", Chr$(0) + Chr$(80) ' "s" key or down arrow
            newY = PlayerY + 1
        Case "A", Chr$(0) + Chr$(75) ' "a" key or left arrow
            newX = PlayerX - 1
        Case "D", Chr$(0) + Chr$(77) ' "d" key or right arrow
            newX = PlayerX + 1
    End Select

    If newX >= 1 And newX <= MapWidth And newY >= 1 And newY <= MapHeight Then
        If MapTiles(newX, newY).Symbol = " " Or MapTiles(newX, newY).Symbol = "." Then
            MovePlayer newX, newY
        ElseIf Map(newX, newY) = 36 Then
            MoveBox newX, newY, newBoxX, newBoxY
        End If
    End If

    mouseX = _MouseX
    mouseY = _MouseY

    If mouseX >= 0 And mouseX <= 640 And mouseY >= 0 And mouseY <= 480 Then
        tileX = Int(mouseX / TileWidth) + 1
        tileY = Int(mouseY / TileHeight) + 1

        If tileX >= 1 And tileX <= MapWidth And tileY >= 1 And tileY <= MapHeight Then
            If MOUSECLICK() Then
                If Map(tileX, tileY) = 0 Or Map(tileX, tileY) = 46 Then ' 0 για κενό, 46 για τελεία
                    MovePlayer tileX, tileY
                ElseIf Map(tileX, tileY) = 36 Then ' 36 για το σύμβολο $
                    MoveBox tileX, tileY, newBoxX, newBoxY
                End If
            End If
        End If
    End If

Loop Until GoalsCompleted = NumGoals

Cls
Print "Congratulations! You completed the level."
End


Sub PushGoals (dx As Integer, dy As Integer)
    Dim i As Integer
    For i = 0 To UBound(GoalArr)
        GoalArr(i).Score = 0
        GoalArr(i).Description = ""
        GoalArr(i).IsComplete = 0
    Next
    ReDim Goals(6) As Tile
    Goals(1).Symbol = "o"
    Goals(2).Symbol = "."
    Goals(3).Symbol = "*"
    'Goals(1).IsBox = False
    'Goals(1).IsGoal = True
    'Goals(1).HasBox = False
    'Goals(1).HasPlayer = False
    Goals(1).IsBox = 0
    Goals(1).IsGoal = 1
    Goals(1).HasBox = 0
    Goals(1).HasPlayer = 0
    Goals(1).X = 4
    Goals(1).Y = 7

    For i = 1 To NumGoals
        goal = MapTiles(i, j)
        If goal.X = PlayerX + dx And goal.Y = PlayerY + dy Then
            ' The goal is in that direction
            ' Check if we can move it
            If IsTileWalkable(goal.X + dx, goal.Y + dy) And Not IsGoalAtLocation(goal.X + dx, goal.Y + dy) Then
                ' Move the goal to the new position
                MapTiles(goal.X, goal.Y).Symbol = "."
                MapTiles(goal.X + dx, goal.Y + dy).Symbol = goal.Symbol
                goal.X = goal.X + dx
                goal.Y = goal.Y + dy
                ' See if there is another goal to move
                possibleMove = True
                Do Until Not possibleMove
                    possibleMove = False
                    For j = 1 To NumGoals
                        otherGoal = MapTiles(j, j)
                        If i <> j Then
                            If otherGoal.X = goal.X And otherGoal.Y = goal.Y Then
                                ' There is another goal next to this one; move it too
                                If IsTileWalkable(otherGoal.X + dx, otherGoal.Y + dy) And Not IsGoalAtLocation(otherGoal.X + dx, otherGoal.Y + dy) Then
                                    MapTiles(otherGoal.X, otherGoal.Y).Symbol = "."
                                    MapTiles(otherGoal.X + dx, otherGoal.Y + dy).Symbol = otherGoal.Symbol
                                    otherGoal.X = otherGoal.X + dx
                                    otherGoal.Y = otherGoal.Y + dy
                                    possibleMove = True
                                    Exit Do
                                End If
                            End If
                        End If
                    Next j
                Loop
                Exit Sub
            End If
        End If
    Next i
End Sub

Sub DrawMap ()
    Cls
    For y = 1 To MapHeight
        For x = 1 To MapWidth
            If x = PlayerX And y = PlayerY Then
                Print "@"; ' Draw the player
            Else
                If MapTiles(x, y).Symbol = "." Then
                    Print "o";
                Else
                    Print MapTiles(x, y).Symbol;
                End If
            End If
        Next x
        Print
    Next y
    Print "Goals completed: " + Str$(GoalsCompleted) + "/" + Str$(NumGoals) + "/" + Str$(GoalsCoveredCount) + "/" + Str$(tileSymol)
End Sub

Sub MovePlayer (newX, newY)

    prevX = PlayerX
    prevY = PlayerY

    currentTile = MapTiles(PlayerX, PlayerY)
    prevSymbol = currentTile.Symbol
    prevIsGoal = currentTile.IsGoal

    If currentTile.IsGoal = 1 Then
        currentTile.Symbol = "."
        MoveBox PlayerX, PlayerY, newX, newY
    Else
        currentTile.Symbol = " "
    End If

    PlayerX = newX
    PlayerY = newY

End Sub

Sub MoveBox (boxX, boxY, newBoxX, newBoxY)
    If newBoxTile.Symbol = "." Then
        positionAfterBox = MapTiles(newBoxX + (newBoxX - boxX), newBoxY + (newBoxY - boxY))

        If newBoxX >= 1 And newBoxX <= MapWidth And newBoxY >= 1 And newBoxY <= MapHeight Then
            newBoxTile = MapTiles(newBoxX, newBoxY)

            If positionAfterBox.Symbol <> "." Then
                boxTile = MapTiles(boxX, boxY)
                If boxTile.IsGoal = 1 Then
                    boxTile.Symbol = "."
                Else
                    boxTile.Symbol = " "
                End If

                newBoxTile.Symbol = "$"
                MapTiles(newBoxX, newBoxY).Symbol = "."
                MapTiles(newBoxX, newBoxY).HasBox = 1
                MapTiles(boxX, boxY).HasBox = 0
                GoalsCoveredCount = GoalsCoveredCount + 1
                MoveBox PlayerX, PlayerY, newX, newY
                MovePlayer boxX, boxY
            End If
        ElseIf newBoxTile.Symbol = " " Then
            boxTile = MapTiles(boxX, boxY)
            If boxTile.IsGoal = 1 Then
                boxTile.Symbol = "."
            Else
                boxTile.Symbol = " "
            End If
        End If
    End If
End Sub

Sub InitializeGame ()
    NumGoals = 6
    GoalsCompleted = 0
    ' Set up player
    PlayerX = 13
    PlayerY = 10
    MapTiles(PlayerX, PlayerY).Symbol = "@"

    For y = 1 To MapHeight
        For x = 1 To MapWidth
            Map(x, y) = Asc(" ")
        Next x
    Next y

    For y = 1 To MapHeight
        For x = 1 To MapWidth
            MapTiles(x, y).Symbol = " "
            MapTiles(x, y).IsGoal = 0
            MapTiles(x, y).IsBox = 0
        Next x
    Next y
    For x = 1 To MapWidth
        MapTiles(x, 1).Symbol = "*"
        MapTiles(x, MapHeight).Symbol = "*"
    Next x

    For y = 1 To MapHeight
        MapTiles(1, y).Symbol = "*"
        MapTiles(MapWidth, y).Symbol = "*"
    Next y
End Sub

Sub LoadLabel ()
    ' Δημιουργία χάρτη του παιχνιδιού
    levelMap(1) = "      #####          "
    levelMap(2) = "      #   #          "
    levelMap(3) = "      #$  #          "
    levelMap(4) = "    ###  $#          "
    levelMap(5) = "    #  $ $ #         "
    levelMap(6) = "    # # ## # #####   "
    levelMap(7) = " #### # ## ##  ..#   "
    levelMap(8) = " # $           ..#   "
    levelMap(9) = " #### ## # ##  ..#   "
    levelMap(10) = "  ### ## #########   "
    levelMap(11) = "  #              #   "
    levelMap(12) = "  ################   "

    ' Διασχίστε τον χάρτη και ορίστε τα χαρακτηριστικά των πλακιδίων

    For row = 1 To MapHeight
        For col = 1 To MapWidth
            'tileSymbol = MID(levelMap(row), col, 1)

            MapTiles(col, row).Symbol = tileSymbol
            MapTiles(col, row).IsBox = 0
            MapTiles(col, row).IsGoal = 0

            If tileSymbol = "$" Then
                MapTiles(col, row).IsBox = 1
            ElseIf tileSymbol = "." Then
                MapTiles(col, row).IsGoal = 1
            End If
        Next col
    Next row
End Sub

This is all code.
Thanks.


RE: Goals(1) = New Tile() - bplus - 09-01-2023

EDIT: ah you posted something with more info


RE: Goals(1) = New Tile() - gaslouk - 09-01-2023

(09-01-2023, 10:08 AM)bplus Wrote: EDIT: ah you posted something with more info
As many as you needed.

Change this line please
Code: (Select All)
    levelMap(8) = " # $           ..#   "
with this line.
Code: (Select All)
    levelMap(8) = " # $  $        ..#   "
Τhanks.


RE: Goals(1) = New Tile() - bplus - 09-01-2023

should his be loadLevel not loadLabel?
Code: (Select All)
Sub LoadLabel () ' <<< loadLevel(LevelNumber)
    ' ??µ??????a ???t? t?? pa????d???
    levelMap(levelNumber, 1) = "      #####          "  ' <<<  each line like this  >> has (level number, row number)
    levelMap(2) = "      #   #          "
    levelMap(3) = "      #$  #          "
    levelMap(4) = "    ###  $#          "
    levelMap(5) = "    #  $ $ #         "
    levelMap(6) = "    # # ## # #####   "
    levelMap(7) = " #### # ## ##  ..#   "
    levelMap(8) = " # $           ..#   "
    levelMap(9) = " #### ## # ##  ..#   "
    levelMap(10) = "  ### ## #########   "
    levelMap(11) = "  #              #   "
    levelMap(12) = "  ################   "


     ' level needs to have as many rows and columns as MapTiles

    ' ??as??ste t?? ???t? ?a? ???ste ta ?a?a?t???st??? t?? p?a??d???

    For row = 1 To MapHeight  
        For col = 1 To MapWidth
            tileSymbol = MID$(levelMap(row), col, 1)  '<<< don't comment you need tileSymbol  for next line and need $ for MID$

            MapTiles(col, row).Symbol = tileSymbol
            MapTiles(col, row).IsBox = 0
            MapTiles(col, row).IsGoal = 0

            If tileSymbol = "$" Then
                MapTiles(col, row).IsBox = 1
            ElseIf tileSymbol = "." Then
                MapTiles(col, row).IsGoal = 1
            End If
        Next col
    Next row
End Sub

I can only guess at what this stuff is suppose to be or do, don't have a clue. Thought it might be a soccer game but your level map is too complicated.
Anyway level has to match map in width and height, you only show 12 rows


RE: Goals(1) = New Tile() - gaslouk - 09-01-2023

Thanks b+ for the help.
The game is a clone of Sokoban.

Code: (Select All)
Screen _NewImage(640, 480, 32)

Const MapWidth = 30
Const MapHeight = 22
TileWidth = 30
TileHeight = 22

Type GoalType
    Score As Integer
    Description As String
    IsComplete As Integer
End Type
Type Tile
    Symbol As String * 1 'use higher numbers if you need more chars
    IsBox As Integer ' 0 for False, 1 for True
    IsGoal As Integer ' 0 for False, 1 for True
    HasBox As Integer ' 0 for False, 1 for True
    HasPlayer As Integer ' 0 for False, 1 for True
    X As Integer
    Y As Integer
End Type

Dim Shared row, col As Integer
Dim Shared levelMap As String * 25
Dim Shared tileSymbol As String
Dim Shared MapTiles(MapWidth, MapHeight) As Tile
Dim Shared Map(MapWidth, MapHeight) As Integer
Dim Shared PlayerX, PlayerY
Dim Shared NumGoals, GoalsCompleted
Dim Shared GoalsCoveredCount As Integer
Dim Shared boxTile As Tile
Dim Shared currentTile As Tile
Dim Shared prevX As Integer
Dim Shared prevY As Integer
Dim Shared newBoxTile As Tile
Dim Shared positionAfterBox As Tile
Dim Shared prevSymbol As String
Dim Shared prevIsGoal As Integer
Dim Shared possibleMove As _Unsigned _Byte
Dim Shared otherGoal As Tile
Dim Shared goal As Tile
Dim Shared j As Integer
Dim Shared Goals(6) As Tile
Dim Shared GoalArr(10) As GoalType

' Initialize MapTiles
' Set up walls

InitializeGame
LoadLevel (1)

' Initialize GoalsCoveredCount to 0
GoalsCoveredCount = 0

Do
    _Limit 60
    DrawMap
    _Display

    Do
        key$ = InKey$
        If Len(key$) > 0 Then Exit Do
    Loop

    If key$ = Chr$(27) Then Exit Do

    newX = PlayerX
    newY = PlayerY

    Select Case UCase$(key$)
        Case "W", Chr$(0) + Chr$(72) ' "w" key or up arrow
            newY = PlayerY - 1
        Case "S", Chr$(0) + Chr$(80) ' "s" key or down arrow
            newY = PlayerY + 1
        Case "A", Chr$(0) + Chr$(75) ' "a" key or left arrow
            newX = PlayerX - 1
        Case "D", Chr$(0) + Chr$(77) ' "d" key or right arrow
            newX = PlayerX + 1
    End Select

    If newX >= 1 And newX <= MapWidth And newY >= 1 And newY <= MapHeight Then
        If MapTiles(newX, newY).Symbol = " " Or MapTiles(newX, newY).Symbol = "." Then
            MovePlayer newX, newY
        ElseIf Map(newX, newY) = 36 Then
            MoveBox newX, newY, newBoxX, newBoxY
        End If
    End If

    mouseX = _MouseX
    mouseY = _MouseY

    If mouseX >= 0 And mouseX <= 640 And mouseY >= 0 And mouseY <= 480 Then
        tileX = Int(mouseX / TileWidth) + 1
        tileY = Int(mouseY / TileHeight) + 1

        If tileX >= 1 And tileX <= MapWidth And tileY >= 1 And tileY <= MapHeight Then
            If MOUSECLICK() Then
                If Map(tileX, tileY) = 0 Or Map(tileX, tileY) = 46 Then ' 0 για κενό, 46 για τελεία
                    MovePlayer tileX, tileY
                ElseIf Map(tileX, tileY) = 36 Then ' 36 για το σύμβολο $
                    MoveBox tileX, tileY, newBoxX, newBoxY
                End If
            End If
        End If
    End If

Loop Until GoalsCompleted = NumGoals

Cls
Print "Congratulations! You completed the level."
End


Sub PushGoals (dx As Integer, dy As Integer)
    Dim i As Integer
    For i = 0 To UBound(GoalArr)
        GoalArr(i).Score = 0
        GoalArr(i).Description = ""
        GoalArr(i).IsComplete = 0
    Next
    ReDim Goals(6) As Tile
    Goals(1).Symbol = "o"
    Goals(2).Symbol = "."
    Goals(3).Symbol = "*"
    Goals(1).IsBox = 0
    Goals(1).IsGoal = 1
    Goals(1).HasBox = 0
    Goals(1).HasPlayer = 0
    Goals(1).X = 4
    Goals(1).Y = 7

    For i = 1 To NumGoals
        goal = MapTiles(i, j)
        If goal.X = PlayerX + dx And goal.Y = PlayerY + dy Then
            ' The goal is in that direction
            ' Check if we can move it
            If IsTileWalkable(goal.X + dx, goal.Y + dy) And Not IsGoalAtLocation(goal.X + dx, goal.Y + dy) Then
                ' Move the goal to the new position
                MapTiles(goal.X + dx, goal.Y + dy).Symbol = goal.Symbol
                MapTiles(goal.X, goal.Y).Symbol = "."
                goal.X = goal.X + dx
                goal.Y = goal.Y + dy
                ' See if there is another goal to move
                possibleMove = True
                Do Until Not possibleMove
                    possibleMove = False
                    For j = 1 To NumGoals
                        otherGoal = MapTiles(j, j)
                        If i <> j Then
                            If otherGoal.X = goal.X And otherGoal.Y = goal.Y Then
                                ' There is another goal next to this one; move it too
                                If IsTileWalkable(otherGoal.X + dx, otherGoal.Y + dy) And Not IsGoalAtLocation(otherGoal.X + dx, otherGoal.Y + dy) Then
                                    MapTiles(otherGoal.X, otherGoal.Y).Symbol = "."
                                    MapTiles(otherGoal.X + dx, otherGoal.Y + dy).Symbol = otherGoal.Symbol
                                    otherGoal.X = otherGoal.X + dx
                                    otherGoal.Y = otherGoal.Y + dy
                                    possibleMove = True
                                    Exit Do
                                End If
                            End If
                        End If
                    Next j
                Loop
                Exit Sub
            End If
        End If
    Next i
End Sub

Sub DrawMap ()
    Cls
    For y = 1 To MapHeight
        For x = 1 To MapWidth
            If x = PlayerX And y = PlayerY Then
                Print "@"; ' Draw the player
            Else
                If MapTiles(x, y).Symbol = "." Then
                    Print "o";
                Else
                    Print MapTiles(x, y).Symbol;
                End If
            End If
        Next x
        Print
    Next y
    Print "Goals completed: " + Str$(GoalsCompleted) + "/" + Str$(NumGoals) + "/" + Str$(GoalsCoveredCount)
End Sub

Sub MovePlayer (newX, newY)

    prevX = PlayerX
    prevY = PlayerY

    currentTile = MapTiles(PlayerX, PlayerY)
    prevSymbol = currentTile.Symbol
    prevIsGoal = currentTile.IsGoal

    If currentTile.IsGoal = 1 Then
        currentTile.Symbol = "."
        MoveBox PlayerX, PlayerY, newX, newY
    Else
        currentTile.Symbol = " "
    End If

    PlayerX = newX
    PlayerY = newY

End Sub

Sub MoveBox (boxX, boxY, newBoxX, newBoxY)
    'Dim boxTile As Tile ' Πρέπει να δηλώσετε τις μεταβλητές boxX και boxY
    If newBoxTile.Symbol = "." Then
        'positionAfterBox = MapTiles(newBoxX + (newBoxX - boxX), newBoxY + (newBoxY - boxY))

        If newBoxX >= 1 And newBoxX <= MapWidth And newBoxY >= 1 And newBoxY <= MapHeight Then
            newBoxTile = MapTiles(newBoxX, newBoxY)

            If positionAfterBox.Symbol <> "." Then
                boxTile = MapTiles(boxX, boxY)
                If boxTile.IsGoal = 1 Then
                    boxTile.Symbol = "."
                Else
                    boxTile.Symbol = " "
                End If

                newBoxTile.Symbol = "$"
                MapTiles(newBoxX, newBoxY).Symbol = "."
                MapTiles(newBoxX, newBoxY).HasBox = 1
                MapTiles(boxX, boxY).HasBox = 0
                GoalsCoveredCount = GoalsCoveredCount + 1
                MoveBox PlayerX, PlayerY, newBoxX, newBoxY
                MovePlayer boxX, boxY
            End If
        ElseIf newBoxTile.Symbol = " " Then
            boxTile = MapTiles(boxX, boxY)
            If boxTile.IsGoal = 1 Then
                boxTile.Symbol = "."
            Else
                boxTile.Symbol = " "
            End If
        End If
    End If
End Sub

Sub InitializeGame ()
    NumGoals = 6
    GoalsCompleted = 0
    ' Set up player
    PlayerX = 11
    PlayerY = 9
    MapTiles(PlayerX, PlayerY).Symbol = "@"

    For y = 1 To MapHeight
        For x = 1 To MapWidth
            Map(x, y) = Asc(" ")
        Next x
    Next y

    For y = 1 To MapHeight
        For x = 1 To MapWidth
            MapTiles(x, y).Symbol = " "
            MapTiles(x, y).IsGoal = 0
            MapTiles(x, y).IsBox = 0
        Next x
    Next y
    For x = 1 To MapWidth
        MapTiles(x, 1).Symbol = "*"
        MapTiles(x, MapHeight).Symbol = "*"
    Next x

    For y = 1 To MapHeight
        MapTiles(1, y).Symbol = "*"
        MapTiles(MapWidth, y).Symbol = "*"
    Next y
End Sub

Sub LoadLevel (levelNumber As Integer)
    ReDim levelMap(levelNumber, 23) As String * 25 ' Δημιουργία του δυναμικού πίνακα με τον απαιτούμενο αριθμό σειρών
    levelMap(levelNumber, 1) = "      #####                  "
    levelMap(levelNumber, 2) = "      #  #                  "
    levelMap(levelNumber, 3) = "      #$  #                  "
    levelMap(levelNumber, 4) = "    ###  $#                  "
    levelMap(levelNumber, 5) = "    #  $ $ #                  "
    levelMap(levelNumber, 6) = "    # # ## # #####            "
    levelMap(levelNumber, 7) = " #### # ## ##  ..#            "
    levelMap(levelNumber, 8) = " # $  $        ..#            "
    levelMap(levelNumber, 9) = " #### ## # ##  ..#            "
    levelMap(levelNumber, 10) = "  ### ## #########            "
    levelMap(levelNumber, 11) = "  #              #            "
    levelMap(levelNumber, 12) = "  ################            "

    For row = 1 To MapHeight
        For col = 1 To MapWidth
            tileSymbol = Mid$(levelMap(levelNumber, row), col, 1)

            MapTiles(col, row).Symbol = tileSymbol
            MapTiles(col, row).IsBox = 0
            MapTiles(col, row).IsGoal = 0

            If tileSymbol = "$" Then
                MapTiles(col, row).IsBox = 1
            ElseIf tileSymbol = "." Then
                MapTiles(col, row).IsGoal = 1
            End If
        Next col
    Next row
End Sub
I have problems with the push of the boxes.
Huh 

help please.

Thanks again.


RE: Goals(1) = New Tile() - bplus - 09-03-2023

I think you want to MoveBox when player is trying to go into $ location.

So when moving player see if he is trying to go into $ sign place.
But then there is a problem: can the box be moved in the direction the player is pushing?

I looked up the SmallBASIC version of Sokoban here:
https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games%202/sokoban.bas

It is massive!!! but might help you @gaslouk ???
(I never learned that game, at first I thought it 2048 another one I never tried.)