save
This commit is contained in:
parent
e42cd89337
commit
25b18f8484
54
build.cpp
54
build.cpp
@ -1,57 +1,18 @@
|
||||
|
||||
#define EXT_LINK
|
||||
#define EXT_INC
|
||||
#include "build.hpp"
|
||||
#include <unordered_set>
|
||||
|
||||
#ifdef _WIN32
|
||||
std::vector<std::string> LINK = {"-lopengl32", "-lkernel32", "-luser32", "-lshell32", "-lwinmm", "-lgdi32"};
|
||||
#else
|
||||
std::vector<std::string> LINK = {};
|
||||
#endif
|
||||
std::vector<std::string> LINK = {"raylib/lib/libraylib.a"};
|
||||
|
||||
std::vector<std::string> RAYINCLUDE = {"-Iraylib/src", "-Iraylib/src/external/glfw/include", "-Iraylib/src/external/glfw/deps/mingw"};
|
||||
std::vector<std::string> RAYINCLUDE = {"-Iraylib/include"};
|
||||
std::filesystem::path RAYLIB_DIR = "raylib";
|
||||
|
||||
bool build = false;
|
||||
bool clear = false;
|
||||
bool run = false;
|
||||
|
||||
void compile_raylib_dir()
|
||||
{
|
||||
std::filesystem::path out_dir = OBJ_DIR / RAYLIB_DIR;
|
||||
std::filesystem::path ray_src_dir = RAYLIB_DIR / "src";
|
||||
std::filesystem::create_directory(out_dir);
|
||||
std::vector<std::filesystem::path> ray_srcs = {"rcore.c", "rshapes.c", "rtextures.c", "rtext.c", "utils.c", "rmodels.c", "raudio.c", "rglfw.c"};
|
||||
std::vector<std::string> ray_flags = {"-D_GNU_SOURCE", "-DPLATFORM_DESKTOP", "-DGRAPHICS_API_OPENGL_33"};
|
||||
|
||||
command.clear();
|
||||
command.push_back(c_compiler);
|
||||
command.push_back("-c");
|
||||
int src_loc = command.size();
|
||||
command.push_back("");
|
||||
command.push_back("-o");
|
||||
int obj_loc = command.size();
|
||||
command.push_back("");
|
||||
|
||||
command.insert(command.end(), ray_flags.begin(), ray_flags.end());
|
||||
command.push_back(opt_flags);
|
||||
command.insert(command.end(), RAYINCLUDE.begin(), RAYINCLUDE.end());
|
||||
|
||||
std::filesystem::path out, src;
|
||||
|
||||
for (size_t i = 0; i < ray_srcs.size(); i++)
|
||||
{
|
||||
src = ray_src_dir / ray_srcs[i];
|
||||
out = out_dir / ray_srcs[i].replace_extension(".o");
|
||||
if (check_if_rebuild(src, out))
|
||||
{
|
||||
command[src_loc] = src.string();
|
||||
command[obj_loc] = out.string();
|
||||
run_command(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
if (rebuild_my_self(__FILE__, argc, argv))
|
||||
@ -82,9 +43,12 @@ int main(int argc, char const *argv[])
|
||||
|
||||
if (!std::filesystem::is_directory(RAYLIB_DIR))
|
||||
{
|
||||
command = {"git", "clone", "--depth", "1", "--branch", "5.0", "https://github.com/raysan5/raylib.git"};
|
||||
command = {"wget", "https://github.com/raysan5/raylib/releases/download/5.0/raylib-5.0_linux_amd64.tar.gz"};
|
||||
run_command(command);
|
||||
std::filesystem::remove_all("raylib/.git");
|
||||
command = {"tar", "-xzvf", "raylib-5.0_linux_amd64.tar.gz"};
|
||||
run_command(command);
|
||||
std::filesystem::rename("raylib-5.0_linux_amd64", "raylib");
|
||||
std::filesystem::remove_all("raylib-5.0_linux_amd64.tar.gz");
|
||||
}
|
||||
|
||||
if (!std::filesystem::is_directory(RAYLIB_DIR))
|
||||
@ -92,8 +56,6 @@ int main(int argc, char const *argv[])
|
||||
|
||||
std::filesystem::create_directory(OBJ_DIR);
|
||||
|
||||
compile_raylib_dir();
|
||||
|
||||
int res = compile_src_dir(RAYINCLUDE);
|
||||
switch (res)
|
||||
{
|
||||
|
@ -25,9 +25,10 @@ struct Moon
|
||||
|
||||
struct Branch
|
||||
{
|
||||
Color color;
|
||||
uint8_t numOfBranches;
|
||||
float lenghthRatio;
|
||||
uint8_t colorR;
|
||||
uint8_t colorG;
|
||||
uint8_t colorB;
|
||||
uint8_t branch_count;
|
||||
};
|
||||
|
||||
struct Dna
|
||||
@ -37,6 +38,7 @@ struct Dna
|
||||
int time;
|
||||
uint128 mountenSeed;
|
||||
uint128 starSeed;
|
||||
uint128 branchSeed;
|
||||
std::array<Branch, MAX_DEPTH> branches;
|
||||
};
|
||||
|
||||
|
@ -23,6 +23,7 @@ void Tree::draw(Dna *dna)
|
||||
|
||||
m_dna = dna;
|
||||
draw_calls.push_back({start, 0, (float)size / 4, 1});
|
||||
tick();
|
||||
}
|
||||
|
||||
bool Tree::tick()
|
||||
@ -55,10 +56,22 @@ Vector2 Tree::drawLine()
|
||||
float thick = 2.0;
|
||||
float fstep = 1.0 / ((arg.lenghth / thick) * 1.5);
|
||||
|
||||
Color colorParent = {
|
||||
m_dna->branches[arg.dep - 1].colorR,
|
||||
m_dna->branches[arg.dep - 1].colorG,
|
||||
m_dna->branches[arg.dep - 1].colorB,
|
||||
255};
|
||||
|
||||
Color colorM = {
|
||||
m_dna->branches[arg.dep].colorR,
|
||||
m_dna->branches[arg.dep].colorG,
|
||||
m_dna->branches[arg.dep].colorB,
|
||||
255};
|
||||
|
||||
for (float i = 0; i < 1; i += fstep)
|
||||
{
|
||||
Vector2 point = Vector2Lerp(arg.start, end, i);
|
||||
Color color = ColorLerp(m_dna->branches[arg.dep - 1].color, m_dna->branches[arg.dep].color, i);
|
||||
Color color = ColorLerp(colorParent, colorM, i);
|
||||
DrawCircleV(point, thick, color); // Fester on the phone to call DrawCircle insted of the Circle shader
|
||||
// Circle::setColor(color);
|
||||
// Circle::draw(point.x, point.y, thick); // TODO Change to BeginShaderMode and EndShaderMode only onece
|
||||
@ -66,6 +79,11 @@ Vector2 Tree::drawLine()
|
||||
return end;
|
||||
}
|
||||
|
||||
inline uint8_t get_num_of_branches(uint8_t count)
|
||||
{
|
||||
return ((float)count / 255.0f) * 3 + 1;
|
||||
}
|
||||
|
||||
void Tree::drawBranch()
|
||||
{
|
||||
DrawArgs arg = draw_calls.front();
|
||||
@ -74,11 +92,11 @@ void Tree::drawBranch()
|
||||
|
||||
Vector2 next = drawLine();
|
||||
|
||||
float next_len = m_dna->branches[arg.dep].lenghthRatio;
|
||||
float sectors = m_dna->branches[arg.dep].numOfBranches + 1;
|
||||
float next_len = 0.7f;
|
||||
float sectors = get_num_of_branches(m_dna->branches[arg.dep].branch_count) + 1;
|
||||
float degres = 180.0f / sectors;
|
||||
|
||||
for (size_t i = 0; i < m_dna->branches[arg.dep].numOfBranches; i++)
|
||||
for (size_t i = 0; i < get_num_of_branches(m_dna->branches[arg.dep].branch_count); i++)
|
||||
{
|
||||
float newAngle = arg.angleDeg - 90 + (degres * (i + 1));
|
||||
draw_calls.push_back({next, newAngle, arg.lenghth * next_len, arg.dep + 1});
|
||||
|
@ -15,24 +15,25 @@ void newDna(Dna &dna)
|
||||
dna.mountenSeed.b = mrand::getInt();
|
||||
dna.mountenSeed.c = mrand::getInt();
|
||||
dna.mountenSeed.d = mrand::getInt();
|
||||
|
||||
dna.starSeed.a = mrand::getInt();
|
||||
dna.starSeed.b = mrand::getInt();
|
||||
dna.starSeed.c = mrand::getInt();
|
||||
dna.starSeed.d = mrand::getInt();
|
||||
|
||||
for (size_t i = 0; i < MAX_DEPTH; i++)
|
||||
dna.branchSeed.a = mrand::getInt();
|
||||
dna.branchSeed.b = mrand::getInt();
|
||||
dna.branchSeed.c = mrand::getInt();
|
||||
dna.branchSeed.d = mrand::getInt();
|
||||
|
||||
for (size_t i = 0; i < dna.branches.size(); i++)
|
||||
{
|
||||
uint8_t r = mrand::getValue(0, 255);
|
||||
uint8_t g = mrand::getValue(0, 255);
|
||||
uint8_t b = mrand::getValue(0, 255);
|
||||
dna.branches[i].color = {r, g, b, 255};
|
||||
|
||||
dna.branches[i].numOfBranches = mrand::getValue(1, 3);
|
||||
|
||||
dna.branches[i].lenghthRatio = ((float)mrand::getValue(600, 700)) / 1000.0f;
|
||||
uint8_t *array = (uint8_t *)&dna.branches[i];
|
||||
for (size_t i = 0; i < sizeof(Branch); i++)
|
||||
{
|
||||
array[i] = mrand::getValue(0, 254);
|
||||
}
|
||||
}
|
||||
|
||||
dna.branches[0].color = dna.branches[1].color;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user