You can use a constant in the function, but wouldn't be able to use it to define an array:
+ Code Snippet#CONSTANT MAP_WIDTH = GetVirtualWidth() / 64
dim map[MAP_WIDTH, MAP_HEIGHT] as MapObj // error
So you're thinking, just make a global instead, right? Wrong. Global must be an integer literal or constant
And by constant, it really means literal because you can't assign a constant to a global, you'll get the same error still.
This is the only way I was able to get my constant value to work in both array allocation and for use in a function. But this also means I had to explicitly define the resolution. It's just an extra step I don't feel should be necessary.
+ Code Snippetglobal _screenWidth = 1024
global _screenHeight = 768
SetVirtualResolution( _screenWidth, _screenHeight )
#CONSTANT MAP_WIDTH = _screenWidth / 64
#CONSTANT MAP_HEIGHT = _screenHeight / 64
dim map[MAP_WIDTH, MAP_HEIGHT] as MapObj
The way AppGameKit treats constants is misleading, because it's not a constant at all.
For example, everytime you use MY_INT you'll get a different value. Maybe I needed the next integer for a specific object id and that'll never change for the remainder of the program, but can't do it this way since the constant maps to the function call rather than assigning the returned value.
+ Code Snippetglobal myInt = 0
#CONSTANT MY_INT = getInt()
function getInt()
inc myInt
endfunction myInt