Page 42 - PIC18F4550微處理機C語言設計實務
P. 42
PIC18F4550 ฆஈଣዚ C ႧԊணࠇྼਕ
܁ѓΐᑘʘܝd̙˸̴͜Ը܁ѓΐᑘᜊᅰdא٫ਗ਼ᜊᅰΤ၈ٜટ׳ίΐᑘɽܼ
ܝࠦ܁ѓfԷνj
enum Direction Direction1;
א
enum Direction {
Up,
Down = 3,
Left = 4,
Right,
}Direction1;
߰ӚϞՉ˼ᜊᅰࠅԴ͜Νᅵٙΐᑘۨ࿒dɰ̙˸ଫΐᑘۨ࿒ٙΤ၈ٜટ܁ѓΐ
ᑘٙᜊᅰfԷνj
enum {
Up,
Down = 3,
Left = 4,
Right,
}Direction1;
ʘܝࠅᛘᄳ༈ΐᑘᜊᅰdۆٜટԴ͜ΐᑘʫʩ९ٙΤ၈dϾʔΎԴ͜Չᅰ࠽fԷνj
Direction1 = Up;
Direction1 = Left;
אٜટкᓙdԷνj
switch(Direction1){
case Up:
y++;
break;
case Down:
y--;
break;
case Left:
x--;
break;
case Right:
x++;
break;
}
32