Created
December 9, 2025 00:46
-
-
Save KonnorRogers/3d356adec6a362e2cc2fef8a374e3d6f to your computer and use it in GitHub Desktop.
render target caching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def tick args | |
| args.state.background ||= { | |
| x: 0, | |
| y: Grid.h / 2, | |
| h: 224 * 2, | |
| w: 1504 * 2, | |
| path: "sprites/background.png" | |
| } | |
| background_sprite = args.state.background | |
| if !args.state.background_rt | |
| args.state.background_rt = args.outputs[:background] | |
| rt = args.state.background_rt | |
| rt.w = background_sprite.w | |
| rt.h = background_sprite.h | |
| rt.sprites << background_sprite.merge({x: 0, y: 0}) | |
| args.state.background_rt_sprite = { | |
| x: 0, | |
| y: -50, | |
| h: 224 * 2, | |
| w: 1504 * 2, | |
| path: :background | |
| } | |
| end | |
| keyboard = args.inputs.keyboard | |
| if keyboard.right | |
| args.state.background.x -= 2 | |
| args.state.background_rt_sprite.x -= 2 | |
| elsif keyboard.left | |
| args.state.background.x += 2 | |
| args.state.background_rt_sprite.x += 2 | |
| end | |
| args.outputs.sprites << args.state.background | |
| args.outputs.sprites << args.state.background_rt_sprite | |
| end | |
| GTK.reset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment