Posts: 35
Threads: 5
Joined: Apr 2022
Reputation:
5
Code: (Select All) ReDim Goals(6)
Goals(1) = New Tile()
Goals(1).Symbol = "o"
Expected operator in equation
Help.
thank you.
Posts: 1,272
Threads: 119
Joined: Apr 2022
Reputation:
100
08-31-2023, 06:08 PM
(This post was last modified: 08-31-2023, 06:09 PM by TerryRitchie.)
(08-31-2023, 05:42 PM)gaslouk Wrote: Code: (Select All) ReDim Goals(6)
Goals(1) = New Tile()
Goals(1).Symbol = "o"
Expected operator in equation
Help.
thank you. What is "New Tile()"? If that's meant to be a function or UDT the space is not allowed.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Posts: 1,586
Threads: 59
Joined: Jul 2022
Reputation:
52
(08-31-2023, 05:42 PM)gaslouk Wrote: Code: (Select All) Goals(1) = New Tile()
QB64 doesn't have "new" operator, it doesn't support object-oriented programming. Yet.
Posts: 207
Threads: 13
Joined: Apr 2022
Reputation:
52
08-31-2023, 09:45 PM
(This post was last modified: 08-31-2023, 09:47 PM by RhoSigma.)
(08-31-2023, 05:42 PM)gaslouk Wrote: Code: (Select All) ReDim Goals(6)
Goals(1) = New Tile()
Goals(1).Symbol = "o"
Expected operator in equation
Help.
thank you.
As mentioned "new" is an operator for object oriented programming languages such as C++, PHP, Javascript etc. which is not possible in QB64(PE), however REDIM can do the job, but "Tile" have to be a user defined TYPE instead of a function.
Code: (Select All) Type Tile
Symbol As String * 1 'use higher numbers if you need more chars
End Type
ReDim Goals(6) As Tile
Goals(1).Symbol = "o"
Goals(2).Symbol = "x"
Goals(3).Symbol = "*"
etc.
Posts: 35
Threads: 5
Joined: Apr 2022
Reputation:
5
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
Bless you. That sounds rough!
Posts: 207
Threads: 13
Joined: Apr 2022
Reputation:
52
09-01-2023, 08:35 AM
(This post was last modified: 09-01-2023, 08:37 AM by RhoSigma.)
Posts: 35
Threads: 5
Joined: Apr 2022
Reputation:
5
09-01-2023, 08:49 AM
(This post was last modified: 09-01-2023, 09:40 AM by gaslouk.)
Code: (Select All) Dim Shared row, col As Integer
Dim Shared levelMap(1 To 12) As String
Dim Shared tileSymbol As String
Sub LoadLabel (numLevel)
' Δημιουργία χάρτη του παιχνιδιού
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
Help.
thank you.
Posts: 3,966
Threads: 176
Joined: Apr 2022
Reputation:
219
09-01-2023, 09:28 AM
(This post was last modified: 09-01-2023, 09:32 AM by bplus.)
(09-01-2023, 08:49 AM)gaslouk Wrote: Code: (Select All) Dim Shared row, col As Integer
Dim Shared levelMap(1 To 12) As String
Dim Shared tileSymbol As String
Sub LoadLabel (numLevel)
' Δημιουργία χάρτη του παιχνιδιού
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
Help.
thank you.
Needed to end with [/code]
b = b + ...
Posts: 35
Threads: 5
Joined: Apr 2022
Reputation:
5
(09-01-2023, 09:28 AM)bplus Wrote: (09-01-2023, 08:49 AM)gaslouk Wrote: Code: (Select All) Dim Shared row, col As Integer
Dim Shared levelMap(1 To 12) As String
Dim Shared tileSymbol As String
Sub LoadLabel (numLevel)
' Δημιουργία χάρτη του παιχνιδιού
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
Help.
thank you.
Needed to end with [/code] Thanks bplus
|