you can do all sorts of fun stuff with constants:
// Project: temp
// Created: 2019-05-17
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "temp" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
//Declare ---------------------------------------------------------------------------
type CLASS_Player
name as string
number as integer
endtype
type STATIC_CLASS_Game
players as CLASS_Player[]
currentPlayer as integer
endtype
GLOBAL Game as STATIC_CLASS_Game
//Init ---------------------------------------------------------------------------
#CONSTANT FOREACH_Players for i_Players = 0 to Game.players.length
#CONSTANT THIS_Player Game.Players[i_Players]
tPlayer as CLASS_Player
tPlayer.name = "AAAA"
tPlayer.number = 0
Game.players.insert(tPlayer)
tPlayer.name = "BBBB"
tPlayer.number = 1
Game.players.insert(tPlayer)
tPlayer.name = "CCCC"
tPlayer.number = 2
Game.players.insert(tPlayer)
Game.currentPlayer = 1
do
Players_update()
Sync()
loop
//Updates ====================================================================================================================================================
function Players_update()
FOREACH_Players
if THIS_Player.number = Game.currentPlayer
print(THIS_Player.name + " says hi")
if THIS_Player.name <> "ZZZZ"
Players_setName(i_Players, "ZZZZ")
endif
endif
next i_Players
endfunction
function Players_setName(i_Players as integer, rName as string)
THIS_Player.name = rName
print(" and is now called " + THIS_Player.name)
endfunction
http://games.joshkirklin.com/sulium
A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.