Card Script - copy the following into your "Card" script: local sGameRunning on preOpenCard set the acceleratedRendering of this stack to true end preOpenCard on startGame activateScreenUpdates put true into sGameRunning end startGame on stopGame put false into sGameRunning end stopGame on updateScreen if sGameRunning is true then moveBox -- moveTerrain -- moveEnemy -- detectCollisions -- updateScore end if end updateScreen on moveBox if keysdown() = 65362 then set the top of the button "box" to the top of the button "box" - 4 if the top of the button "box" < the top of the card "level1" then set the top of the button "box" to the top of the card "level1" end if end if if keysdown() = 65364 then set the bottom of the button "box" to the bottom of the button "box" + 4 if the bottom of the button "box" > the bottom of the card "level1" then set the bottom of the button "box" to the bottom of the card "level1" end if end if if keysdown() = 65361 then set the left of the button "box" to the left of the button "box" - 4 if the left of the button "box" < the left of the card "level1" then set the left of the button "box" to the left of the card "level1" end if end if if keysdown() = 65363 then set the right of the button "box" to the right of the button "box" + 4 if the right of the button "box" > the right of the card "level1" then set the right of the button "box" to the right of the card "level1" end if end if end moveBox |
Home > Game Loops - Advanced >