示例#1
0
void movetank(int direction) {
    int zq;
    
    if (!shields[tank]) {
        printat(24,3,"\x7");
        printat(24,3,"That Tank is dead - immobile!           ");
        return;
    }
    
    erasetank(tank);
    
    zq=badmove(direction);  /* 0 = Normal, 1 =  RIP, 2 = New Map   */
    
    if (zq == 1) {
        shields[tank]=0;
        printat(24,3,"Tank has hit map edge and exploded!");
        printat(24,3,"\x7");
        convert(tanky[tank],tankx[tank],tankm[tank]);
        if ((bigmap[realy][realx] !='B') && (bigmap[realy][realx] != 'D')) {
            bigmap[realy][realx] = 'X';
            if(tankm[tank] == map) {
                move(tankx[tank]+39,tanky[tank]+1);
                wprintw(stdscr,"X");
            }
        }
        views();
        return;
    }
    
    if(zq == 2) {
        convert(tanky[tank],tankx[tank],tankm[tank]);
        twas[tank]=bigmap[realy] [realx];
        if((twas[tank] !='B') && (twas[tank] !='D'))
            bigmap[realy] [realx] = 48+tank;
        views();
        return;
    }
    
    switch(direction) {
        case UP:
            tanky[tank] -= 1;
            break;
            
        case DOWN:
            tanky[tank] +=1;
            break;
            
        case LEFT:
            tankx[tank] -=1;
            break;
        case RIGHT:
            tankx[tank] +=1;
            break;
    }
    
    update(tank);
    views();
    return;
}
示例#2
0
void drawscr(void) {
    boxit(1,39,22,80);
    boxit(16,4,22,10);
    boxit(16,16,22,22);
    boxit(16,28,22,34);
    boxit(1,1,15,38);
    boxit(23,2,25,79);
    printat(1,53,"[ Main Map ]");
    printat(22,54,"[ Map # 1 ]");
    printat(1,6,"[ Comm-Bat Command Listing ]");
    printat(23,34,"[ Messages ]");
    printat(16,5,"[ D ]");
    printat(16,17,"[ B ]");
    printat(16,29,"[ T ]");
}
示例#3
0
/*! This is the sensor process, it takes a simulated input ( a keyboard press )
    and passes it to the Light control process via IPC
 */
void
main(int argc, char* argv[]) {
    long send_port;

    if (ALL_OK != createprocess(1)) {
        printat(MAIN_DEBUG_LINE, 0, 
		"Sensor control: createprocess of Light control failed.\n");
        return;
    }

    // Locating the send port of the light control process
    send_port = findport(0, 1);
    if (send_port < 0) {
        printat(MAIN_DEBUG_LINE, 0, 
		"Sensor control: findport() failed (Light control) ");
        return;
    }

    printat(0, 0, "Welcome to VRTTCS (very realtime traffic control system)");
    printat(MAIN_DEBUG_LINE, 0, "Sensor control: ");

    while (1) {
        register long scan_code = getscancode();
        if (0x1c == scan_code) {
            struct message msg;
            printat(MAIN_DEBUG_LINE, 0, "Sensor control: Got sensor input");
            if (ALL_OK != send(send_port, &msg)) {
                printat(MAIN_DEBUG_LINE, 0, 
			"Sensor control: send() failed");
                return;
            } else {
                /* We let the debug message display some time*/
                pause(500);
                printat(MAIN_DEBUG_LINE, 0, "Sensor control:                                 ");
            }
        }
    }
}