void BlockOps::setUseTarget (bool use) { useTarget = use; if (!useTarget) clearTarget (); }
void UnitTargeting::clearTargetUsingCounter() { targetLoseCounter++; //if (targetLoseCounter >= UNITTARGETING_TARGET_LOSE_MAX_COUNT) if (targetLoseCounter >= targetLoseTime) { clearTarget(); } }
//thread void *inputHandler(void *vargp) { initTermios(); char cc; pthread_t tid2; pthread_create(&tid2, NULL, drawGun, NULL); drawTarget(getTargetPosX(TP),getTargetPosY(TP),50,220,10); while(stop == 0) { drawTarget(getTargetPosX(TP),getTargetPosY(TP),50,220,10); usleep(1000); if (kbhit()) { cc = getch();resetTermios(); switch (cc) { case 'w': case 'W' : clearTarget(getTargetPosX(TP),getTargetPosY(TP)); moveTarget(&TP,0,-15); break; case 'a': case 'A' : clearTarget(getTargetPosX(TP),getTargetPosY(TP)); moveTarget(&TP,-15,0); break; case 's': case 'S' : clearTarget(getTargetPosX(TP),getTargetPosY(TP)); moveTarget(&TP,0,15); break; case 'd': case 'D' : clearTarget(getTargetPosX(TP),getTargetPosY(TP)); moveTarget(&TP,15,0); break; case 'q' : case 'Q' : stop = 1; break; case 'i' : case 'I' : if(! isActive(B)) { makeBomb(getTargetPosX(TP),getTargetPosY(TP),&B); setActive(&B,1); } } initTermios(); } } pthread_join(tid2, NULL); }
// The target is the set of blocks which the currently falling block // will occupy when it lands. It is an aid for beginners. void BlockOps::generateTarget () { if (!useTarget) return; clearTarget (); // FIXME: Check that this is actually guaranteed // to terminate (i.e. posx, posy, blocknr and rot // are guaranteed to be valid). int n = 0; do { n++; } while (blockOkHere (posx, posy + n, blocknr, rot)); n--; // Mark the relevant places. putBlockInField (posx, posy + n, blocknr, rot, TARGET); }
void MemoryCompressor::clear() { clearMemory(); clearTarget(); }
task main() { //Declare variables int targetImage[8][8] = {{1, 1, 1, 0, 0, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 0, 1, 1, 1}}; int hitImage[8][8] = {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 1, 1, 1, 0, 0}, {0, 1, 1, 1, 1, 1, 1, 0}, {0, 1, 1, 1, 1, 1, 1, 0}, {0, 1, 1, 1, 1, 1, 1, 0}, {0, 1, 1, 1, 1, 1, 1, 0}, {0, 0, 1, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; int splashImage[8][8] = {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 1, 1, 1, 0, 0}, {0, 1, 0, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 1, 0}, {0, 0, 1, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; int mainGrid[8][8] = {{0, 1, 1, 1, 1, 1, 0, 0}, //[0][0-8] {0, 0, 0, 0, 0, 0, 0, 0}, //[1][0-7] {0, 1, 0, 0, 0, 0, 0, 0}, //[2][0-7] {0, 1, 0, 0, 0, 1, 1, 1}, //[3][0-7] {1, 0, 0, 0, 0, 0, 0, 0}, //[4][0-7] {1, 0, 0, 0, 0, 0, 0, 0}, //[5][0-7] {1, 0, 1, 1, 1, 0, 0, 0}, //[6][0-7] {1, 0, 0, 0, 0, 0, 0, 0}}; //[7][0-7] int colourValue; int x=10; int y=10; int xMove=0; int yMove=0; int xShip=0; int yShip=7-yMove; int hits=0; //Setup colour sensor SensorType[S3] = sensorEV3_Color;//set TYPE SensorMode[S3] = modeEV3Color_Color;//set MODE while(hits<17) /* ************************************************************* Red - 5 - SHOOT Blue - 2 - LEFT Yellow - 4 - RIGHT Green - 3 - DOWN ************************************************************* */ { //Erase target image clearTarget(targetImage,x,y); sleep(500); //Check colour colourValue=getColorName(S3); sleep(50); if (colourValue==2) { if(xMove>0) { xMove--; } else if(xMove==0) { xMove=7; } } if (colourValue==4) { if(xMove<7) { xMove++; } else if(xMove==7) { xMove=0; } } if (colourValue==3) { if(yMove>0) { yMove--; } else if(yMove==0) { yMove=7; } } x=xMove*8+10; y=yMove*8+10; if (colourValue==5) { //Calculate Main Grid Location xShip=xMove; yShip=7-yMove; //Play torpedo drop sound torpedoSound(); if (mainGrid[yShip][xShip]==1) { //Play hit sound kabloom(); //Draw hit image kabloomDraw(hitImage,x,y); //Increment hits hits++; //Remove ship mainGrid[yShip][xShip]=0; } else { //Play splash sound sploosh(); //Draw splash image splooshDraw(splashImage,x,y); } } //Draw target image drawTarget(targetImage,x,y); //Sleep for a small amount of time sleep(500); } displayBigTextLine(2, "Winner!"); sleep(5000); }