How to Build UFO‐Cells (Linux) - UbuntuJackson/UFO-Cells GitHub Wiki
UFO-Cells does under the hood use a graphics toolkit called PixelGameEngine. PixelGameEngine depends on OpenGL. On Windows those dependencies are already installed by the drivers, but on Linux there are a few additional things you need to install.
install libopengl-dev
install libglx-dev
install libpng-dev
install libx11-dev
install libthread-pool-dev?
Do you need libopenal-dev?
A typical UFO-Cells project ought to look like this.\n
root
|_/build
|_/external/UFO-Cells
|_/res
|_/src
|_CMakeLists.txt
Thus you need to create a folder called "build", "external", "res", "external" and then a "CMakeLists.txt" file.
-
Open /root in terminal.
cd external.
git clone https://github.com/UbuntuJackson/UFO-Cells.git
- Make an example Project. Make a main.cpp file with the following code.
#include <ufo/game.h>
#include <ufo/console.h>
#include <ufo/ray2.h>
#include <olcPixelGameEngine.h>
class PGE_Derived : public Game{
public:
Ray2 ray{olc::vf2d(10.0f*6.0f, 10.0f*6.0f), olc::vf2d(10.0f*10.0f, 10.0f*10.0f)};
Ray2 other_ray{olc::vf2d(60.0f, 20.0f), olc::vf2d(10.0f*2.0f, 40.0f)};
PGE_Derived() : Game(){}
bool OnUserCreate(){
return true;
}
bool OnUserUpdate(float fElapsedTime){
dt = fElapsedTime;
Clear(olc::GREY);
SetPixelMode(olc::Pixel::NORMAL);
ray.p1 = GetMousePos();
Console::Out(Ray2({0.0f, 0.0f}, {3.0f, 2.0f}).Normal());
DrawLine(other_ray.Start(), other_ray.End(), olc::BLUE);
if(ray.VsOtherRay(other_ray).is_hit){
DrawLine(ray.Start(), ray.End(), olc::RED);
}
else{
DrawLine(ray.Start(), ray.End(), olc::GREEN);
}
return true;
}
};
int main(){
PGE_Derived game;
if (game.Construct(400, 200, 1, 1, false, true, true))
game.Start();
return 0;
}
- Make a CMakeLists.txt in /root.
cmake_minimum_required(VERSION 3.10)
project(ExecutableName)
add_subdirectory(external/UFO-Cells) #CMakeLists.txt for engine is in folder called "engine"
set(
SRC
src/main.cpp
)
add_executable(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME} PUBLIC UFOCells)
cd build
cmake .. -DCMAKE_CXX_FLAGS="-ggdb"
make
./ExecutableName