Last active
July 5, 2023 00:48
-
-
Save thewatts/e322396d24e05d6ac01144acfbe8d670 to your computer and use it in GitHub Desktop.
DR Perf
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
# module GTK | |
# class Runtime | |
# def __sdl_tick__ sdl_tick | |
# @sdl_tick = sdl_tick | |
# tick_argv | |
# return if @no_tick | |
# __sdl_tick__simulation__ | |
# rescue Exception => e | |
# @last_tick_exception_global_at = Kernel.global_tick_count | |
# pretty_print_exception_and_export! e | |
# pause! | |
# end | |
# end | |
# end | |
def generate_maps(number_of_maps, size) | |
width, height = 1280, 720 # 720p HD resolution | |
tile_width = width / size | |
tile_height = height / size | |
maps = [] | |
colors = [ | |
{ r: 255, g: 0, b: 0 }, # red | |
{ r: 0, g: 255, b: 0 }, # green | |
{ r: 0, g: 0, b: 255 }, # blue | |
{ r: 255, g: 165, b: 0 }, # orange | |
{ r: 255, g: 255, b: 0 } # yellow | |
] | |
number_of_maps.times do |number| | |
puts number | |
map = [] | |
size = (tile_width * tile_height).to_i | |
size.times do |i| | |
x = (i % tile_width) * size | |
y = (i / tile_width) * size | |
color = colors.sample | |
map << { x: x, y: y, size: size, r: color[:r], g: color[:g], b: color[:b] } | |
end | |
maps << map | |
end | |
maps | |
end | |
def tick(args) | |
number_of_maps = 180 # change me for per testing :) | |
size_of_tile = 4 # px | |
args.state.maps ||= generate_maps(number_of_maps, size_of_tile) | |
# puts args.state.maps.first | |
args.outputs.sprites << args.state.maps.first | |
left_padding = 30 | |
args.outputs.labels << [left_padding, 30.from_top, "FPS: #{args.gtk.current_framerate.to_sf}"] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment