int Pacman::update(char gameboard[][28]) { int new_x = getNextX(); int new_y = getNextY(); boolean move = true; switch(gameboard[new_y][new_x]) { case 'd': case 'u': case '0': break; case '9': wrap(); break; case 'a': case 'c': case 'f': case 's': //die(); // :( default: move = false; break; } if(move) { incrementX(); incrementY(); } return gameboard[int(y)][int(x)]; }
void ofxSimpleGuiPage::draw(float x, float y, bool alignRight) { setPosition(x += config->offset.x, y += config->offset.y); if(alignRight) x = ofGetWidth() - x - config->gridSize.x; float posX = 0; float posY = 0; float stealingX = 0; float stealingY = 0; ofSetRectMode(OF_RECTMODE_CORNER); for(int i=0; i<controls.size(); i++) { ofxSimpleGuiControl &control = *controls[i]; if(control.newColumn) { if(alignRight) posX -= config->gridSize.x; else posX += config->gridSize.x; posY = 0; } float controlX = posX + x; float controlY = posY + y; //we don't draw the event stealing controls until the end because they can expand and overlap with other controls (e.g. combo box) if(eventStealingControl == &control) { stealingX = controlX; stealingY = controlY; } else { // printf("drawing control: %s %s\n", control.controlType.c_str(), control.name.c_str()); control.draw(controlX, controlY); } if(control.hasTitle) { ofNoFill(); ofSetHexColor(config->borderColor); glLineWidth(0.5f); ofRect(controlX, controlY, control.width, control.height); } posY = getNextY(posY + control.height + config->padding.y); if(posY + y >= height - control.height - config->padding.y) { if(alignRight) posX -= config->gridSize.x; else posX += config->gridSize.x; posY = 0; } // if(guiFocus == controls[i]->guiID) controls[i]->focused = true; // MEMO // else controls[i]->focused = false; } //event stealing controls get drawn on top if(eventStealingControl) { eventStealingControl->draw(stealingX, stealingY); if(eventStealingControl->hasTitle) { ofNoFill(); ofSetHexColor(config->borderColor); glLineWidth(0.5f); ofRect(stealingX, stealingY, eventStealingControl->width, eventStealingControl->height); } } }
void TimgFilterSharpen::process(TffPict2 &pict,const TpresetSettings *cfg) { if ((cfg->sharpen.method==0 && !cfg->sharpen.xsharpStrength) || (cfg->sharpen.method==1 && !cfg->sharpen.unsharpStrength)) return; Trect *r=init(&pict.rect,cfg->fullSharpen); switch (cfg->sharpen.method) { case 0: if (config.cpu_flags&XVID_CPU_MMXEXT) { const unsigned char *srcY=getCurY(pict)+r->diffY;unsigned char *dstY=getNextY(pict)+r->diffY; xsharpen(srcY,dstY,cfg); } return; case 1: { const unsigned char *srcY=getCurY(pict)+r->diffY;unsigned char *dstY=getNextY(pict)+r->diffY; unsharpen(srcY,dstY,cfg); return; } } }
int enemy::Getinput(character *Player) { int PlayerX = Player->getNextX(); int PlayerY = Player->getNextY(); int EnemyX = getNextX(); int EnemyY = getNextY(); int DistX = PlayerX - EnemyX; int DistY = PlayerY - EnemyY; int Distance = int(sqrt(DistX*DistX + DistY*DistY)); // Distance between enemy and player if (TurnCount == LastTurn) { return rand() % 4 + 1;// If a move toward the player cannot be found, move randomly } // Check that the Character has moved } else { LastMove = -1; } if (Distance < 6 ) { if (DistX < 0 && LastMove !=3) // Left { LastMove = 3; LastTurn = TurnCount; return 3; } else if (DistX > 0 && LastMove != 4) // right { LastMove = 4; LastTurn = TurnCount; return 4; } else if (DistY < 0 && LastMove != 1) // Up { LastMove = 1; LastTurn = TurnCount; return 1; } else if (DistY > 0 && LastMove != 2) // Down { LastMove = 2; LastTurn = TurnCount; return 2; } } return rand() % 4 + 1; // If a move toward the player cannot be found, move randomly }
void TimgFilterTimesmooth::process(TffPict2 &pict,const TpresetSettings *cfg) { if (!cfg->blur.tempSmooth) return; Trect *r=init(&pict.rect,cfg->fullBlur); const unsigned char *srcY=getCurY(pict)+r->diffY ;unsigned char *dstY=getNextY(pict)+r->diffY ; const unsigned char *srcU=getCurU(pict)+r->diffUV;unsigned char *dstU=getNextU(pict)+r->diffUV; const unsigned char *srcV=getCurV(pict)+r->diffUV;unsigned char *dstV=getNextV(pict)+r->diffUV; if (cfg->blur.tempSmooth!=oldStrength) { oldStrength=cfg->blur.tempSmooth; for (int i=0;i<=510;i++) { int sqerr=((i-255)*(i-255))>>oldStrength; if (sqerr>16) sqerr=16; sqerr=16-sqerr; square_table[i]=sqerr; } }
void TimgFilterOffset::process(TffPict2 &pict,const TpresetSettings *cfg) { if (!cfg->offset.Y_X && !cfg->offset.Y_Y && !cfg->offset.U_X && !cfg->offset.U_Y && !cfg->offset.V_X && !cfg->offset.V_Y) return; Trect *r=init(&pict.rect,cfg->fullOffset); if (cfg->offset.Y_X || cfg->offset.Y_Y) { const unsigned char *srcY=getCurY(pict)+r->diffY;unsigned char *dstY=getNextY(pict)+r->diffY; offset(srcY,dstY,dxY,strideY,dyY,cfg->offset.Y_X,-cfg->offset.Y_Y,0); } if (cfg->offset.U_X || cfg->offset.U_Y) { const unsigned char *srcU=getCurU(pict)+r->diffUV;unsigned char *dstU=getNextU(pict)+r->diffUV; offset(srcU,dstU,dxUV,strideUV,dyUV,cfg->offset.U_X/2,-cfg->offset.U_Y/2,128); } if (cfg->offset.V_X || cfg->offset.V_Y) { const unsigned char *srcV=getCurV(pict)+r->diffUV;unsigned char *dstV=getNextV(pict)+r->diffUV; offset(srcV,dstV,dxUV,strideUV,dyUV,cfg->offset.V_X/2,-cfg->offset.V_Y/2,128); } }
void ofxSimpleGuiPage::draw(float x, float y, bool alignRight) { setPos(x += config->offset.x, y += config->offset.y); if(alignRight) x = ofGetWidth() - x - config->gridSize.x; float posX = 0; float posY = 0; ofSetRectMode(OF_RECTMODE_CORNER); for(int i=0; i<controls.size(); i++) { ofxSimpleGuiControl &control = *controls[i]; if(control.newColumn) { if(alignRight) posX -= config->gridSize.x; else posX += config->gridSize.x; posY = 0; } float controlX = posX + x; float controlY = posY + y; control.draw(controlX, controlY); if(control.hasTitle) { ofNoFill(); ofSetHexColor(config->borderColor); glLineWidth(0.5f); ofRect(controlX, controlY, control.width, control.height); } posY = getNextY(posY + control.height + config->padding.y); if(posY + y >= height - control.height - config->padding.y) { if(alignRight) posX -= config->gridSize.x; else posX += config->gridSize.x; posY = 0; } // if(guiFocus == controls[i]->guiID) controls[i]->focused = true; // MEMO // else controls[i]->focused = false; } }