B
Bretonator
Guest
I am working with a game that uses procedural generation of sprites, and there is a spritesheet laid out like a 3 dimensioned array. In pseudocode, I imagine referencing it something like this:
image = imgMatrix[3, 2, 0];
imagine a spritesheet called imgMatrix that is laid out in quadrants with 3x3 square sprites in each quadrant. In array sizing pseduocode: imgMatrix[3,2,2]
Each numeric value would be multiplied to find a corresponding coordinate on the spritesheet and then just use or draw only a selected portion of it. The 3 would perhaps correspond to the fourth quadrant of the spritesheet. 2 would be the row, 0 the column:
-------------------
|..........|...........|
|..........|...........|
|..........|...........|
---------|----------
|..........|...........|
|..........|...........|
|..........|X........|
-------------------
'X' would be the desired sprite portion to reference and display on screen
I'm trying to figure a way to select a portion of a spritesheet without having to "cut it up" as we normally do and create far too many sprites to fiddle with.
Is there a way to do this?
image = imgMatrix[3, 2, 0];
imagine a spritesheet called imgMatrix that is laid out in quadrants with 3x3 square sprites in each quadrant. In array sizing pseduocode: imgMatrix[3,2,2]
Each numeric value would be multiplied to find a corresponding coordinate on the spritesheet and then just use or draw only a selected portion of it. The 3 would perhaps correspond to the fourth quadrant of the spritesheet. 2 would be the row, 0 the column:
-------------------
|..........|...........|
|..........|...........|
|..........|...........|
---------|----------
|..........|...........|
|..........|...........|
|..........|X........|
-------------------
'X' would be the desired sprite portion to reference and display on screen
I'm trying to figure a way to select a portion of a spritesheet without having to "cut it up" as we normally do and create far too many sprites to fiddle with.
Is there a way to do this?
Last edited by a moderator: