MCPcopy Create free account
hub / github.com/android/ndk-samples / DoFrame

Method DoFrame

endless-tunnel/app/src/main/cpp/play_scene.cpp:280–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void PlayScene::DoFrame() {
281 float deltaT = mFrameClock.ReadDelta();
282 float previousY = mPlayerPos.y;
283
284 // clear screen
285 glClearColor(0.0, 0.0, 0.0, 1.0);
286 glEnable(GL_DEPTH_TEST);
287 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
288
289 // rotate the view matrix according to current roll angle
290 glm::vec3 upVec = glm::vec3(-sin(mRollAngle), 0, cos(mRollAngle));
291
292 // set up view matrix according to player's ship position and direction
293 mViewMat = glm::lookAt(mPlayerPos, mPlayerPos + mPlayerDir, upVec);
294
295 // render tunnel walls
296 RenderTunnel();
297
298 // render obstacles
299 RenderObstacles();
300
301 if (mMenu) {
302 RenderMenu();
303 // nothing more to do
304 return;
305 }
306
307 // render HUD (lives, score, etc)
308 RenderHUD();
309
310 // deduct from the time remaining to remove a sign from the screen
311 if (mSignText && mSignExpires) {
312 mSignTimeLeft -= deltaT;
313 if (mSignTimeLeft < 0.0f) {
314 mSignText = NULL;
315 }
316 }
317
318 // if a "saved checkpoint" sign pending? Can we show it right now?
319 if (!mSignText && mCheckpointSignPending) {
320 mCheckpointSignPending = false;
321 ShowSign(S_CHECKPOINT_SAVED, SIGN_DURATION);
322 }
323
324 // did we already show the howto?
325 if (!mShowedHowto && mDifficulty == 0) {
326 mShowedHowto = true;
327 ShowSign(S_HOWTO_WITHOUT_JOY, SIGN_DURATION);
328 }
329
330 // deduct from the time remaining on the blinking heart animation
331 if (mBlinkingHeart && Clock() > mBlinkingHeartExpire) {
332 mBlinkingHeart = false;
333 }
334
335 // update speed
336 float targetSpeed = PLAYER_SPEED + PLAYER_SPEED_INC_PER_LEVEL * mDifficulty;
337 float accel = mPlayerSpeed >= 0.0f ? PLAYER_ACCELERATION_POSITIVE_SPEED

Callers

nothing calls this directly

Calls 6

ClockFunction · 0.85
ApproachFunction · 0.85
ClampFunction · 0.85
ReadDeltaMethod · 0.80
RequestNewSceneMethod · 0.80
PlayToneMethod · 0.80

Tested by

no test coverage detected