I am currently working on making a program that will rotate sprites 90 degrees clockwise. What I have currently written is:
char* rotsprite_char(int height, char src_matrix[height], char dest_matrix[height])
int i = 0;
int j = 7;
char *dest_pointer = NULL;
for (i = 0; i < height; i++)
dest_pointer = &dest_matrix[i];
for (j = 7; j >= 0; j--)
*dest_pointer = (src_matrix[j] & (0b1 << (7 - i)));
Here's an illustration of what is going on:
Let's say we have a 4x4 sprite that looks looks this in binary: (the code is written for char sprites)
The result should look like this:
The code is supposed to open the first char of the destination matrix (dest_matrix), and then proceed to open all of the source matrix (src_matrix) chars. It then should take the first bit of each of these chars and put those bits into the destination char in order. Then is should return the pointer to the modified matrix.
When I display the modified matrix, I only get two pixels that turn on. Do you have any ideas what I should do to get this to work right?
The problem I am having is that when I go to display the modified matrix, i