Open coolbutuseless opened 1 week ago
This package includes isometric_landscape
which is a collection of 36
isometric tiles (as a list of nativeRasters)
library(grid)
set.seed(1)
# Set up staggered x coordinates for even/odd rows
even <- 0 + (0:5) * 60
odd <- 31 + (0:5) * 60
# Sample from just the tree/house tiles.
# Weight the 'basic' tile to occur much more often
tile_idxs <- grep("basic|house|tree", names(isometric_landscape))
probs <- rep(1, length(tile_idxs))
probs[1] <- 30
# A blank cvanas
nr <- nr_new(420, 420, 'white')
# generate isometric tiles from the top down
for (y in seq(0, 350, 30)) {
select <- sample(tile_idxs, length(odd), T, prob = probs)
for (i in seq_along(odd)) {
nr_blit(nr, odd[i], y - 15, isometric_landscape[[select[[i]]]])
}
select <- sample(tile_idxs, length(even), T, prob = probs)
for (i in seq_along(even)) {
nr_blit(nr, even[i], y, isometric_landscape[[select[i]]])
}
}
grid.newpage()
grid.raster(nr, interpolate = FALSE)