bool CBouncingBall::UpdatePhysics(float dt) { if (m_isActive == false) return false; bool bounce = false; m_position += m_velocity * dt + (m_acceleration * dt * dt) * 0.5; m_velocity += m_acceleration * dt; float yPlane = 0.0f; if(CollisionDetection(yPlane)) { CollisionResponse(); bounce = true; } return bounce; }
void Game::SimulationLoop(float delta) { m_dt = delta; // Update rope's representation updateRopeVisuals(); // Mark inactive objects putInactiveAtRest(); //----------------------------------------------- // Integrate velocities CalculateObjectPhysics(); // Static and dynamic collision detection CollisionDetection(m_dt); // Resolve collisions for (int i=0; i<5; i++) { DynamicCollisionResponse(m_dt); } // Clear manifold m_manifold->Assess(); // Apply impulse if (!mAppliedAirJet) ApplyImpulse(); // Update rope physics m_rope.simulate(delta); // Integrate position UpdateObjectPhysics(delta); //----------------------------------------------- }
/** * Enalassei ta frames twn sprites kai ta typwnei * currTime :O xronos tou paixnidiou * scrolled :True an egine scroll ,false alliws * xOff :To xOff tou window * mario_running:True an o mario trexei,false alliws */ animatorToStart FrameRangeAnimator::Progress(timestamp_t currTime, bool scrolled, int xOff, bool mario_running, bool gamePaused, Sprite* mario_sprite) { int oldFrameNo = sprite->GetFrame(); animatorToStart who; who.pair.first = other_t; Point s; s.x = 0; s.y = 0; who.pair.second = s; if (state == ANIMATOR_RUNNING){ if (sprite->getPosX() < -33){ state = ANIMATOR_FINISHED; sprite->resetOldxOff(); } if (!gamePaused) { if ((sprite->getType() != gm_t)){ if (sprite->getRepet() == false){ if (sprite->getType() == star_t){ if (shroom_progressed < sprite->GetAnimFilm()->GetFrameBox(0).w){ sprite->alterPosY(-1); shroom_progressed++; } else{ anim->SetDy(0); } } if (sprite->getType() == coin_animator_t){ if (shroom_progressed < 20){ sprite->alterPosY(-1); shroom_progressed++; Point p; p.x = sprite->getPosX(); p.y = sprite->getPosY(); sprite->GetAnimFilm()->DisplayFrame(p, sprite->GetFrame()); sprite->alterPosY(-1); p.x = sprite->getPosX(); p.y = sprite->getPosY(); sprite->GetAnimFilm()->DisplayFrame(p, sprite->GetFrame()); sprite->alterPosY(-1); p.x = sprite->getPosX(); p.y = sprite->getPosY(); sprite->GetAnimFilm()->DisplayFrame(p, sprite->GetFrame()); } else{ shroom_progressed = 0; state = ANIMATOR_FINISHED; sprite->resetOldxOff(); } } if (state != ANIMATOR_FINISHED){ Point r = sprite->Move(anim->GetDx(), anim->GetDy(), sprite->GetFrame(), oldFrameNo, scrolled, xOff, mario_running, anim); anim->SetDx(r.x); anim->SetDy(r.y); sprite->setRepet(true); CollisionDetection(mario_sprite, sprite, currTime, &who); } } else sprite->setRepet(false); if ((sprite->getType() != gkt_t) || ((sprite->getType() == gkt_t) && (sprite->getRepetitions() == 2))){ if (currTime > lastTime && currTime - lastTime >= anim->GetDelay()) { if (anim->getEndFrameNo() > anim->getStartFrameNo()){ if (sprite->GetFrame() < anim->getEndFrameNo()){ sprite->SetFrame(sprite->GetFrame() + 1); } else{ sprite->SetFrame(anim->getStartFrameNo()); } } else{ if (sprite->GetFrame() > anim->getEndFrameNo()){ sprite->SetFrame(sprite->GetFrame() - 1); } else{ sprite->SetFrame(anim->getStartFrameNo()); } } if (!anim->GetContinuous()) { state = ANIMATOR_FINISHED; NotifyStopped(); } else { lastTime += anim->GetDelay(); } } } if ((sprite->getType() == gkt_t) && (sprite->getRepetitions() == 1)){ if (currTime - sprite->getTimeToAwake() > 7){ sprite->SetFrame(3); anim->SetDx(1); anim->switchEnds(); sprite->setRepet((short int)2); } } if ((sprite->getType() == gkt_t) && (sprite->getRepetitions() == 0)){ Point p,r; for (int i = 0; i < 2; i++){ p.x = sprite->getPosX(); p.y = sprite->getPosY(); r=sprite->Move(anim->GetDx(), anim->GetDy(), sprite->GetFrame(), oldFrameNo, scrolled, xOff, mario_running, anim); anim->SetDx(r.x); anim->SetDy(r.y); sprite->GetAnimFilm()->DisplayFrame(p, sprite->GetFrame()); } } } else if(sprite->getType()==gm_t){/*Shroom case*/ if ((anim->GetDx()==0)&&(currTime - lastTime >= 0.5)){ if (shroom_progressed < sprite->GetAnimFilm()->GetFrameBox(0).w){ sprite->Move(anim->GetDx(), anim->GetDy(), sprite->GetFrame(), oldFrameNo, scrolled, xOff, mario_running, anim); sprite->alterPosY(-1); shroom_progressed++; } else{ shroom_progressed = 0; anim->SetDx(1); anim->SetDy(0); } } if (anim->GetDx() != 0){ if (sprite->getRepet() == false){ Point r = sprite->Move(anim->GetDx(), anim->GetDy(), sprite->GetFrame(), oldFrameNo, scrolled, xOff, mario_running, anim); anim->SetDx(r.x); anim->SetDy(r.y); sprite->setRepet(true); CollisionDetection(mario_sprite, sprite, currTime, &who); } else sprite->setRepet(false); } }/*End of shroom case*/ Point p; p.x = sprite->getPosX(); p.y = sprite->getPosY(); sprite->GetAnimFilm()->DisplayFrame(p, sprite->GetFrame()); } } if (state == ANIMATOR_STOPPED){ if(currTime - lastTime <= 2){ Point p = sprite->Move(0, 0, sprite->GetFrame(), oldFrameNo, scrolled, xOff, mario_running, anim); p.x = sprite->getPosX(); p.y = sprite->getPosY(); sprite->GetAnimFilm()->DisplayFrame(p, sprite->GetFrame()); } else{ sprite->SetFrame(0); state = ANIMATOR_FINISHED; } } return who; }
void DockingProbe::TimeStep(double simt, double simdt) { if (!FirstTimeStepDone) { DoFirstTimeStep(); FirstTimeStepDone = true; return; } if (UndockNextTimestep) { UpdatePort(Dockparam[1] * 0.5, simdt); OurVessel->Undock(ourPort); UndockNextTimestep = false; } if (ExtendingRetracting > 0) { if (Status >= DOCKINGPROBE_STATUS_EXTENDED) { Status = DOCKINGPROBE_STATUS_EXTENDED; ExtendingRetracting = 0; Dockproc = DOCKINGPROBE_PROC_UNDOCKED; OurVessel->Undocking(ourPort); OurVessel->SetDockingProbeMesh(); } else { Status += 0.33 * simdt; } } else if (ExtendingRetracting < 0) { if (Status <= DOCKINGPROBE_STATUS_RETRACTED) { Status = DOCKINGPROBE_STATUS_RETRACTED; ExtendingRetracting = 0; OurVessel->HaveHardDocked(ourPort); OurVessel->SetDockingProbeMesh(); } else { Status -= 0.33 * simdt; } } if (Dockproc == DOCKINGPROBE_PROC_SOFTDOCKED) { UpdatePort(Dockparam[1] * 0.5, simdt); Dockproc = DOCKINGPROBE_PROC_HARDDOCKED; } else if (Dockproc == DOCKINGPROBE_PROC_HARDDOCKED) { if (Status > DOCKINGPROBE_STATUS_RETRACTED) { UpdatePort(Dockparam[1] * 0.5 * Status / 0.9, simdt); } else { UpdatePort(_V(0,0,0), simdt); Dockproc = DOCKINGPROBE_PROC_UNDOCKED; } } // sprintf(oapiDebugString(), "Docked %d Status %.3f Dockproc %d ExtendingRetracting %d", (Docked ? 1 : 0), Status, Dockproc, ExtendingRetracting); // Switching logic if (OurVessel->DockingProbeExtdRelSwitch.IsUp() && IsPowered()) { Extend(); } else if (OurVessel->DockingProbeExtdRelSwitch.IsDown()) { if ((!OurVessel->DockingProbeRetractPrimSwitch.IsCenter() && OurVessel->DockProbeMnACircuitBraker.IsPowered() && OurVessel->PyroBusA.Voltage() > SP_MIN_DCVOLTAGE) || (!OurVessel->DockingProbeRetractSecSwitch.IsCenter() && OurVessel->DockProbeMnBCircuitBraker.IsPowered() && OurVessel->PyroBusB.Voltage() > SP_MIN_DCVOLTAGE)) { int ActiveCharges = 0; if (OurVessel->DockingProbeRetractPrimSwitch.IsUp()) ActiveCharges = ActiveCharges | DOCKINGPROBE_CHARGE_PRIM1; if (OurVessel->DockingProbeRetractPrimSwitch.IsDown()) ActiveCharges = ActiveCharges | DOCKINGPROBE_CHARGE_PRIM2; if (OurVessel->DockingProbeRetractSecSwitch.IsUp()) ActiveCharges = ActiveCharges | DOCKINGPROBE_CHARGE_SEC1; if (OurVessel->DockingProbeRetractSecSwitch.IsDown()) ActiveCharges = ActiveCharges | DOCKINGPROBE_CHARGE_SEC2; if ((ActiveCharges & RetractChargesUsed)!= ActiveCharges) Retract(); RetractChargesUsed = RetractChargesUsed | ActiveCharges; // sprintf(oapiDebugString(), "Charge Used: P1%d P2%d S1%d S2%d", RetractChargesUsed & DOCKINGPROBE_CHARGE_PRIM1 , RetractChargesUsed & DOCKINGPROBE_CHARGE_PRIM2 , RetractChargesUsed & DOCKINGPROBE_CHARGE_SEC1 , RetractChargesUsed & DOCKINGPROBE_CHARGE_SEC2); } } /// /// Begin Advanced Docking Code /// if (DockingMethod > ADVANCED){ // Code that follows is largely lifted from Atlantis... // Goal is to handle close proximity docking between a probe and drogue VECTOR3 gdrgPos, gdrgDir, gprbPos, gprbDir, gvslPos, rvel, pos, dir, rot; OurVessel->Local2Global (Dockparam[0],gprbPos); //converts probe location to global OurVessel->GlobalRot (Dockparam[1],gprbDir); //rotates probe direction to global // Search the complete vessel list for a grappling candidate. // Not very scalable ... for (DWORD i = 0; i < oapiGetVesselCount(); i++) { OBJHANDLE hV = oapiGetVesselByIndex (i); if (hV == OurVessel->GetHandle()) continue; // we don't want to grapple ourselves ... oapiGetGlobalPos (hV, &gvslPos); if (dist (gvslPos, gprbPos) < oapiGetSize (hV)) { // in range VESSEL *v = oapiGetVesselInterface (hV); DWORD nAttach = v->AttachmentCount (true); for (DWORD j = 0; j < nAttach; j++) { // now scan all attachment points of the candidate ATTACHMENTHANDLE hAtt = v->GetAttachmentHandle (true, j); const char *id = v->GetAttachmentId (hAtt); if (strncmp (id, "PADROGUE", 8)) continue; // attachment point not compatible v->GetAttachmentParams (hAtt, pos, dir, rot); v->Local2Global (pos, gdrgPos); // converts found drogue position to global v->GlobalRot (dir, gdrgDir); // rotates found drogue direction to global if (dist (gdrgPos, gprbPos) < COLLISION_DETECT_RANGE && DockingMethod == ADVANCEDPHYSICS) { // found one less than a meter away! // Detect if collision has happend, if so, t will return intersection point along the probe line X(t) = gprbPos + t * gprbDir double t = CollisionDetection(gprbPos, gprbDir, gdrgPos, gdrgDir); // Calculate time of penetration according to current velocity OurVessel->GetRelativeVel(hV, rvel); // Determine resultant force //APPLY rforce to DockingProbe Vessel, and APPLY -rforce to Drogue Vessel return; } if (dist(gdrgPos, gprbPos) < CAPTURE_DETECT_RANGE && DockingMethod > ADVANCED) { // If we're within capture range, set docking port to attachment so docking can take place // Originally, I would have used the Attachment features to soft dock and move the LM during retract // but Artlav's docking method does this better and uses the docking port itself. // Attachment is being used as a placeholder for the docking port and to identify its orientation. OurVessel->GetAttachmentParams(hattPROBE, pos, dir, rot); DOCKHANDLE dock = OurVessel->GetDockHandle(ourPort); OurVessel->SetDockParams(dock, pos, dir, rot); } }//for nAttach }//if inRange }//for nVessel } }
void CFuncVehicle::Next() { Vector vGravityVector, forward, right, up; float time = 0.1f; vGravityVector = g_vecZero; UTIL_MakeVectors(pev->angles); forward = (gpGlobals->v_forward * -1) * (m_length * 0.5); right = (gpGlobals->v_right * -1) * (m_width * 0.5); up = gpGlobals->v_up * 16; m_vFrontLeft = pev->origin + forward - right + up; m_vFrontRight = pev->origin + forward + right + up; m_vFront = pev->origin + forward + up; m_vBackLeft = pev->origin - forward - right + up; m_vBackRight = pev->origin - forward + right + up; m_vBack = pev->origin - forward + up; m_vSurfaceNormal = g_vecZero; CheckTurning(); if (m_flSteeringWheelDecay < gpGlobals->time) { m_flSteeringWheelDecay = gpGlobals->time + 0.1f; if (m_iTurnAngle < 0) m_iTurnAngle++; else if (m_iTurnAngle > 0) m_iTurnAngle--; } if (m_flAcceleratorDecay < gpGlobals->time) { m_flAcceleratorDecay = gpGlobals->time + 0.1f; if (pev->speed < 0) { pev->speed += 20; if (pev->speed > 0) pev->speed = 0; } else if (pev->speed > 0) { pev->speed -= 20; if (pev->speed < 0) pev->speed = 0; } } if (pev->speed == 0) { m_iTurnAngle = 0; pev->avelocity = g_vecZero; pev->velocity = g_vecZero; SetThink(&CFuncVehicle::Next); NextThink(pev->ltime + time, TRUE); return; } TerrainFollowing(); CollisionDetection(); Vector temp; if (m_vSurfaceNormal != g_vecZero) { Vector vTargetAngle, vAngle; float vx; real_t vy; m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, gpGlobals->v_forward); m_vVehicleDirection = CrossProduct(m_vSurfaceNormal, m_vVehicleDirection); vTargetAngle = UTIL_VecToAngles(m_vVehicleDirection); vAngle = pev->angles; vTargetAngle.y += 180; if (m_iTurnAngle != 0) { vTargetAngle.y += m_iTurnAngle; } UTIL_FixupAngles(vTargetAngle); UTIL_FixupAngles(vAngle); vx = UTIL_AngleDistance(vTargetAngle.x, vAngle.x); vy = UTIL_AngleDistance(vTargetAngle.y, vAngle.y); if (vx > 10) vx = 10; else if (vx < -10) vx = -10; if (vy > 10) vy = 10; else if (vy < -10) vy = -10; pev->avelocity.y = int(vy * 10); pev->avelocity.x = int(vx * 10); m_flLaunchTime = -1; m_flLastNormalZ = m_vSurfaceNormal.z; } else { if (m_flLaunchTime != -1) { vGravityVector.x = 0; vGravityVector.y = 0; vGravityVector.z = (gpGlobals->time - m_flLaunchTime) * -35; if (vGravityVector.z < -400) { vGravityVector.z = -400; } } else { m_flLaunchTime = gpGlobals->time; vGravityVector = Vector(0, 0, 0); pev->velocity = pev->velocity * 1.5; } m_vVehicleDirection = gpGlobals->v_forward * -1; } UTIL_VecToAngles(m_vVehicleDirection); if (m_flUpdateSound < gpGlobals->time) { UpdateSound(); m_flUpdateSound = gpGlobals->time + 1.0f; } if (m_vSurfaceNormal != g_vecZero) { pev->velocity = m_vVehicleDirection.Normalize() * pev->speed; } else { pev->velocity = pev->velocity + vGravityVector; } SetThink(&CFuncVehicle::Next); NextThink(pev->ltime + time, TRUE); }
void Game::Loop(){ srand (time(NULL)); player = new Player(renderer,WIDTH/2 ,HEIGHT/2,1,PLAYER,&information); gameObjects.push_back(player); for(int i=1;i<=5;i++) { int AsteroidX = rand() % 600 + 150; int AsteroidY = rand() % 300 + 150; if(player->CheckIfCanSpawnAsteroid(AsteroidX,AsteroidY)) { asteroid = new Asteroids(renderer,AsteroidX,AsteroidY,&information); gameObjects.push_back(asteroid); } else i--; } while(!quit && mainEvent.type != SDL_QUIT) { timer = SDL_GetTicks(); CheckIfGameIsEnded(); while(SDL_PollEvent(&mainEvent)) { if(mainEvent.type == SDL_KEYDOWN) { if(mainEvent.key.keysym.sym == SDLK_q) { //ADDING NEW ASTEROIDS //asteroid = new Asteroids(renderer,rand() % 600 + 150 ,rand() % 300 + 150,&information); //gameObjects.push_back(asteroid); } if(mainEvent.key.keysym.sym == SDLK_SPACE) { //ADDING NEW ASTEROIDS bullet = new Bullet(renderer,player->points[1].x,player->points[1].y,5,BULLET,player->GetAngle(),&information); gameObjects.push_back(bullet); } } } SpawnAsteroids(); /////////////////COLLISION DETECTION //////////// CollisionDetection(); /////////////////////////////////////////////////////// //UPDATE GAMEOBJECTS for(int i = 0; i < gameObjects.size(); i++){ gameObjects[i]->Update(); } //////////////////////////////////////////////////////// //DELETE DEAD OBJECTS DeleteUnusedOrDeadObjects(); ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// //DRAW Background RenderBackground(); ////////////////////////////////////////////////////// //DRAW things ///////RENDER for(int i = 0; i < gameObjects.size(); i++){ gameObjects[i]->Render(); } ShowScore(information); //////////////////////////////////////////////////////// ///////////////FPS////////////// SDL_RenderPresent(renderer); if(1000/FPS > SDL_GetTicks() - timer) SDL_Delay(1000/FPS - (SDL_GetTicks() - timer)); //////////////////////////////////////////////////////// } }
GLvoid Scene::KeyListener(){ /* landMap is the height map of the land */ // W if(_keystate['w']){ _mainCraft->MoveBy(SCALE_RATIO*_movingSpeed); //_mainPlayer->UpdatePos(SCALE_RATIO, _mainLand->landMap[(GLint)(_mainPlayer->modelPos.x/(SCALE_RATIO))][(GLint)(_mainPlayer->modelPos.z/(SCALE_RATIO))], 0.0f); } // A if(_keystate['a']){ _mainCraft->UpdateDirection(-1.0f); //_mainCraft->UpdatePos(move_x, 0.0f, move_z); //_mainPlayer->UpdatePos(0.0f, _mainLand->landMap[(GLint)(_mainPlayer->modelPos.x/(SCALE_RATIO))][(GLint)(_mainPlayer->modelPos.z/(SCALE_RATIO))], -SCALE_RATIO); } // S if(_keystate['s']){ _mainCraft->MoveBy(-SCALE_RATIO*_movingSpeed); //_mainPlayer->UpdatePos(-SCALE_RATIO, _mainLand->landMap[(GLint)(_mainPlayer->modelPos.x/(SCALE_RATIO))][(GLint)(_mainPlayer->modelPos.z/(SCALE_RATIO))], 0.0f); } // D if(_keystate['d']){ _mainCraft->UpdateDirection(1.0f); //_mainPlayer->UpdatePos(0.0f, _mainLand->landMap[(GLint)(_mainPlayer->modelPos.x/(SCALE_RATIO))][(GLint)(_mainPlayer->modelPos.z/(SCALE_RATIO))], +SCALE_RATIO); //_mainCraft->UpdatePos(move_x, 0.0f, move_z); } // Space if(_keystate[' ']){ //_mainPlayer->UpdatePos(STEP_SIZE*SCALE_RATIO, 0.0f , STEP_SIZE*SCALE_RATIO); _mainCraft->UpdateHeight(SCALE_RATIO*_movingSpeed); } if(_keystate['q']){ _mainCraft->UpdateHeight(-SCALE_RATIO*_movingSpeed); } if(_keystate['5']){ zoom+=0.1f; } if(_keystate['6']){ zoom-=0.1f; } // Fire if(_keystate['f']&&_mainCraft->_bullets.size() < 8){ // max bullets in one column is 8 if(!_mainCraft->_bullets.empty()){ for(auto bullets:_mainCraft->_bullets){ for(auto bullet:bullets){ bullet->Emit(); bullet->UpdatePos(); } if(bullets.back()->_lifeCounter == 10){ _mainCraft->_bullets.push_back(_mainCraft->tmpBullets.front()); _mainCraft->tmpBullets.pop_front(); } if(bullets.back()->isNeedRemove){ _mainCraft->tmpBullets.push_back(_mainCraft->_bullets.front()); for(auto item:_mainCraft->tmpBullets.back()){ item->Reset(); } _mainCraft->_bullets.pop_front(); } } CollisionDetection(); }else{ _mainCraft->_bullets.push_back(_mainCraft->tmpBullets.front()); _mainCraft->tmpBullets.pop_front(); } }else{ if(!_mainCraft->_bullets.empty()){ _mainCraft->tmpBullets.push_back(_mainCraft->_bullets.front()); for(auto item:_mainCraft->tmpBullets.back()){ item->Reset(); } _mainCraft->_bullets.pop_front(); } } if(_keystate['v']){ _isUseParticle = true; _movingSpeed = 3.0f; }else{ _mainCraft->_particles.back()->ParticleInit(); _isUseParticle = false; _movingSpeed = 1.0f; } if(_keystate['1']){ _mainLand.back()->heightCoefficient += 0.1f; } if(_keystate['2']){ _mainLand.back()->heightCoefficient -= 0.1f; } }
//----------------------------------------------------------------------------- // Name : FrameAdvance () (Private) // Desc : Called to signal that we are now rendering the next frame. //----------------------------------------------------------------------------- void CGameApp::FrameAdvance() { static TCHAR FrameRate[ 50 ]; static TCHAR TitleBuffer[ 255 ]; // Advance the timer m_Timer.Tick( 60 ); // Skip if app is inactive if ( !m_bActive ) return; // Get / Display the framerate if ( m_LastFrameRate != m_Timer.GetFrameRate() ) { m_LastFrameRate = m_Timer.GetFrameRate( FrameRate, 50 ); sprintf_s( TitleBuffer, _T("Game : %s"), FrameRate ); SetWindowText( m_hWnd, TitleBuffer ); } // End if Frame Rate Altered if(StartGame == true) { SetCursor( NULL ); // Poll & Process input devices ProcessInput(); // Collision detection between game objects BricksExist=false; CollisionDetection(); if(BricksExist == false) { Vec2 brickPos; brickPos.x = START_BRICK_POS_X; brickPos.y = START_BRICK_POS_Y; countBricks = 0; countGifts = 0; nrBricks = 0; // delete objects from previous level for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { countBricks++; } } for(int cBricks = 0; cBricks <= countBricks; cBricks++) { for(auto it2 = m_vGameObjects.begin(); it2 != m_vGameObjects.end(); ++it2) { CGameObject * pGameObj = it2->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { m_vGameObjects.erase(it2); break; } } } for(auto it = m_vGameObjectsGift.begin(); it != m_vGameObjectsGift.end(); ++it) { CGameObject * pGameObj = it->get(); countGifts++; } for(int cGifts = 0; cGifts <= countGifts; cGifts++) { for(auto it2 = m_vGameObjectsGift.begin(); it2 != m_vGameObjectsGift.end(); ++it2) { CGameObject * pGameObj = it2->get(); m_vGameObjectsGift.erase(it2); break; } } // load new objects m_pBall.lock()->myVelocity.x = 0; m_pBall.lock()->myVelocity.y = 0; m_pBall.lock()->myPosition.x = m_pPlayer.lock()->myPosition.x; m_pBall.lock()->myPosition.y = m_nViewHeight - m_pBall.lock()->GetHeight() - m_pPlayer.lock()->GetHeight() - ONE; FollowPlayer = true; UnstoppableBall = false; StickyBar = false; MoveBall = false; SystemParametersInfo(SPI_SETMOUSESPEED, NULL, (void*)10, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); ballPos.x = 0; if(ShrinkBar == true) { ShrinkBar = false; m_pPlayer.lock()->Normal_Bar(); } nrLevel++; level.LoadBricks(nrLevel); level.RandomBricks("-ud"); string::iterator it; for(it = level.bricks.begin(); it < level.bricks.end(); it++) { if(*it == '-') { continue; } auto pBrick = std::make_shared<Brick>(*it); m_vGameObjects.push_back(pBrick); } for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectType() == GOT_Brick) { for(std::size_t levelbricks = 0; levelbricks < level.bricks.size(); levelbricks++) { if(level.bricks[nrBricks] == '-') { brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } else { nrBricks++; break; } nrBricks++; } pGameObj->Init(Vec2(brickPos.x, brickPos.y)); brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } } if(level.Winner == true) { LevelChange = false; } else { LevelChange = true; } } // Animate the game objects AnimateObjects(); } // Drawing the game objects DrawObjects(); }