SHARE
TWEET

Untitled

a guest Feb 27th, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. class GAME
  4.  
  5.   attr_accessor :args, :state, :inputs, :outputs, :grid
  6.  
  7.   def defaults
  8.     state.enemies ||= [RAT.new(0), RAT.new(1), RAT.new(2)]
  9.     state.temp1 ||= []
  10.     state.temp ||= []
  11.    
  12.     state.room_floors ||= []
  13.     state.room_pieces ||= []
  14.     state.room_pieces[0] ||= file_read
  15.     state.room_pieces[1] ||= file_read_wall_1
  16.     state.enemies.each do |enemy|
  17.       enemy.state = state
  18.       enemy.outputs = outputs
  19.     end
  20.     $player1 ||= Player.new
  21.     state.walls_1 ||= [$player1]
  22.     #state.rooms[0].outputs = outputs
  23.    
  24.     #state.enemies[0].inputs = inputs
  25.     if state.tick_count == 30
  26.      # p state.rooms[0].rooms_to_render.to_s
  27.     end
  28.   end
  29.  
  30.   def file_read_wall_1
  31.     state.temp1 = $gtk.read_file('/tilemap/world1/home_base_Walls_Left_Down.csv')
  32.     p state.temp1
  33.     state.temp1.each_line.with_index do |row, x|
  34.       row.split(',').each.with_index do |tile, y|
  35.         @max_x = state.temp1.each_line.count
  36.         @max_y = row.split(',').count
  37.         state.walls_1 << Room.new(10 - x, y, tile.to_i, 220, 300, @max_x.to_i, @max_y.to_i,"walls",1)
  38.       end
  39.     end
  40.   end
  41.  
  42.   def file_read
  43.     state.temp = $gtk.read_file('/tilemap/world1/home_base_Floors.csv')
  44.     p state.temp
  45.     state.temp.each_line.with_index do |row, x|
  46.       row.split(',').each.with_index do |tile, y|
  47.         @max_x = state.temp[0].each_line.count
  48.         @max_y = row.split(',').count
  49.         state.room_floors << Room.new(10 - x, y, tile.to_i, 220, 300, @max_x.to_i, @max_y.to_i,"floor",0)
  50.         p state.room_floors
  51.       end
  52.     end
  53.    end
  54.  
  55.   def tick args
  56.     defaults
  57.     #state.enemies.each do |enemy|
  58.       #puts enemy
  59.       #enemy.tick
  60.     #end
  61.     #state.rooms[0]
  62.     state.rooms[0].defaults
  63.     #puts state.rooms[0].rooms_to_render.to_s
  64.     render_floor
  65.     $player1.state = args.state
  66.     $player1.inputs = args.inputs
  67.     $player1.outputs = args.outputs
  68.     $player1.tick
  69.     render_walls_1
  70.    
  71.   end
  72.   def render_floor
  73.     state.room_floors.each do |room|
  74.       outputs.sprites << room
  75.       #p rooms.to_s
  76.     end
  77.   end
  78.  
  79.   def render_walls_1
  80.     sorted_walls.each do |room|
  81.       outputs.sprites << room
  82.     end
  83.   end
  84.  
  85.   def sorted_walls
  86.     state.walls_1.sort do |a,b|
  87.       b.y <=> a.y
  88.     end
  89.   end
  90.  
  91. 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