kakeru hasebe / Mbed 2 deprecated dotmatlix_danmaku

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 DigitalOut K_ally[] = {
00003     DigitalOut(PB_3),
00004     DigitalOut(PA_0),
00005     DigitalOut(PA_5),
00006     DigitalOut(PA_9),
00007     DigitalOut(PA_6),
00008     DigitalOut(PA_10),
00009     DigitalOut(PA_12),
00010     DigitalOut(PA_3)
00011 };
00012 
00013 DigitalOut A_ally[] = {
00014     DigitalOut(PA_7),
00015     DigitalOut(PA_1),
00016     DigitalOut(PA_11),
00017     DigitalOut(PA_4),
00018     DigitalOut(PB_1),
00019     DigitalOut(PA_8),
00020     DigitalOut(PF_0),
00021     DigitalOut(PF_1)
00022 };
00023 
00024 DigitalIn up(PB_7,PullUp);
00025 DigitalIn left(PB_0,PullUp);
00026 DigitalIn down(PB_6,PullUp);
00027 DigitalIn right(PB_5,PullUp);
00028 DigitalIn dec(PA_2);
00029 Ticker ugoku;
00030 int X = 0;
00031 int Y = 7;
00032 int ene[15][2]= {
00033     {-1, -1},
00034     {-1, -1},
00035     {-1, -1},
00036     {-1, -1},
00037     {-1, -1},
00038     {-1, -1},
00039     {-1, -1},
00040     {-1, -1},
00041     {-1, -1},
00042     {-1, -1},
00043     {-1, -1},
00044     {-1, -1},
00045     {-1, -1},
00046     {-1, -1},
00047     {-1, -1},
00048 };
00049 
00050 
00051 void move()
00052 {
00053     if (~up == 1) {
00054         X = X - 1;
00055         if (X < 0) {
00056             X = 0;
00057         }
00058     }
00059     if (~down == 0) {
00060         X = X + 1;
00061         if (X > 7) {
00062             X = 8;
00063         }
00064     }
00065     if (~left == 1) {
00066         Y = Y - 1;
00067         if (Y < 0) {
00068             Y = 0;
00069         }
00070     }
00071     if (~right == 1) {
00072         Y = Y + 1;
00073         if (Y > 7) {
00074             Y = 8;
00075         }
00076     }
00077     /*   if (~dec == 1) {
00078            if (start == 1) {
00079                break;
00080            } else {
00081                break;
00082            }
00083        }
00084     X = X + 1;
00085     if(X>7)X-=8;*/
00086 }
00087 void draw_player()
00088 {
00089 
00090     for(int j = 0; j != 8; j++) {
00091         A_ally[j] = 0;
00092         //wait_us(1);
00093     }
00094     for(int i = 0; i != 8; i++) {
00095         K_ally[i] = 0;
00096         //wait_us(1);
00097     }
00098     A_ally[Y] = 1;
00099     K_ally[X] = 1;
00100     wait_ms(1);
00101     for(int k = 0; k != 8; k++) {
00102         A_ally[k] = 0;
00103         //wait_us(1);
00104     }
00105     for(int m = 0; m != 8; m++) {
00106         K_ally[m] = 0;
00107         //wait_us(1);
00108     }
00109 }
00110 
00111 
00112 /*int draw_enemy(){
00113     if (count == 1){
00114         A_enemy[4] = 1;
00115         K_enemy[8] = 1;
00116         wait_
00117         A_enemy[4] = 0;
00118         K_enemy[8] = 0;
00119     }
00120     if (count == 2){
00121         */
00122 
00123 
00124 int main()
00125 {
00126     ugoku.attach(&move,1);
00127     while(1) {
00128         draw_player();
00129         wait_us(1);
00130         /*for (int m = 0; m < 1; m++) {
00131             draw_enemy();
00132         }*/
00133 
00134     }
00135 }