From 778de89501e812edab5229d702f00fb9c9af1f72 Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Tue, 14 Aug 2018 09:08:31 +0200 Subject: [PATCH] update doc, travis poging1 --- .gitignore | 1 + .travis.yml | 15 ++++++++++ CMakeLists.txt | 2 +- README.md | 29 +++++++++++++++++-- .../libgba-sprite-engine/sprites/sprite.h | 4 +-- test/CMakeLists.txt | 4 +-- test/scenetest.cpp | 4 +-- 7 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 2d3823f..83642da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +build/ # Created by https://www.gitignore.io/api/clion,cmake diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5f85b6c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: cpp +compiler: g++ + +before_install: + # Install a supported cmake version + - wget -O cmake.sh https://cmake.org/files/v3.12/cmake-3.12.1-Linux-x86_64.sh + - sudo sh cmake.sh --skip-license --exclude-subdir --prefix=/usr/local + + script: + - mkdir build + - cd build + - cmake -DCMAKE_CXX_COMPILER=$BIN_PATH/clang++ -DCMAKE_INSTALL_PREFIX=./ ../ + - cd test + - make + - ./unittest \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d24261..d58b278 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.12) SET(CMAKE_C_COMPILER arm-none-eabi-gcc) SET(CMAKE_CXX_COMPILER arm-none-eabi-g++) SET(CMAKE_OBJCOPY arm-none-eabi-objcopy) -SET(CMAKE_AR arm-none-eabi-ar) +SET(CMAKE_AR arm-none-eabi-ar CACHE FILEPATH "Archiver") SET(CMAKE_RANLIB arm-none-eabi-ranlib) SET(BASE_CMAKE_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") diff --git a/README.md b/README.md index 27f3d5b..8e7607c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ## A high-level object-oriented Gameboy Advance sprite engine library +![travis build status](https://travis-ci.org/wgroeneveld/gba-sprite-engine.svg?branch=master) + That's a mouthful - let's break that down: #### High-level object-oriented @@ -117,7 +119,9 @@ Creating sprites is easy with the `SpriteBuilder`. Specify what kind of sprite y Sample rotation demo 3. -**Sprite animation is built-in**! Just feed your sprite data to the builder and use `.withAnimated(amountOfFrames, frameDelay)`. Remember to position each frame in one column in the image itself (vertically). +**Sprite animation is built-in**! Just feed your sprite data to the builder and use `.withAnimated(amountOfFrames, frameDelay)`. Remember to position each frame in one column in the image itself (vertically). Like this: + +![lama gif example](https://github.com/wgroeneveld/gba-sprite-engine/blob/master/demos/demo1-basicfeatures/lama.png?raw=true) Useful sprite methods: @@ -160,15 +164,34 @@ The engine comes with (some) [Google Test](https://github.com/google/googletest) ### Compiling everything -The project has been developed with CLion. The `.idea` dir is there for you to get started. +#### Prerequirements + +1. cmake 3.12.x or higher: the cmake linker toolchain set contains a bug in .11 +2. A compiled Google Test 1.8.x or higher with `$GTEST_DIR` env. var +3. The [DevkitPro toolchain](https://devkitpro.org/wiki/Getting_Started) installed in your `$PATH` +4. The [mGBA emulator](https://mgba.io/downloads.html) + +#### Compiling with cmake + +The project has been developed with CLion. The `.idea` dir is there for you to get started. The project can be imported as a cmake project. As such, `CMake` was an easy choice. Use the following commands to build everything, including the demos: 1. `mkdir cmake-build-debug && cd cmake-build-debug` 2. `cmake ./../` +3. `make` + +The demos will be in `cmake-build-debug/demox/demoname.gba`. Things you might need to change in `CMakeLists.txt` files: 1. I'm assuming your GBA cross compiler is in your `$PATH`. If it's not, add an absolute path to `SET(CMAKE_C_COMPILER arm-none-eabi-gcc)` etc. -2. The Google Test Library should be compiled from source in some directory. I have mine hardcoded: `SET(GTEST_LIBRARY "/Users/jefklak/CLionProjects/googletest-release-1.8.0/googletest")` so adjust accordinly or exclude the test subproject. +2. I'm assuming your Google Test Library is compiled and in your `$GTEST_DIR` path. If not, add an absolute path to: `SET(GTEST_LIBRARY "/Users/jefklak/CLionProjects/googletest-release-1.8.0/googletest")`. +#### Running unit tests + +After compiling, execute the `unittest` main executable: + +`./cmake-build-debug/test/unittest` + +And hope for exit code 0! diff --git a/engine/include/libgba-sprite-engine/sprites/sprite.h b/engine/include/libgba-sprite-engine/sprites/sprite.h index 59e3f73..530fbca 100644 --- a/engine/include/libgba-sprite-engine/sprites/sprite.h +++ b/engine/include/libgba-sprite-engine/sprites/sprite.h @@ -48,8 +48,8 @@ private: protected: const void *data; - u32 x, y, priority, dx, dy; - u32 w, h, size_bits, shape_bits; + int x, y, dx, dy; + u32 priority, w, h, size_bits, shape_bits; bool stayWithinBounds; u32 imageSize, tileIndex; SpriteSize spriteSize; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 45fcfbc..b9c5813 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.12) project(Unittest) enable_testing() -SET(GTEST_LIBRARY "/Users/jefklak/CLionProjects/googletest-release-1.8.0/googletest") +SET(GTEST_LIBRARY "$ENV{GTEST_DIR}") # reset linker flags; ARM + GTest doesn't work SET(CMAKE_EXE_LINKER_FLAGS "${BASE_CMAKE_LINK_FLAGS}") diff --git a/test/scenetest.cpp b/test/scenetest.cpp index 5310676..d680eea 100644 --- a/test/scenetest.cpp +++ b/test/scenetest.cpp @@ -17,12 +17,12 @@ protected: } }; -class SomeScene : public scene { +class SomeScene : public Scene { private: std::unique_ptr someSprite1; std::unique_ptr someSprite2; public: - SomeScene() : scene(nullptr) { }; + SomeScene() : Scene(nullptr) { }; std::vector sprites() override { return { someSprite1.get(), someSprite2.get()