diff --git a/main.cpp b/main.cpp index 9ed2e66..8b64541 100644 --- a/main.cpp +++ b/main.cpp @@ -3,7 +3,10 @@ #include #include #include +#include #include +#include +#include #include #include @@ -40,7 +43,7 @@ static float ballVelY = 0.5f; static float ballSpeed = 600.f; static float ballAccel = 25.f; -static float opponentSpeed = 450.f; +static float opponentSpeed = 1200.f; static float opponentVelY = 0.f; const char* vShader = "#version 300 es\n" @@ -175,6 +178,8 @@ static Rect opponent( bool paused = true; extern "C" int APP_MAIN(int argc, char **argv) { + srand(time(NULL)); + SDL_SetAppMetadata("Example Renderer Primitives", "1.0", "com.example.renderer-primitives"); SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight"); @@ -269,8 +274,16 @@ extern "C" int APP_MAIN(int argc, char **argv) { } if (paused && event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_SPACE) { paused = false; + ball.x = SCREEN_WIDTH / 2 - BALL_SIZE / 2; + ball.y = SCREEN_HEIGHT / 2 - BALL_SIZE / 2; + ballVelX = ((float)rand() / (float)RAND_MAX) * 2.f - 1.f; + ballVelY = ((float)rand() / (float)RAND_MAX) * 2.f - 1.f; } else if (paused && event.type == SDL_EVENT_FINGER_UP) { paused = false; + ball.x = SCREEN_WIDTH / 2 - BALL_SIZE / 2; + ball.y = SCREEN_HEIGHT / 2 - BALL_SIZE / 2; + ballVelX = (float)rand() / (float)RAND_MAX * 2 - 1; + ballVelY = (float)rand() / (float)RAND_MAX * 2 - 1; } }