void display() { glColor3f(1, 1, 1); glClear(GL_COLOR_BUFFER_BIT); // glTranslatef(2,0,0); if (flag == 0) { circle(r, cx, 250); if (int(cx) >= 100 && int(cx) <= 150) circle(30, 100, 250); if (int(cx) >= 200 && int(cx) <= 250) circle(30, 200, 250); if (int(cx) >= 300 && int(cx) <= 350) circle(30, 300, 250); if (int(cx) >= 400 && int(cx) <= 450) circle(30, 400, 250); } if (flag == 1) circle2(60, cx, 250); if (bloodflag == 1) { blood(yy1--); } glFlush(); cx += d; if (cx >= 700) { d = -d1; flag = 1; } if (cx <= 400 && flag == 1) { d = 0; } glutPostRedisplay(); }
bool PainEffect::tick() { // sf::Image capture = this->window->capture(); this->camera->setWPosition(this->camera->getWPosition() - this->camera->rShift); float normal = ((float) this->clock.getElapsedTime().asMilliseconds()) / this->duration; float result = pow((normal - 1) , 4); int ampFull = ((float) this->power) * result; int ampHalf = ampFull / 2; if (ampHalf > 0) { this->camera->rShift += sf::Vector2f( this->random(ampFull) - ampHalf, this->random(ampFull) - ampHalf ); sf::Color blood(128, 0, 0, result * 72); sf::RectangleShape filter(sf::Vector2f(this->engine->getWindow()->getSize())); filter.setFillColor(blood); this->window->draw(filter); return true; } else { this->camera->rShift = sf::Vector2f(0, 0); return false; } }
void MainDlg::OnLbnSelchangeUserList() { int curindex = _userList.GetCurSel(); if( curindex >= 0 ) { int userNo = (int)_userList.GetItemData( curindex ); UserList & userInfoList = Network::GetInstance().GetUserInfoList(); int index = Network::GetInstance().GetIndexForUserNo( userNo ); UserInfo & userInfo = userInfoList[ index ]; std::string picPath = "../Test/pic/" + userInfo._pic; CString age( userInfo._age.c_str() ); CString sex( userInfo._sex.c_str() ); CString tall( userInfo._tall.c_str() ); CString weight( userInfo._weight.c_str() ); CString blood( userInfo._blood.c_str() ); CString tel( userInfo._tel.c_str() ); CString pic( picPath.c_str() ); _userDataList.DeleteAllItems(); LV_ITEM lvItem; CString itemText; itemText = "나이"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 0; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)age; _userDataList.SetItem(&lvItem); itemText = "성별"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 1; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 1; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)sex; _userDataList.SetItem(&lvItem); itemText = "키"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 2; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 2; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)tall; _userDataList.SetItem(&lvItem); itemText = "몸무게"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 3; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 3; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)weight; _userDataList.SetItem(&lvItem); itemText = "혈액형"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 4; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 4; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)blood; _userDataList.SetItem(&lvItem); itemText = "전화"; lvItem.mask = LVIF_TEXT; lvItem.iItem = 5; lvItem.iSubItem = 0; lvItem.pszText = (LPTSTR)(LPCTSTR)itemText; _userDataList.InsertItem(&lvItem); lvItem.mask = LVIF_TEXT; lvItem.iItem = 5; lvItem.iSubItem = 1; lvItem.pszText = (LPTSTR)(LPCTSTR)tel; _userDataList.SetItem(&lvItem); HBITMAP hBmp = (HBITMAP)LoadImage(NULL, pic, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); _image.SetBitmap( hBmp ); // m_wndView->SetUserNo( userNo ); // OnCbnSelchangeComboHour(); } }
int main() { int i,ic; //variables for incrementing in for loops int lives=5, level=1; //initialize lives and level int fgx=12, fgy=11, *frogx=&fgx, *frogy=&fgy; //initialize frog position int row=12,col=25,board[row][col]; //dimensions for board char play; //declare play character int x[19]= {5-width/4,width+5,10-width/4,15-width/4,width+10,5-width/2,1.2*width,10-width/2,15-width/2,1.2*width,5-width,1.5*width,10-width,15-width,1.5*width,width+5,5-width,width+10,10-width/2}; //array of starting positions of moving objects //initialize board for(i=0; i<6; i++) for(ic=0; ic<col; ic++) board[i][ic]=0; for(i=6; i<row; i++) for(ic=0; ic<col; ic++) board[i][ic]=1; for(i=2; i<col; i+=4) board[0][i]=2; gfx_open(width,height,"Frogger"); //open graphics window play=welcome(); //begin game while(play!='q') { //while user wants to play the game and not quit background(level); draw_lives(lives); draw(col,board,level,x,frogx,frogy); drawfrog(*frogx,*frogy,play); gfx_flush(); usleep(100000); /* for(i=0;i<row;i++){ //prints board in terminal for(ic=0;ic<col;ic++) printf("%d",board[i][ic]); printf("\n"); } //end for(i=0;i<row;i++) printf("\n"); */ if (gfx_event_waiting()) { //if user tries to move frog play = hopper(frogx,frogy,row,col); //move frog according to input if valid } //end if (gfx_event_waiting()) switch(board[*frogy][*frogx]) { case 0: //frog dies in this location lives--; //lose a life *frogx=12; *frogy=11; if(lives==0) { play=blood(); //game over, play again or end lives=5; level=1; } //end if(lives==0) break; case 1: //frog can be in this location and game continues break; case 2: //frog made it to lilly pad level++; //level up *frogx=12; *frogy=11; if (level>5) { play=win();//you won! level = 1; lives = 5; } //end if (level>5) break; } //end switch(board[*frogx][*frogy]) } //end while(play!='q') } //end main
Boss::Boss(Player* player) : DE::GameObject() , m_fHP(1000.0f) , m_fJumpingTime(0.0f) , m_pPlayer(player) , m_bHitPlayer(false) { DE::Handle hMeshComponent(sizeof(DE::MeshComponent)); new (hMeshComponent) DE::MeshComponent("mutant", DE::eMeshType::SKELETAL_MESH); AddComponent((DE::Component*) hMeshComponent.Raw()); DE::Handle hAABB(sizeof(DE::AABB)); // hard code bounding box for the boss body new (hAABB) DE::AABB(DE::Vector3(-0.4f, -0.2f, -0.4f), DE::Vector3(0.6f, 1.8f, 0.6f)); AddComponent((DE::Component*) hAABB.Raw()); DE::Handle hAI(sizeof(AIBehavior)); new (hAI) AIBehavior(); AddComponent((DE::Component*) hAI.Raw()); DE::Handle hSkel(sizeof(DE::Skeleton)); new (hSkel) DE::Skeleton("mutant"); AddComponent((DE::Component*) hSkel.Raw()); DE::Handle hAnimController(sizeof(DE::AnimationController)); new (hAnimController) DE::AnimationController((DE::Skeleton*) hSkel.Raw()); AddComponent((DE::Component*) hAnimController.Raw()); ((DE::AnimationController*) hAnimController.Raw())->CreateAnimationSets("mutant_walking"); ((DE::AnimationController*) hAnimController.Raw())->CreateAnimationSets("mutant_idle"); ((DE::AnimationController*) hAnimController.Raw())->CreateAnimationSets("mutant_jump_attack"); ((DE::AnimationController*) hAnimController.Raw())->CreateAnimationSets("mutant_punch"); ((DE::AnimationController*) hAnimController.Raw())->CreateAnimationSets("mutant_dying"); ((DE::AnimationController*) hAnimController.Raw())->CreateAnimationSets("mutant_roaring"); ((DE::AnimationController*) hAnimController.Raw())->CreateAnimationSets("mutant_swiping"); ((DE::AnimationController*) hAnimController.Raw())->getAnimationSet("walk")->SetLooping(true); ((DE::AnimationController*) hAnimController.Raw())->getAnimationSet("idle")->SetLooping(true); ((DE::AnimationController*) hAnimController.Raw())->getAnimationSet("idle")->setActive(true); DE::Handle hASM(sizeof(BossASM)); new (hASM) BossASM((DE::AnimationController*) hAnimController.Raw()); AddComponent((DE::Component*) hASM.Raw()); ((DE::AnimationController*) hAnimController.Raw())->SetAnimationStateMachine((BossASM*)hASM.Raw()); // Small surrounding light DE::Handle hPointLight(sizeof(DE::PointLightComponent)); new (hPointLight) DE::PointLightComponent(DE::Vector3(0.0f, 6.0f, 0.0f), DE::Vector4(1.0, 1.0, 1.0), 6, 4); AddComponent((DE::Component*) hPointLight.Raw()); // Left hand m_pLeftHand = new DE::GameObject(); DE::Handle hLeftHandAABB(sizeof(DE::AABB)); //new (hLeftHandAABB) DE::AABB(DE::Vector3(0, 0.4, 0.6), DE::Vector3(0.1, 0.7, 0.9)); new (hLeftHandAABB) DE::AABB(DE::Vector3(-0.1, -0.1, -0.1), DE::Vector3(0.2, 0.2, 0.1)); m_pLeftHand->AddComponent((DE::Component*) hLeftHandAABB.Raw()); DE::Handle hLeftHandEmitter(sizeof(DE::Emitter)); new (hLeftHandEmitter) DE::Emitter("lefthand", DE::Emitter::YELLOW_LIGHT, 1.0f, DE::Vector3(0.0f, 0.0f, 0.0f), DE::Vector3(0.0f, 1.0f, 0.0f)); m_pLeftHand->AddComponent((DE::Component*) hLeftHandEmitter.Raw()); m_pLeftHand->GetComponent<DE::Emitter>()->SetRandomRange(-2.5f, 2.5f); m_pLeftHand->GetComponent<DE::Transform>()->AttachToJoint(GetComponent<DE::Skeleton>(), 10); m_pLeftHand->GetComponent<DE::Transform>()->AttachTo(m_pTransform); // Right hand m_pRightHand = new DE::GameObject(); DE::Handle hRightHandAABB(sizeof(DE::AABB)); new (hRightHandAABB) DE::AABB(DE::Vector3(-0.1, -0.1, -0.1), DE::Vector3(0.2, 0.2, 0.1)); m_pRightHand->AddComponent((DE::Component*) hRightHandAABB.Raw()); DE::Handle hRightHandEmitter(sizeof(DE::Emitter)); new (hRightHandEmitter) DE::Emitter("righthand", DE::Emitter::YELLOW_LIGHT, 1.0f, DE::Vector3(0.0f, 0.0f, 0.0f), DE::Vector3(0.0f, 1.1f, 0.0f)); m_pRightHand->AddComponent((DE::Component*) hRightHandEmitter.Raw()); m_pRightHand->GetComponent<DE::Emitter>()->SetRandomRange(-2.5f, 2.5f); m_pRightHand->GetComponent<DE::Transform>()->AttachToJoint(GetComponent<DE::Skeleton>(), 31); m_pRightHand->GetComponent<DE::Transform>()->AttachTo(m_pTransform); // blood effect m_pBlood = new DE::GameObject(); DE::Handle blood(sizeof(DE::Emitter)); new (blood) DE::Emitter("boss", DE::Emitter::BLEEDING, 6.0f, DE::Vector3(0.0f, 0.3f, 0.0f), DE::Vector3(0.0f, 0.0f, -0.5f)); m_pBlood->AddComponent((DE::Component*) blood.Raw()); m_pBlood->GetComponent<DE::Emitter>()->SetRandomRange(-2.5f, 2.5f); m_pBlood->GetComponent<DE::Transform>()->AttachToJoint(GetComponent<DE::Skeleton>(), 2); m_pBlood->GetComponent<DE::Transform>()->AttachTo(m_pTransform); // blue eye m_pBlueEye = new DE::GameObject(); DE::Handle hLeftEye(sizeof(DE::Emitter)); new (hLeftEye) DE::Emitter("lefteye", DE::Emitter::BLUE_LIGHT, 0.4f, DE::Vector3(-0.04f, 0.078f, 0.089f), DE::Vector3(0.0f, 0.05f, 0.0f)); m_pBlueEye->AddComponent((DE::Component*) hLeftEye.Raw()); m_pBlueEye->GetComponent<DE::Transform>()->AttachToJoint(GetComponent<DE::Skeleton>(), 5); m_pBlueEye->GetComponent<DE::Transform>()->AttachTo(m_pTransform); DE::Handle hRightEye(sizeof(DE::Emitter)); new (hRightEye) DE::Emitter("righteye", DE::Emitter::BLUE_LIGHT, 0.4f, DE::Vector3(0.04f, 0.078f, 0.089f), DE::Vector3(0.0f, 0.05f, 0.0f)); m_pBlueEye->AddComponent((DE::Component*) hRightEye.Raw()); m_pBlueEye->GetComponent<DE::Transform>()->AttachToJoint(GetComponent<DE::Skeleton>(), 5); m_pBlueEye->GetComponent<DE::Transform>()->AttachTo(m_pTransform); }