diff options
Diffstat (limited to '')
-rw-r--r-- | randtilegen.rb | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/randtilegen.rb b/randtilegen.rb index f77d333..f92db5d 100644 --- a/randtilegen.rb +++ b/randtilegen.rb @@ -11,9 +11,19 @@ class RandTileGenerator end def random(range, type=:both, numbers=nil) - numbers = range if numbers.nil? - - @current_section[:entries] << {range: range, type: type, numbers: numbers.to_a} + case range + when Range + # Regular handling + numbers = range if numbers.nil? + @current_section[:entries] << {range: range, type: type, numbers: numbers.to_a} + when Numeric + # One number + random(range..range, type, numbers) + when Enumerable + # An array or something else similar + numbers = range if numbers.nil? + range.each { |r| random(r, type, numbers) } + end end def pack @@ -79,6 +89,33 @@ class RandTileGenerator output << "\0" output.join end + + + def regular_terrain + # Left Side + random([0x10, 0x20, 0x30, 0x40], :vert) + # Right Side + random([0x11, 0x21, 0x31, 0x41], :vert) + # Top Side + random(2..7, :horz) + # Bottom Side + random(0x22..0x27, :horz) + # Middle + random(0x12..0x17) + end + + def sub_terrain + # Left Side + random([0x18, 0x28, 0x38, 0x48], :vert) + # Right Side + random([0x19, 0x29, 0x39, 0x49], :vert) + # Top Side + random(0xA..0xF, :horz) + # Bottom Side + random(0x2A..0x2F, :horz) + # Middle + random(0x1A..0x1F) + end end @@ -89,6 +126,11 @@ g.section('TestTileset') do g.random(250..255, :vert, 0..5) end +g.section('Pa1_nohara') do + g.regular_terrain + g.sub_terrain +end + File.open('/home/me/Games/Newer/DolphinPatch/NewerRes/RandTiles.bin', 'wb') do |f| f.write g.pack end |