SHARE
TWEET

Untitled

a guest Feb 26th, 2020 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Room
  2.   attr_sprite
  3.   def initialize(x, y, tile_index)
  4.     @index = tile_index
  5.     @w = 63
  6.     @h = 32
  7.     @tile_w = 63
  8.     @tile_h = 32
  9.     @tile_x = tile_index * @tile_w
  10.     @tile_y = tile_index * @tile_h
  11.     @x = x * @tile_w
  12.     @y = y * @tile_h
  13.   end
  14.   def to_s
  15.     "x: #{@x}, y: #{@y}, tile_w: #{@tile_w}, tile_h: #{@tile_h}, tile_x: #{@tile_x}, tile_y: #{@tile_y}"
  16.   end
  17. end
  18.  
  19.  
  20.   #tiles stuff
  21.  
  22.   class Rooms
  23.     attr_accessor :coord_x, :coord_y, :index_x, :index_y, :file, :room_floor, :tiles, :size_x, :size_y, :temp, :state, :outputs, :x_temp, :y_temp, :sprites, :rooms_to_render                              
  24.  
  25.     def tick
  26.         default
  27.         render
  28.     end
  29.  
  30.     def default
  31.         @room_floor ||= '/tilemap/world1/home_base_Floors.csv'
  32.         @tiles ||= []
  33.         @temp ||= []
  34.         @index_x ||= []
  35.         @index_y ||= []
  36.         @rooms_to_render ||= []
  37.         @tiles[0] ||= file_read
  38.         #puts @tiles[0]
  39.         @size_x ||= 7
  40.         @size_y ||= 7
  41.         #@index_x ||= interpret_x
  42.         #@index_y ||= interpret_y
  43.         @x_temp ||= []
  44.         @y_temp ||= []
  45.         @coord_x ||= [1000]
  46.         @coord_y ||= [600]        
  47.     end
  48.  
  49.     def file_read
  50.       def file_read
  51.         @temp = $gtk.read_file(@room_floor)
  52.         @temp.each_line.with_index do |row, x|
  53.           row.split(',').each.with_index do |tile, y|
  54.             @rooms_to_render << Room.new(x, y, tile.to_i)
  55.           end
  56.         end
  57.        end
  58.      end
  59.  
  60.      def render
  61.       @rooms_to_render.each do |room|
  62.         outputs.sprites << room
  63.       end
  64.     end
  65. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top