yes declaring (and maybe the initial setup such as a basic rota) will go before the main loop
any code to allow users to change it will go in the loop as it will need to be checked in real time (such as functions)
so using Phaelax's example it could look something like this
// Project: rota shift
// Created: 2018-02-21
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "rota shift" )
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
Type Position
original as string
temp as string
EndType
global workers as Position[9]
workers[1].original = "Jon"
workers[2].original = "Terry"
workers[3].original = "Pat"
workers[4].original = "Fred"
workers[5].original = "Brian"
workers[6].original = "Rich"
workers[7].original = "Larry"
workers[8].original = "Sam"
workers[9].original = "Tom"
for a = 1 to 9
workers[a].temp = workers[a].original
next a
AddVirtualButton(1,200,386,200)
SetVirtualButtonText(1,"Reset Rota")
AddVirtualButton(2,500,386,200)
SetVirtualButtonText(2,"Move"+chr(10)+"Forwards")
AddVirtualButton(3,800,386,200)
SetVirtualButtonText(3,"Move"+chr(10)+"Backwards")
do
for a = 1 to 9
Print(workers[a].temp)
next a
if GetVirtualButtonReleased(1)
rebuildTemp()
elseif GetVirtualButtonReleased(2)
rotateForward()
elseif GetVirtualButtonReleased(3)
rotateBackward()
//etc
endif
sync()
loop
// Restores the "temp" list with the original names
function rebuildTemp()
for i = 1 to workers.length
workers[i].temp = workers[i].original
next i
endfunction
function rotateForward()
temp as Position
temp = workers[1]
for i = 1 to workers.length-1
workers[i] = workers[i+1]
next i
workers[workers.length] = temp
endfunction
function rotateBackward()
temp as Position
temp = workers[workers.length]
for i = workers.length to 2 step -1
workers[i] = workers[i-1]
next i
workers[1] = temp
endfunction
function swapshift(a as integer, b as integer)
temp$ = workers[a].temp
workers[a].temp = workers[b].temp
workers[b].temp = temp$
endfunction
function getWorker(pos as integer)
t$ = workers[pos].temp
endfunction t$
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu