BASIC COMMANDS ( CORE )
First
This function returns the first member of a linked list (a Type)
Example:
enemy.EN = First(EN)
(EN is the name of the Type)
Last
This function returns the last member of a linked list (a Type)
Example:
enemy.EN = Last(EN)
(EN is the name of the Type)
Before
This function returns a member previous than the provided one. You can use this to iterate lists.
Example:
enemy = Before(enemy)
After
This function returns a member next to the provided one. You can use this to iterate lists.
Example:
enemy = After(enemy)
New
This function creates a new member for the provided list (Type), and returns its handle.
Example:
bul.BULLET = New(BULLET)
(BULLET is the name of the Type, 'bul' is the new variable)
Insert
You can control where you INSERT the current TYPE object into the TYPE collection. When you create a new Type object with the NEW command, it is automatically appended to the END of the collection. Using INSERT along with BEFORE and AFTER (and electively FIRST and LAST) to put the Type object exactly where you want it.
Example:
bul.BULLET = New(BULLET)
Insert bul After(First(BULLET))
Delete
This command deletes a member from the list
Example:
Delete bul
ConvertToInteger
CoolBasic currently does not support passing type variables to functions, nor does it support returning typed values. With this function you can temporarily convert a type variable into an integer so you can pass it to a function as normal variable. Back in the function you can convert it back using the ConvertToType-function.
Example:
pointer = ConvertToInteger(bul)
ConvertToType
This function converts an integer pointer into a type variable. See function "ConvertToInteger" for more details.
Example:
bul.BULLET = ConvertToInteger(pointer)
Data, Read, Restore
With these structures you can store a list of integers, floats or strings into your source code, and then read them as if you were reading a data file. Data elements can be used to store map data, for instance.
Example:
Restore map1
Dim map(6,5)
'----------------------
'read level 1
Restore level1
For y=1 To 5
For x=1 To 6
map(x,y)=READ()
Next x
Next y
'----------------------
'main loop
Repeat
For y=1 To 5
For x=1 To 6
If map(x,y) Then Box x*40,y*40,40,40
Next x
Next y
Box 40,40,240,200,OFF
DrawScreen
Until EscapeKey()
End
'----------------------
'you can store more levels, too.
level1:
DATA 0,0,0,0,0,0
DATA 0,0,0,1,0,0
DATA 0,0,1,1,1,0
DATA 0,0,0,1,0,0
DATA 1,0,0,0,0,1
End
This command terminates the program immediately.