Revision 186
sprite cannot go off screen
sprite.c | ||
---|---|---|
40 | 40 |
free(p); |
41 | 41 |
} |
42 | 42 |
|
43 |
void (sprite_set_pos) (sprite_t *p, int16_t x, int16_t y){ p->x = x; p->y = y; } |
|
43 |
void (sprite_set_pos) (sprite_t *p, int16_t x, int16_t y) { |
|
44 |
p->x = max(0, x); p->y = max(0, y); |
|
45 |
p->x = min(p->x, graph_get_XRes() - 1); p->y = min(p->y, graph_get_YRes() - 1); |
|
46 |
} |
|
44 | 47 |
void (sprite_set_angle) (sprite_t *p, double angle){ p->theta = angle; } |
45 | 48 |
void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0){ p->u0 = u0; p->v0 = v0; } |
46 | 49 |
|
Also available in: Unified diff