Main Gameloop
ram.run.Rdram.run() runs the main gameloop, continuously ticking and drawing.
The game can be paused with ^C, and will resume when ram.run() is called again.
Arguments
- RAM
RAM object to run.
- start_at
RAM will wait until
time.sec()==this value to start running. IfNULL, RAM starts running immediately. This argument is used to sync multiplayer sessions and otherwise doesn't matter.
Details
This function runs the following code and returns the RAM upon interruption by ^C or error.
The function will also print a full traceback if it encounters an error.
Function Tree
Functions are nested in the gameloop like so:
ram.run() ram.update() every frame (see vignette("timing")) inputs.get() inputs.read() inputs.command() if any commands are sent ram.rollback() if any inputs were received late inputs.process() ram.tick() RAM$ROM$custom() render.ram() if RAM$time > time.sec() render.object() for every object in RAM$objects render.animate() if the object has a complex sprite render.sprite() or custom obj$draw() render.overlay() render.scene() render.overlay() for every layer in scene$layers render.matrix()
Examples
if (FALSE) { # \dontrun{
RAM = ram.init(BadApple)
RAM = ram.run(RAM)
#pause with ^C,
RAM = ram.run(RAM) #to resume
} # }