I'm attempting to iterate through files in a sequence to create a small animation using DragonRuby, but I'm encountering an error when attempting to use the Dir class, which is commonly used in Ruby. Here's the error message:
EXCEPTION THROWN:
uninitialized constant FujiwaraGame::Dir
Backtrace:
app/main.rb:362:in video
app/main.rb:347:in render_video
app/main.rb:105:in render
app/main.rb:82:in gameplay
app/main.rb:74:in game_state
app/main.rb:405:in tick
app/main.rb:417:in tick
It seems that the Dir class is not recognized in this framework. Is there an alternative method to access my files? Here's the code I was attempting to use:
def video
x = 0
y = TILE_SIZE * 3
w = 1280
h = (720 - 80) - y # Adjusted for the HUD height
@video_image ||= { x: x, y: y, w: w, h: h, path: 'sprites/misc/frame_0000.png'}
video_file ||= ''
d = Dir.new("video")
d.each {|x| puts "Got #{x}" }
end
This issue occurs whenever I try to use the Dir class, not just in this specific function. Additionally, the directory containing the files is inside the project folder, so that shouldn't be the issue.
How can I use the Dir class in DragonRuby to access files in a directory for creating animations?
open files in a directory to make a small animation using the native to Ruby Dir class
It looks like DragonRuby is compliant with the ISO/IEC 30170:2012 Information technology — Programming languages — Ruby specification.
Diris not part of ISO Ruby, it is an extension.