Get the App
SLTechnology News&Howtos  ›  Development  › 

Application example Analysis of SurfaceView Class in Android Game Development

Shulou Source: shulou.com Published: 2022-06-02 10:15:25 09月14日 Update

< 0) mHeading += 360; else if (mHeading >

) mHeading-= 360;} / / Base accelerations-- 0 for x, gravity for y double ddx = 0; double ddy =-PHYS_DOWN_ACCEL_SEC * elapsed If (mEngineFiring) {/ / taking 0 as up, 90 as to the right / / cos (deg) is ddy component, sin (deg) is ddx component double elapsedFiring = elapsed; double fuelUsed = elapsedFiring * PHYS_FUEL_SEC / / tricky case where we run out of fuel partway through the / / elapsed if (fuelUsed > mFuel) {elapsedFiring = mFuel / fuelUsed * elapsed; fuelUsed = mFuel / / Oddball case where we adjust the "control" from here mEngineFiring = false;} mFuel-= fuelUsed; / / have this much acceleration from the engine double accel = PHYS_FIRE_ACCEL_SEC * elapsedFiring Double radians = 2 * Math.PI * mHeading / 360; ddx = Math.sin (radians) * accel; ddy + = Math.cos (radians) * accel;} double dxOld = mDX; double dyOld = mDY / / figure speeds for the end of the period mDX + = ddx; mDY + = ddy; / / figure position based on average speed during the period mX + = elapsed * (mDX + dxOld) / 2; mY + = elapsed * (mDY + dyOld) / 2; mLastTime = now / / Evaluate if we have landed... Stop the game double yLowerBound = TARGET_PAD_HEIGHT + mLanderHeight / 2-TARGET_BOTTOM_PADDING; if (mY

Tags: Example case analysis analysis application development more knowledge article e.g.practical previous generation code that is work meeting engineering article see knowledge point industry try Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB vpn Apple MySQL