Skip to content

Commit

Permalink
Added a small api to the spritesheet for two-dimensional indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
avivbeeri committed Mar 15, 2023
1 parent 4906e9e commit 9d8ecf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/modules/graphics.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ Draw tile `index` on the spritesheet at location `(x, y)` on screen.
Draw tile `index` on the spritesheet at location `(x, y)` on screen. This will also apply the given transform `parameterMap` to the tile being drawn.
You can reference the `ImageData.transform` documentation for a list of available parameters.

#### `draw(tileX: Number, tileY: Number, x: Number, y: Number)`
Draw tile `(tileX, tileY)` on the spritesheet at location `(x, y)` on screen.

#### `draw(tileX: Number, tileY: Number, x: Number, y: Number, parameterMap)`
Draw tile `(tileX, tileY)` on the spritesheet at location `(x, y)` on screen. This will also apply the given transform `parameterMap` to the tile being drawn.
You can reference the `ImageData.transform` documentation for a list of available parameters.

### Instance Methods

#### `fg: Color`
Expand Down
Empty file removed docs/modules/image.md
Empty file.
2 changes: 2 additions & 0 deletions src/modules/image.wren
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class SpriteSheet {
return _cache[s]
}

draw(sx, sy, x, y, modMap) { draw(sy * _width + sx, x, y, modMap) }
draw(sx, sy, x, y) { draw(sy * _width + sx, x, y) }
draw(s, x, y) { draw(s, x, y, null) }
draw(s, x, y, modMap) {
getTile(s).modify(modMap || {
Expand Down

0 comments on commit 9d8ecf9

Please sign in to comment.