Mercurial > hg > beaglert
diff examples/tank_wars/render.cpp @ 311:493a07f6ec09 prerelease
Renamed BelaContext->audioSampleCount to BelaContext->audioFramesElapsed for consistency of terminology
author | andrewm |
---|---|
date | Fri, 27 May 2016 18:37:51 +0100 |
parents | 421a69d42943 |
children | 9dc5a0ccad25 |
line wrap: on
line diff
--- a/examples/tank_wars/render.cpp Fri May 27 18:29:20 2016 +0100 +++ b/examples/tank_wars/render.cpp Fri May 27 18:37:51 2016 +0100 @@ -202,7 +202,7 @@ } // First-order lowpass filter to remove noise on launch FSR - float rawSample = analogReadFrame(context, n, gInputLauncher); + float rawSample = analogRead(context, n, gInputLauncher); float launchSample = gLauncherFilterPole * gLauncherLastSample + (1.0f - gLauncherFilterPole) * rawSample; gLauncherLastSample = launchSample; @@ -236,9 +236,9 @@ // Update game physics and cannon angles gSamplesUntilNextFrame = gGameFrameInterval; - setTank1CannonAngle(map(analogReadFrame(context, n, gInputTank1Angle), + setTank1CannonAngle(map(analogRead(context, n, gInputTank1Angle), 0, 1.0, M_PI, 0)); - setTank2CannonAngle(map(analogReadFrame(context, n, gInputTank2Angle), + setTank2CannonAngle(map(analogRead(context, n, gInputTank2Angle), 0, 1.0, M_PI, 0)); nextGameFrame(); @@ -265,21 +265,21 @@ // Rescale screen coordinates to matrix ranges; invert the Y // coordinate to go from normal screen coordinates to scope coordinates - analogWriteFrameOnce(context, n, gOutputX, constrain(map(x, 0, gScreenWidth, 0, 1.0), 0, 1.0)); - analogWriteFrameOnce(context, n, gOutputY, constrain(map(y, 0, gScreenHeight, 1.0, 0), 0, 1.0)); + analogWriteOnce(context, n, gOutputX, constrain(map(x, 0, gScreenWidth, 0, 1.0), 0, 1.0)); + analogWriteOnce(context, n, gOutputY, constrain(map(y, 0, gScreenHeight, 1.0, 0), 0, 1.0)); } else { // Still not ready! Write 0 until something happens - analogWriteFrameOnce(context, n, gOutputX, 0); - analogWriteFrameOnce(context, n, gOutputY, 0); + analogWriteOnce(context, n, gOutputX, 0); + analogWriteOnce(context, n, gOutputY, 0); } if(gameStatusWinner() != 0) { // Blink one LED to show who won // Blink both LEDs when projectile is in motion float val = (gSampleCounter % 4000 > 2000) ? 1.0 : 0; - analogWriteFrameOnce(context, n, gOutputPlayer1LED, gameStatusWinner() == 1 ? val : 0); - analogWriteFrameOnce(context, n, gOutputPlayer2LED, gameStatusWinner() == 2 ? val : 0); + analogWriteOnce(context, n, gOutputPlayer1LED, gameStatusWinner() == 1 ? val : 0); + analogWriteOnce(context, n, gOutputPlayer2LED, gameStatusWinner() == 2 ? val : 0); // After 5 seconds, restart the game gSamplesSinceFinish++; @@ -289,16 +289,16 @@ else if(gameStatusProjectileInMotion()) { // Blink both LEDs when projectile is in motion float val = (gSampleCounter % 2000 > 1000) ? 1.0 : 0; - analogWriteFrameOnce(context, n, gOutputPlayer1LED, val); - analogWriteFrameOnce(context, n, gOutputPlayer2LED, val); + analogWriteOnce(context, n, gOutputPlayer1LED, val); + analogWriteOnce(context, n, gOutputPlayer2LED, val); } else if(gameStatusPlayer1Turn()) { - analogWriteFrameOnce(context, n, gOutputPlayer1LED, 1.0); - analogWriteFrameOnce(context, n, gOutputPlayer2LED, 0); + analogWriteOnce(context, n, gOutputPlayer1LED, 1.0); + analogWriteOnce(context, n, gOutputPlayer2LED, 0); } else { - analogWriteFrameOnce(context, n, gOutputPlayer2LED, 1.0); - analogWriteFrameOnce(context, n, gOutputPlayer1LED, 0); + analogWriteOnce(context, n, gOutputPlayer2LED, 1.0); + analogWriteOnce(context, n, gOutputPlayer1LED, 0); } // Check if we have reached the point where we should next update