Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Template
- attr_accessor :id
- attr_accessor :width
- attr_accessor :height
- attr_accessor :map
- attr_accessor :pattern
- def initialize(id, width, height, pattern)
- @id = id
- @width = width
- @height = height
- @pattern = pattern
- readTemplate()
- end
- def readTemplate()
- @map = load_data(sprintf("Data/Map%03d.rxdata",@id))
- end
- end
- def mergeArrays(a, b, x, y, mask)
- tp = b.map
- x_limit = b.width
- y_limit = b.height
- for j in y..y_limit+y
- for k in x..x_limit+x
- for l in 0..2
- begin
- if tp.data[k-x,j-y,l] != 0 && tp.data[k-x,j-y,l] != nil
- a.data[k,j,l] = tp.data[k-x,j-y,l]
- #p mask[k]
- mask[j][k] = 1
- end
- rescue => exception
- #p exception
- end
- end
- end
- end
- end
- def placeMapOn(template, x, y, mapid)
- map = load_data(sprintf("Data/Map%03d.rxdata",mapid))
- mask = Array.new(map.height){Array.new(map.width){0}}
- mergeArrays(map, template, x, y, mask)
- save_data(map, sprintf("Data/Map%03d.rxdata", mapid))
- end
- def placeTest()
- t = Template.new(4, 8, 4, nil)
- placeMapOn(t, 3, 4, 2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement