Code:
#include<stdio.h>
#include<stdlib.h>
#define blockSize 16
#define blockSide 4
int bType[28] = {6,10,14,15,10,11,14,15,7,11,14,15,10,13,14,15,9,10,14,15,10,11,13,14,3,7,11,15};
int main() {
int *tBlock,type = 0,i;
tBlock = (int*) calloc(blockSize,sizeof(int));
for(i=0;i<blockSize;++i) tBlock[i] = 0;
for(i=(blockSide*type);i<blockSide*(type+1);++i) tBlock[bType[i]] = type;
for(i=0;i<blockSize;++i) printf("%d ",tBlock[i]);
free(tBlock);
return 0;
}
This code is a piece of a tetris game and it should set for each type of block, the corresponding value at the right index.
Th problem comes when I set type = 0, then the output will be all zeros.
This is very strange because the other numbers from 1 to 6 will give the right values.
Why is this happening? I can't seem to find any error...