Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.70 KB | None | 0 0
  1. class Map < Base
  2.   def start
  3.     create_ground
  4.   end
  5.  
  6.   def create_ground
  7.     @ground = Sprite.new(nil)
  8.     @ground.z = 0
  9.     @ground.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  10.     @tileset = Bitmap.new('Graphics/Tilesets/0.png')
  11.    
  12.     draw_ground
  13.   end
  14.  
  15.   def draw_ground
  16.     src_bitmap = @tileset
  17.     src_rect = Rect.new(16 * 7, 16, 16, 16)
  18.    
  19.     max_x = Graphics.width / 16
  20.     max_y = Graphics.height / 16
  21.    
  22.     @ground.bitmap.clear
  23.     for x in 0...max_x
  24.       for y in 0...max_y
  25.         dest_rect = Rect.new(x * 16, y * 16, 16, 16)
  26.         @ground.bitmap.stretch_blt(dest_rect, src_bitmap, src_rect)
  27.       end
  28.     end
  29.   end
  30.  
  31.   def terminate
  32.    
  33.   end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement