Last active
August 29, 2021 18:33
-
-
Save xenobrain/1d2a736091f43634062f4434f265ee06 to your computer and use it in GitHub Desktop.
This file contains 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
class Renderer | |
attr_accessor(:background, :foreground, :overlay) | |
def initialize | |
@background = [] | |
@foreground = [] | |
@overlay = [] | |
end | |
def draw_override(ffi_draw) | |
@background.shift.call(ffi_draw) until @background.empty? | |
@foreground.shift.call(ffi_draw) until @foreground.empty? | |
@overlay.shift.call(ffi_draw) until @overlay.empty? | |
end | |
def tick(args) | |
args.outputs.sprites << self | |
end | |
end | |
@renderer = Renderer.new | |
def draw_player | |
player = args.state.player | |
@renderer.foreground << proc |ffi| | |
ffi.draw_sprite(player.x, player.y, player.w, player.h, player.path) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment