Yes, what you have is correct.
However, it might be more economical to have a function like this:
Code:
void move_block(const block *l, int x, int y) {
int i;
for(i = 0; i < 4; i ++) {
l->Bl[i ].x += x;
l->Bl[i ].y += y;
}
}
Then you can just call move_block(l, 0, 1) to move a block (0,1), or downwards, etc.
Or, if you can't wrap your head around 0, 1 meaning downwards, you could use some #defines or an enum to do the job for you -- perhaps something like this.
Code:
typedef enum {
DIR_UP,
DIR_LEFT,
DIR_RIGHT,
DIR_DOWN
} direction;
void get_dir_values(direction dir, int *x, int *y) {
switch(direction) {
case DIR_UP:
*x = -1, *y = 0;
break;
/* ... */
}
}
void move_block(const block *l, direction dir) {
int i, x, y;
get_dir_values(dir, &x, &y);
for(i = 0; i < 4; i ++) {
l->Bl[i ].x += x;
l->Bl[i ].y += y;
}
}
Then again, maybe that's just too much code.