Skip to content

Commit

Permalink
CMake: Enable -Wall
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Oct 11, 2023
1 parent a616b37 commit b4e4482
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(MSVC)
string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=implicit-function-declaration")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fdiagnostics-color")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
Expand Down
14 changes: 7 additions & 7 deletions examples/bike/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#include <jngl/init.hpp>

jngl::AppParameters jnglInit() {
return {
[]() {
jngl::setStepsPerSecond(1. / timePerFrame);
jngl::AppParameters params;
params.start = []() {
jngl::setStepsPerSecond(std::lround(1. / timePerFrame));
jngl::setPrefix("../examples/bike");
return std::make_shared<Base>();
},
"Bike",
jngl::Vec2(screenWidth, screenHeight),
};
};
params.displayName = "Bike";
params.screenSize = { screenWidth, screenHeight };
return params;
}
10 changes: 5 additions & 5 deletions examples/shader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class ShaderExample : public jngl::Work {
};

jngl::AppParameters jnglInit() {
return {
[]() { return std::make_shared<ShaderExample>(); },
"Shader Example",
jngl::Vec2(1280, 720),
};
jngl::AppParameters params;
params.start = []() { return std::make_shared<ShaderExample>(); };
params.displayName = "Shader Example";
params.screenSize = { 1280, 720 };
return params;
}
38 changes: 16 additions & 22 deletions examples/throw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@ class Ball : public jngl::Work {
void CheckMouse(int x, int y);

private:
double x_, y_, xSpeed_, ySpeed_;
double x_{}, y_{}, xSpeed_{}, ySpeed_{};
const std::string filename_;
const int width_, height_;
};

const double timePerFrame = 0.01; // 100 FPS

jngl::AppParameters jnglInit() {
return {
[]() {
jngl::setStepsPerSecond(1. / timePerFrame);
jngl::setPrefix("../examples/throw");
return std::make_shared<Ball>("ball");
},
"Throw Example",
jngl::Vec2(screenWidth, screenHeight),
jngl::AppParameters params;
params.start = []() {
jngl::setStepsPerSecond(std::lround(1. / timePerFrame));
jngl::setPrefix("../examples/throw");
return std::make_shared<Ball>("ball");
};
params.displayName = "Throw Example";
params.screenSize = { screenWidth, screenHeight };
return params;
}

Ball::Ball(const std::string& filename)
: x_(100), y_(100), xSpeed_(200), ySpeed_(200), filename_(filename),
width_(jngl::getWidth(filename)), height_(jngl::getHeight(filename)) {
: filename_(filename), width_(jngl::getWidth(filename)), height_(jngl::getHeight(filename)) {
}

void Ball::draw() const {
Expand All @@ -49,32 +48,27 @@ void Ball::step() {
y_ += ySpeed_ * timePerFrame;
xSpeed_ *= 0.99; // Die Geschwindigkeit wird 100 mal pro Sekunde um 1 % langsamer
ySpeed_ *= 0.99;
if(x_ + width_ > screenWidth)
{
if (x_ + width_ > screenWidth) {
xSpeed_ = -xSpeed_;
x_ = screenWidth - width_;
}
if(y_ + height_ > screenHeight)
{
if (y_ + height_ > screenHeight) {
ySpeed_ = -ySpeed_;
y_ = screenHeight - height_;
}
if(x_ < 0)
{
if (x_ < 0) {
xSpeed_ = -xSpeed_;
x_ = 0;
}
if(y_ < 0)
{
if (y_ < 0) {
ySpeed_ = -ySpeed_;
y_ = 0;
}
}

void Ball::CheckMouse(const int x, const int y)
{
void Ball::CheckMouse(const int x, const int y) {
if (jngl::mouseDown()) {
xSpeed_ = (x - width_ / 2. - x_) * 10; // Geschwindigkeit vom Ball auf Entfernung von
xSpeed_ = (x - width_ / 2. - x_) * 10; // Geschwindigkeit vom Ball auf Entfernung von
ySpeed_ = (y - height_ / 2. - y_) * 10; // Mausposition und Ballmittelpunkt mal 10 setzen
}
}
1 change: 0 additions & 1 deletion src/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ class Test : public jngl::Work {
float volume = 1;
std::unique_ptr<jngl::Shader> vertexShader, fragmentShader;
std::unique_ptr<jngl::ShaderProgram> shaderProgram;
std::chrono::steady_clock clock;
jngl::Finally soundLoader;
};

Expand Down

0 comments on commit b4e4482

Please sign in to comment.