let min = 40 let max = 101 let speed = 60 # how many degrees in a second let setup = fn() { return { .color: { .r: 0, .g: 0, .b: 0, }, .dir: 1, }; } let update = fn(state, input) { let dir = state.dir * speed * get_frame_time(); state.color.g = random_u8() % 1; state.color.r = (state.color.r + dir) % max; if state.color.r < min { state.color.r = min; }; state.dir = if state.color.r >= (max - 1) { -1 } else { if state.color.r <= min { 1 } else { state.dir } }; return state; } let draw = fn(state) { frame_clear(state.color.r, state.color.g, state.color.b); } let migrate = fn(state) { return { .player: { .pos: state.player.position } }; }