Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Czarniecki

Pages: [1]
1
General / Using boost-test with SFML and cmake
« on: February 08, 2022, 04:43:59 pm »
I'm writing a simple game in C++ with use of SFML. I want to use boost tests, but when i try to i get undefined reference in every place i use SFML features (the game itself works fine, it's just the test that don't). Sample test:
#include <boost/test/unit_test.hpp>
#include "Sentry.h"

BOOST_AUTO_TEST_SUITE(BasicModelTestSuite)

BOOST_AUTO_TEST_CASE(testLamp_10BulbsWithPower10_ExpectedPower)
    {
        sf::Texture projectileTexture;
        sf::Texture sentryTexture;
        std::vector<std::shared_ptr<Sentry>> foes;
        sentryTexture.loadFromFile("../GameResources/sentry_image.png");
        projectileTexture.loadFromFile("../GameResources/projectile_animation.png");
        foes.push_back(std::make_shared<Sentry>(Sentry(&sentryTexture, sf::Vector2u(1,2), 0.2f, sf::Vector2f(140,200), projectileTexture, true)));
        foes.push_back(std::make_shared<Sentry>(Sentry(&sentryTexture, sf::Vector2u(1,2), 0.2f, sf::Vector2f(200,200), projectileTexture, false)));
        BOOST_REQUIRE_EQUAL(foes.size(), 2);
    }

BOOST_AUTO_TEST_SUITE_END()

And the test portion of cmakelist.txt:
Quote
find_package(Boost 1.65 COMPONENTS "unit_test_framework" REQUIRED)

include_directories(
        ${CMAKE_CURRENT_SOURCE_DIR}/include
        ${Boost_INCLUDE_DIRS}
)

set(SOURCE_TEST_FILES
        test/master.cpp test/master.cpp test/baseTest.cpp
        main.cpp src/Level.cpp include/Level.h src/Game.cpp include/Game.h src/Platform.cpp include/Platform.h src/Item.cpp include/Item.h src/Life.cpp include/Life.h src/Coin.cpp include/Coin.h src/Collider.cpp include/Collider.h src/Enemy.cpp include/Enemy.h src/MrStrawberry.cpp include/MrStrawberry.h src/Animation.cpp include/Animation.h src/MrBerry.cpp include/MrBerry.h src/Projectile.cpp include/Projectile.h src/Sentry.cpp include/Sentry.h)

add_executable(TestProject ${SOURCE_TEST_FILES})

target_include_directories(TestProject PUBLIC include)

target_link_libraries(TestProject
        ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})

enable_testing()

add_test(NAME Test COMMAND TestProject
        --report_level=detailed
        --log_level=all
        --color_output=yes)

add_custom_target(check ${CMAKE_COMMAND} -E env CTEST_OUTPUT_ON_FAILURE=1 BOOST_TEST_LOG_LEVEL=all
        ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> --verbose
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

I have no clue why it throws undefined reference to everything, like this:
Quote
/usr/bin/ld: /home/student/CLionProjects/oop21_ww2_14/BerryGame/src/Projectile.cpp:8: undefined reference to `sf::RectangleShape::setSize(sf::Vector2<float> const&)'
/usr/bin/ld: /home/student/CLionProjects/oop21_ww2_14/BerryGame/src/Projectile.cpp:9: undefined reference to `sf::Shape::setTexture(sf::Texture const*, bool)'

2
General / Installing SFML on linux
« on: February 08, 2022, 11:54:16 am »
I've been developing my game in SFML on windows, but wanted to move to linux. I installed SFML like so:
Quote
sudo apt-get install libsfml-dev
Quote
But when i want to build my program i get:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake:139 (message):
  Requested SFML configuration (Static) was not found
Call Stack (most recent call first):
  CMakeLists.txt:11 (find_package)


CMake Error at CMakeLists.txt:11 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake

  but it set SFML_FOUND to FALSE so package "SFML" is considered to be NOT
  FOUND.
I am using clion and cmake.

3
General / Enemy patrolling
« on: January 01, 2022, 05:25:24 pm »
I'm currently making a game, and trying to create an enemy class, that is patrolling within a certain range from it's origin. My code:
huh = body.getPosition().x
body.move(-(sf::Vector2f(body.getPosition().x, -velocity.y) - sf::Vector2f(huh,body.getPosition().y))* deltaTime);
 

The code above is moving in one direction, and it does the job just fine, but as the object moves, it continuously slows down, until it stops completely, and i'd rather have it walk all the way with the same speed. Any tips on how to do this?

Pages: [1]
anything