diff --git a/Makefile b/Makefile index 3c36a08..c220f3b 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ OBJS := $(SRCS:.cc=.o) DEBUG := -g -SDL_INCLUDE := `sdl2-config --cflags` -I. +SDL_INCLUDE := `sdl2-config --cflags` SDL_LIB := `sdl2-config --libs` -lSDL2_ttf -lSDL2_mixer -CPPFLAGS += $(SDL_INCLUDE) +CPPFLAGS += $(SDL_INCLUDE) -I. CXXFLAGS += $(DEBUG) -Wall -std=c++11 LDFLAGS += $(SDL_LIB) diff --git a/README.md b/README.md index 13e3434..808f1bb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Pong clone written in C++ with SDL 2.0. You will need: -+ [SDL 2.0](https://www.libsdl.org/hg.php) ++ [SDL 2.0](https://www.libsdl.org/) + [SDL Mixer 2.0](http://www.libsdl.org/projects/SDL_mixer/) + [SDL TTF 2.0](https://www.libsdl.org/projects/SDL_ttf/) diff --git a/src/ball.cc b/src/ball.cc index 2d9b3f7..4c60346 100644 --- a/src/ball.cc +++ b/src/ball.cc @@ -51,22 +51,21 @@ void Ball::launch_ball(Paddle *ai_paddle) { } void Ball::bounces_off(Paddle *paddle) { - if (paddle == nullptr) - return; + if (paddle == nullptr) return; - hits++; + hits++; - int sign = (paddle->get_x() < Pong::SCREEN_WIDTH/2) ? 1 : -1; + int sign = (paddle->get_x() < Pong::SCREEN_WIDTH/2) ? 1 : -1; - int relative_y = (y - paddle->get_y() + LENGTH); + int relative_y = (y - paddle->get_y() + LENGTH); - angle = (2.14f * relative_y - 75.0f); + angle = (2.14f * relative_y - 75.0f); - // Convert angle to radian, find its cos() and multiply by the speed. - dx = sign*speed*std::cos(angle*M_PI/180.0f); + // Convert angle to radian, find its cos() and multiply by the speed. + dx = sign*speed*std::cos(angle*M_PI/180.0f); - // Convert angle to radina, find its sin() and multiply by the speed. - dy = speed*std::sin(angle*M_PI/180.0f); + // Convert angle to radina, find its sin() and multiply by the speed. + dy = speed*std::sin(angle*M_PI/180.0f); } void Ball::update_speed() {