list<Controller::ActionType> Controller::getKeyList(){ list<Controller::ActionType> returnList; if (actionLeft()) { returnList.push_back(ActionType::Left); } else if (actionRight()) { returnList.push_back(ActionType::Right); } if (actionUp()) { returnList.push_back(ActionType::Up); } else if (actionDown()) { returnList.push_back(ActionType::Down); } if(actionSprint()){ returnList.push_back(ActionType::Sprint); } if(actionJump()){ returnList.push_back(ActionType::Jump); } if(actionAction()){ returnList.push_back(ActionType::Action); } return returnList; }
list<Controller::ActionType> Controller::getControllerList(){ list<Controller::ActionType> returnList; if(sf::Joystick::isConnected(0)){ if (actionLeft()) { returnList.push_back(ActionType::Left); } else if (actionRight()) { returnList.push_back(ActionType::Right); } if (actionUp()) { returnList.push_back(ActionType::Up); } else if (actionDown()) { returnList.push_back(ActionType::Down); } if(actionSprint()){ returnList.push_back(ActionType::Sprint); } if(actionJump()){ returnList.push_back(ActionType::Jump); } if(actionAction()){ returnList.push_back(ActionType::Action); } } return returnList; }
void DrawSceneGL(void) // 绘制场景 { calculateFPS(); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // 清除场景和深度缓存 glLoadIdentity(); // 重置当前矩阵 //glRasterPos2f(-640, -480); glPrint("FPS:%d", fps); //在此处添加代码进行绘制: // 设置视点 gluLookAt(0.0f, 32.0f, 53.0f, 0.0f, 27.0f, 0.0f, 0.0f, 1.0f, 0.0f); //camera.Look(); //camera.SetViewByMouse(); //旋转场景 glRotatef(angle_Y, 0.0f, 1.0f, 0.0f); // 绘制地面 /*glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, groundTex); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-20.0f, 0.0f, 20.0f); glTexCoord2f(4.0f, 0.0f); glVertex3f( 20.0f, 0.0f, 20.0f); glTexCoord2f(4.0f, 4.0f); glVertex3f( 20.0f, 0.0f,-20.0f); glTexCoord2f(0.0f, 4.0f); glVertex3f(-20.0f, 0.0f,-20.0f); glEnd();*/ //绘制场景 //background3DS.Render(); skybox.Render(); // 显示Tower或Gundam glEnable(GL_LIGHTING); //glMatrixMode (GL_MODELVIEW); /*glLoadIdentity ();*/ glScalef (0.3f,0.3f,0.3f);//Resize all unit below glTranslatef (0.0f, 50.0f, 0.0f);//Stage height glPushMatrix(); glTranslatef (0.0f, 20.0f, 0.0f);//Raise self height actionJump(¬eWholeY,&g_NoteWholeJump); glTranslatef (20.0f, noteWholeY, 48.0f); glScalef (0.6f,0.6f,0.6f); note_Whole3DS.Render(); glPopMatrix(); //Note2 glPushMatrix(); glScalef (0.7f,0.7f,0.7f); glTranslatef (0.0f, 15.0f, 0.0f);//Raise self height actionJump(¬eHalfY,&g_NoteHalfJump); glTranslatef (48.0f, noteHalfY, 20.0f); note_Half3DS.Render(); glPopMatrix(); //Note4 glPushMatrix(); //glScalef (2.0f,2.0f,2.0f); actionJump(¬eQuaterY,&g_NoteFourthJump); glTranslatef (48.0f, noteQuaterY, -20.0f); noteFourth3DS.Render(); glPopMatrix(); //Note8 glPushMatrix(); glScalef (1.7f,1.7f,1.7f); actionJump(¬eEighthY,&g_NoteEightJump); glTranslatef (20.0f, noteEighthY, -48.0f); note_Eighth3DS.Render(); glPopMatrix(); //note 16 glPushMatrix(); glScalef (1.8f,1.8f,1.8f); actionJump(¬eSixteenthY,&g_NoteSixteenthJump); glTranslatef (-20.0f, noteSixteenthY, -48.0f); note_Sixteenth3DS.Render(); glPopMatrix(); //Note 32 glPushMatrix(); glScalef (1.8f,1.8f,1.8f); actionJump(¬eThirtySecondY,&g_NoteThirtySecondJump); glTranslatef (-48.0f, noteThirtySecondY, -20.0f); note_ThirtySecond3DS.Render(); glPopMatrix(); //Note 8 * 2 glPushMatrix(); actionJump(¬eEighthDoubleY,&g_NoteEight2Jump); glTranslatef (-48.0f, noteEighthDoubleY, 20.0f); noteEighth23DS.Render(); glPopMatrix(); /*glPushMatrix(); glTranslatef (-40.0f, 0.0f, 40.0f); noteEighth3DS.Render(); glPopMatrix(); glPushMatrix(); glTranslatef (40.0f, 0.0f, 40.0f); noteEighth23DS.Render(); glPopMatrix(); glPushMatrix(); glTranslatef (-40.0f, 0.0f, -40.0f); noteFourth3DS.Render(); glPopMatrix();*/ /*if (showTower) { glDisable(GL_CULL_FACE); tower3DS.Render(); } else { glEnable(GL_CULL_FACE); gundam3DS.Render(); }*/ angle_Y += 0.4f; glFlush (); // 刷新GL命令队列 }
void Tegiac::changeState(artemis::Entity &e){ StateComponent* state = (StateComponent*)e.getComponent<StateComponent>(); PosComponent* position = (PosComponent*)e.getComponent<PosComponent>(); CharacterInfoComponent* characterInfo = (CharacterInfoComponent*)e.getComponent<CharacterInfoComponent>(); if (state->state == R::CharacterState::ATTACK){ AttackComponent* attackComponent = new AttackComponent(); attackComponent->whoAttack = ((CharacterTypeComponent*)e.getComponent<CharacterTypeComponent>())->type; attackComponent->type = state->attack; attackComponent->powerOfAttack = characterInfo->NORMAL_SKILL_POWER; if (state->attack == R::Attack::TEGIAC_BEAT3){ actionBeat3(e, state->direction); attackComponent->minX = position->x - 60; attackComponent->maxX = position->x + 60; attackComponent->minY = position->y - 100; attackComponent->maxY = position->y + 100; } else if (state->attack == R::Attack::TEGIAC_KICK2){ actionKick2(e, state->direction); attackComponent->minX = position->x - 60; attackComponent->maxX = position->x + 60; attackComponent->minY = position->y - 70; attackComponent->maxY = position->y + 70; } else if (state->attack == R::Attack::TEGIAC_KICK3){ actionKick3(e, state->direction); attackComponent->minX = position->x - 130; attackComponent->maxX = position->x + 130; attackComponent->minY = position->y - 100; attackComponent->maxY = position->y + 100; attackComponent->manaOfAttack = 40; } else if (state->attack == R::Attack::TEGIAC_PUNCH1){ actionPunch1(e, state->direction); attackComponent->minX = position->x - 60; attackComponent->maxX = position->x + 60; attackComponent->minY = position->y - 140; attackComponent->maxY = position->y + 140; } else if (state->attack == R::Attack::TEGIAC_PUNCH2){ actionPunch2(e, state->direction); attackComponent->minX = position->x - 60; attackComponent->maxX = position->x + 60; attackComponent->minY = position->y - 140; attackComponent->maxY = position->y + 140; } else if (state->attack == R::Attack::TEGIAC_PUNCH3){ actionPunch3(e, state->direction); attackComponent->minX = position->x - 80; attackComponent->maxX = position->x + 80; attackComponent->minY = position->y - 140; attackComponent->maxY = position->y + 140; attackComponent->powerOfAttack = characterInfo->SPECIAL_SKILL_POWER; attackComponent->isSpecialSkill = true; return; } else if (state->attack == R::Attack::TEGIAC_PUNCH_AIR){ actionPunchAir(e, state->direction); attackComponent->minX = position->x - 140; attackComponent->maxX = position->x + 140; attackComponent->minY = position->y - 140; attackComponent->maxY = position->y + 140; attackComponent->manaOfAttack = 40; attackComponent->powerOfAttack = characterInfo->SPECIAL_SKILL_POWER; attackComponent->isSpecialSkill = true; } if (R::Constants::soundEnable){ CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(R::Constants::soundVolumn); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(R::Constants::ENEMY_ATTACK, false, 1, 0, 1); } EntityUtils::getInstance()->createAttackEntity(e, attackComponent); } else if (state->state == R::CharacterState::DIE){ if (R::Constants::soundEnable){ CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(R::Constants::soundVolumn); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(R::Constants::ENEMY_DEATH, false, 1, 0, 1); } actionDie(e, state->direction); } else if (state->state == R::CharacterState::DEFENSE){ if (R::Constants::soundEnable){ CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(R::Constants::soundVolumn); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(R::Constants::ENEMY_HIT3,false,1,0,1); } if (state->defense == R::Defense::TRUNG_DON) actionTrungDon(e, state->direction); if (state->defense == R::Defense::TRUNG_DON_NGA) actionTrungDonNga(e, state->direction); } else if (state->state == R::CharacterState::START){ actionStart(e, state->direction); } else if (state->state == R::CharacterState::BACK){ actionBack(e, state->direction); } else if (state->state == R::CharacterState::STAND){ actionStand(e); } else if (state->state == R::CharacterState::STAND_UP){ actionStandUp(e); } else if (state->state == R::CharacterState::LEFT){ actionMove(e, R::Direction::LEFT); } else if (state->state == R::CharacterState::RIGHT){ actionMove(e, R::Direction::RIGHT); } else if (state->state == R::CharacterState::WALK_LEFT){ actionRun(e, R::Direction::LEFT); } else if (state->state == R::CharacterState::WALK_RIGHT){ actionRun(e, R::Direction::RIGHT); } else if (state->state == R::CharacterState::JUMP){ actionJump(e, R::Direction::AUTO); } }
void CaMap::changeState(artemis::Entity &e){ StateComponent* state = (StateComponent*)e.getComponent<StateComponent>(); PosComponent* position = (PosComponent*)e.getComponent<PosComponent>(); CharacterInfoComponent* characterInfo = (CharacterInfoComponent*)e.getComponent<CharacterInfoComponent>(); if (state->state == R::CharacterState::ATTACK){ AttackComponent* attackComponent = new AttackComponent(); attackComponent->whoAttack = ((CharacterTypeComponent*)e.getComponent<CharacterTypeComponent>())->type; attackComponent->type = state->attack; attackComponent->powerOfAttack = characterInfo->NORMAL_SKILL_POWER; if (state->attack == R::Attack::CAMAP_PUNCH_AIR){ actionPunchAir(e, state->direction); characterInfo->power -= 40; return; } else if (state->attack == R::Attack::CAMAP_SKILL){ actionSkill(e, state->direction); characterInfo->power -= 40; return; } else if (state->attack == R::Attack::CAMAP_PUNCH1){ actionPunch1(e, state->direction); return; } else if (state->attack == R::Attack::CAMAP_PUNCH2){ actionPunch2(e, state->direction); return; } else if (state->attack == R::Attack::CAMAP_PUNCH3){ actionPunch3(e, state->direction); return; } else if (state->attack == R::Attack::CAMAP_KICK2){ actionKick2(e, state->direction); return; } if (R::Constants::soundEnable){ CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(R::Constants::soundVolumn); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(R::Constants::ENEMY_ATTACK, false, 1, 0, 1); } EntityUtils::getInstance()->createAttackEntity(e, attackComponent); } else if (state->state == R::CharacterState::DIE){ actionDie(e, state->direction); if (R::Constants::soundEnable){ CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(R::Constants::soundVolumn); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(R::Constants::ENEMY_DEATH, false, 1, 0, 1); } } else if (state->state == R::CharacterState::DEFENSE){ if (R::Constants::soundEnable){ CocosDenshion::SimpleAudioEngine::getInstance()->setEffectsVolume(R::Constants::soundVolumn); CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(R::Constants::PUNCH, false, 1, 0, 1); } if (state->defense == R::Defense::TRUNG_DON) actionTrungDon(e, state->direction); if (state->defense == R::Defense::TRUNG_DON_NGA) actionTrungDonNga(e, state->direction); } else if (state->state == R::CharacterState::START){ actionStart(e, state->direction); } else if (state->state == R::CharacterState::BACK){ actionBack(e, state->direction); } else if (state->state == R::CharacterState::STAND){ actionStand(e); } else if (state->state == R::CharacterState::STAND_UP){ actionStandUp(e); } else if (state->state == R::CharacterState::LEFT){ actionMove(e, R::Direction::LEFT); } else if (state->state == R::CharacterState::RIGHT){ actionMove(e, R::Direction::RIGHT); } else if (state->state == R::CharacterState::WALK_LEFT){ actionMove(e, R::Direction::LEFT); } else if (state->state == R::CharacterState::WALK_RIGHT){ actionMove(e, R::Direction::RIGHT); } else if (state->state == R::CharacterState::JUMP){ actionJump(e, R::Direction::RIGHT); } }