Hi KLaus, thanks for the fast reply!
I had to make time to recreate some of the scripts I've been trying, to show what works and what not.
I don't understand all the terms used in the dictionary at AccRen, compositor is a new term to me, but I do understand that it sets some graphical atributes to a platform optimized setting.
Sorry for the confusion but I got my terms mixed up in the questioning, it's not the accelerated renderring but the gamming loop from the gamming accademy that I think creates a framebased loop.
Honestly I don't fully understand the gameloop itself yet, (it is not explained in the accadamy) I've been checking the explanations in the dictionary and get the most parts of it though.
So the questions should be;
Is it possible to make the gamming loop work with time related commands?
If not why not?
Is there an other way to make a gameloop where you can use the move and time related command?
I've added the gameloopscript (complete stack)
From the cardscript (with comments) I've added the parts which are gameloop related, movement that works and some I tried but don't work ussing move or time related commands.
My goals are to make the enemy move in different patterns and to make the rocket (playercontroled button) move in different ways, for example with a little jump when clicked instead of a straight line up or down if pushed.
Again thanks for replying / any thoughts on this that help.
Greets,
JohnA
--------------------------------------
//Stack script complete
local sStartUpdateTime
local sFrameRate
local sUpdateMessageId
on activateScreenUpdates
stopUpdatingTheScreen
startUpdatingTheScreen 50
end activateScreenUpdates
on startUpdatingTheScreen pFrameRate
put pFrameRate into sFrameRate
put 0 into sStartUpdateTime
send "dispatchUpdateScreen" to me in 0 millisecs
put the result into sUpdateMessageId
end startUpdatingTheScreen
on stopUpdatingTheScreen
if sUpdateMessageId is not empty then
cancel sUpdateMessageId
end if
put empty into sUpdateMessageId
end stopUpdatingTheScreen
on dispatchUpdateScreen
local tThisFrameTime
put the long seconds into tThisFrameTime
if sStartUpdateTime is 0 then
put the long seconds into sStartUpdateTime
end if
lock screen
dispatch "updateScreen" to this card with tThisFrameTime
unlock screen
local tTheTimeNow
put the long seconds into tTheTimeNow
local tNextFrameCount
put round((tTheTimeNow - sStartUpdateTime) * sFrameRate + 0.5) into tNextFrameCount
send "dispatchUpdateScreen" to me in (sStartUpdateTime + (tNextFrameCount * (1 / sFrameRate)) - tTheTimeNow) seconds
put the result into sUpdateMessageId
end dispatchUpdateScreen
-----------------------------------------------------------
//Relevant cardscript
//Some handlers related to the gameloop/ general game
on preOpencard
set the acceleratedRendering of this stack to true
end preOpencard
on startGame
activateScreenUpdates
Clearenemies
ClearPU
if sGamerunning is false then
set the location of btn "Rocket" to 160,300
end if
put true into sGamerunning
end startGame
on stopGame
put false into sGamerunning
end stopGame
on updateScreen
if sGamerunning is true then
moveTerrain
moveRocket
HandleEnemys
DetectCollisions
Updatescore
HandlePUs
end if
end updateScreen
//movement handlers which work ussing the gameloop
on moveRocket
if the mouse is down then
if the top of btn "Rocket" - 10 > 0 then
set the top of btn "Rocket" to (the top of btn "Rocket" - 10)
end if
else
if the bottom of btn "Rocket" - 10 < the bottom of this card then
set the top of btn "Rocket" to (the top of btn "Rocket" + 10)
end if
end if
end moveRocket
on HandleEnemys
if random(100) is 1 then
CreateEnemy
end if
if random(100) is 1 then
CreateEnemyb
end if
if random(100) is 1 then
CreateEnemyc
end if
//(diagonal moving enemy)
repeat for each key tEnemy in sEnemynames
set the right of btn tEnemy to (the right of btn tEnemy - 5)
set the top of btn tEnemy to (the top of btn tEnemy - 1)
if the right of btn tEnemy < 0 then
delete btn tEnemy
delete variable sEnemynames[tEnemy]
end if
end repeat
//(straight moving enemy)
repeat for each key tEnemyb in sEnemynamesb
set the right of btn tEnemyb to (the right of btn tEnemyb - 5)
if the right of btn tEnemyb < 0 then
delete btn tEnemyb
delete variable sEnemynamesb[tEnemyb]
end if
end repeat
//(enemy moving in a (limited) pattern)
repeat for each key tEnemyc in sEnemynamesc
if the right of btn tEnemyc > (0.8 * the width of this card) then
set the right of btn tEnemyc to (the right of btn tEnemyc - 5)
set the top of btn tEnemyc to (the top of btn tEnemyc + 2)
end if
if the right of btn tEnemyc <= (0.8 * the width of this card) then
set the right of btn tEnemyc to (the right of btn tEnemyc - 5)
set the top of btn tEnemyc to (the top of btn tEnemyc - 4)
end if
if the right of btn tEnemyc <= (0.5 * the width of this card) then
set the right of btn tEnemyc to (the right of btn tEnemyc - 5)
set the top of btn tEnemyc to (the top of btn tEnemyc +

end if
if the right of btn tEnemyc < (0.1 * the width of this card) then
set the right of btn tEnemyc to (the right of btn tEnemyc - 5)
end if
if the right of btn tEnemyc < 0 then
delete btn tEnemyc
delete variable sEnemynamesc[tEnemyc]
end if
end repeat
end HandleEnemys
//this handler works with the gameloop to create a timer scrollbar I tried a number of time related commands to create this but nothing worked eventualy I found this option that enabels me to time a powerup for 20 seconds and then stop it using the stopghost handler
on Gtimer1
set the thumbposition of sb "ghostscrollbar" to tghostsec
send "GTimer2" to me in 1 seconds
end Gtimer1
on Gtimer2
if the thumbposition of sb "ghostscrollbar" < 20 then
add 1 to tghostsec
Gtimer1
else
Stopghost
end if
end Gtimer2
//These are handlers I tried but don't work (properly) ussing move or time related commands
on moveRocket
set the bottomleft of graphic "Path" to the loc of btn "Rocket" //- sets a hand drawn curved line graphic in position, does not work for the game because the rocket should not move forward but I wanted to experiment on this.
if the mouse is down then
if the top of btn "Rocket" - 10 > 0 then
move btn "Rocket" to the points of graphic "Path" in 120 ticks without messages //(moves in on go from beginning to end of line instead of (what I wanted) point to point per frame, also time freezes the gameloop for 120 ticks (2 seconds))
else
if the bottom of btn "Rocket" - 10 < the bottom of this card then
set the top of btn "Rocket" to (the top of btn "Rocket" + 5)
end if
end if
end moveRocket
//(another option I tried)
on moveRocket
if the mouseClick is true then // (here I tried to create a little jump with a mouseclick or tap on the sreen)
if the top of btn "Rocket" - 10 > 0 then
set the movespeed to 500
move btn "Rocket" relative 0, -50 in 60 ticks without messages
end if
else
if the bottom of btn "Rocket" - 10 < the bottom of this card then
set the top of btn "Rocket" to (the top of btn "Rocket" + 5)
end if
end if
end moveRocket