Skip to content

Instantly share code, notes, and snippets.

@jdm
Created November 13, 2016 18:46
Show Gist options
  • Save jdm/6e3f60724e7f197d26ced4ea52a0f0d7 to your computer and use it in GitHub Desktop.
Save jdm/6e3f60724e7f197d26ced4ea52a0f0d7 to your computer and use it in GitHub Desktop.
let num_h_tiles = tile.sheet.sheet_size.0;
let tile_w = tile.sheet.tile_size.0;
let tile_h = tile.sheet.tile_size.1;
let src_x = tile.index % num_h_tiles * tile_w;
let src_y = tile.index / num_h_tiles * tile_h;
let image = Image::new()
.src_rect([src_x as i32,
src_y as i32,
tile_w as i32,
tile_h as i32])
.rect([(x * tile_w) as f64, (y * tile_h) as f64, tile_w as f64, tile_h as f64])
let transform = c.transform.scale(SCALE, SCALE);
image.draw(texture, &Default::default(), transform, gl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment