Revision 141
fixed speed problem
lab5/lab5.c | ||
---|---|---|
441 | 441 |
/// |
442 | 442 |
int16_t v = (speed <= 0 ? 1 : speed); |
443 | 443 |
int16_t vx = 0, vy = 0; |
444 |
if(xi != xf) vx = v;
|
|
445 |
else vy = v;
|
|
444 |
if(xi != xf) vx = (xi < xf ? v : -v);
|
|
445 |
else vy = (yi < yf ? v : -v);
|
|
446 | 446 |
|
447 | 447 |
uint16_t Nt = (speed < 0 ? -speed : 1); |
448 | 448 |
uint32_t ticks_per_frame = frequency/(uint32_t)fr_rate; |
... | ... | |
452 | 452 |
message msg; |
453 | 453 |
/// cycle |
454 | 454 |
uint16_t x = xi, y = yi; |
455 |
|
|
455 | 456 |
sprite_set_pos(sp,x,y); |
456 | 457 |
clear_screen(); |
457 |
sprite_draw(sp); printf("\nnew frame %d %d", x, y); |
|
458 |
sprite_draw(sp); |
|
459 |
|
|
458 | 460 |
int good = 1; |
459 | 461 |
while (good) { |
460 | 462 |
/* Get a request message. */ |
... | ... | |
478 | 480 |
y += vy; |
479 | 481 |
sprite_set_pos(sp,x,y); |
480 | 482 |
clear_screen(); |
481 |
sprite_draw(sp); printf("\nnew frame %d %d", x, y);
|
|
483 |
sprite_draw(sp); |
|
482 | 484 |
|
483 |
|
|
484 | 485 |
no_interrupts = 0; |
485 | 486 |
} |
486 | 487 |
} |
Also available in: Unified diff