wont use customizable noise lol, too niche

This commit is contained in:
kin fuyuki 2026-02-22 22:45:30 -03:00
commit c60a0ce031
No known key found for this signature in database
GPG key ID: 0E4E8E519FB71401
16 changed files with 3620 additions and 281 deletions

View file

@ -30,8 +30,6 @@ target_include_directories(enginend PUBLIC
add_executable(test test.cpp) add_executable(test test.cpp)
set_target_properties(test PROPERTIES set_target_properties(test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/engine/test" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/engine/test"
) )
@ -45,14 +43,4 @@ target_link_libraries(test PRIVATE
target_include_directories(test PUBLIC target_include_directories(test PUBLIC
${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include
) )
add_executable(noisemake test.cpp) add_executable(noisemake test.cpp)
set_target_properties(noisemake PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/engine/noisedev"
)
target_include_directories(noisemake PUBLIC
${CMAKE_SOURCE_DIR}/include
)
target_link_libraries(noisemake PRIVATE
enginend
raylib
)

View file

@ -1,125 +0,0 @@
#include <enginend/engine.h>
#include <enginend/graph/noise.h>
#include <tiny/tdf.h>
Texture2D* noiseresult;
std::vector<enginend::nodes::node*>* gui=new std::vector<enginend::nodes::node*>{
new enginend::nodes::twod::textured(noiseresult,0,0,512,512),
new enginend::nodes::twod::text(NULL,enginend::DEFAULT,0,0,512,32,32,"")
};
class noiserenderer :public enginend::program{
public:
tiny::TDF_FILE* config;
std::string currentscript;
std::vector<std::string> scripts;
const char* CONF()override{return "scripts.tdf";}
Image noiseout;
std::string erroredscript="";
noiserenderer(){
enginend::DEFAULT->text={255,0,0,255};
config=new tiny::TDF_FILE;
config->filepath=(char*)this->CONF();
config->read();
boost::unordered_map<std::string,tiny::TDF_DATA>luascripts=*(config->getclass({"lua"}));
for (auto data:luascripts){
if (data.second.type==tiny::TDF_STR){
scripts.push_back(*static_cast<std::string*>(data.second.datapointer));
}
}
currentscript=scripts[0];
}
void boot() override{
SetConfigFlags(FLAG_VSYNC_HINT);
InitWindow(512, 512, "lua noise viewer");
noiseout=GenImageColor(512,512,{255,255,255,255});
this->currentscene=new enginend::scene();
this->tickrate=3;
this->framerate=3;
}
void tick() override {
(*(dynamic_cast<enginend::nodes::twod::text*>((*gui)[1]))).content=this->erroredscript;
(*(dynamic_cast<enginend::nodes::twod::text*>((*gui)[0]))).tick();
(*(dynamic_cast<enginend::nodes::twod::text*>((*gui)[1]))).tick();
}
void draw() override {
(*(dynamic_cast<enginend::nodes::twod::text*>((*gui)[0]))).draw();
(*(dynamic_cast<enginend::nodes::twod::text*>((*gui)[1]))).draw();
}
void exit() override{}
~noiserenderer() {};
};
void refreshstuf(noiserenderer *program,char *refreshtdf,char *refreshnoise);
int main() {
noiserenderer program;
program.boot();
struct timespec peepy;
long time=1000000000L/((long)(program.framerate));
char refreshtdf=program.config->getint({"tdfrefresh"});
char refreshnoise=program.config->getint({"refreshsecs"});
char checkrefresh=0,checkrefreshtdf=0,checkrefreshnoise=0;
peepy.tv_nsec=time;
peepy.tv_sec=0;
while (true) {
program.tick();
program.draw();
nanosleep(&peepy, nullptr);
if (++checkrefresh==3) {
checkrefresh=0;
if (++checkrefreshnoise==refreshnoise) {
checkrefreshnoise=0;
}
if (++checkrefreshtdf==refreshtdf) {
checkrefreshtdf=0;
refreshstuf(&program,&refreshtdf,&refreshnoise);
}
}
if (IsKeyDown(KEY_LEFT_ALT)&&IsKeyDown(KEY_F4)){break;}
}
program.exit();
}
void refreshstuf(noiserenderer *program,char *refreshtdf,char *refreshnoise){
tiny::TDF_FILE *tocheck=new tiny::TDF_FILE;
tocheck->filepath=(char*)program->CONF();
tocheck->read();
bool isequal=true;
if (tocheck->todelete.size()!=program->config->todelete.size())isequal=false;
else {
std::string og="";
std::string justread="";
program->config->crawl(program->config->data,&og);
tocheck->crawl(tocheck->data,&justread);
isequal=og==justread;
}
if (!isequal){
program->config->close();
delete program->config;
program->config=tocheck;
boost::unordered_map<std::string,tiny::TDF_DATA>luascripts=*(program->config->getclass({"lua"}));
for (auto data:luascripts){
if (data.second.type==tiny::TDF_STR){
program->scripts.push_back(*static_cast<std::string*>(data.second.datapointer));
}
}
*refreshtdf=program->config->getint({"tdfrefresh"});
*refreshnoise=program->config->getint({"refreshsecs"});
program->currentscript=program->scripts[0];
}
else {
tocheck->close();
delete tocheck;
}
}

View file

@ -1,40 +0,0 @@
#pragma once
struct buffer {
char**pixel;//rgba format
};
enum NOISETYPE {
CLOUD,
RANDOM,
};
enum DIMENSION {
ONE,TWO,THREE,FOUR
};
class noise {
public:
int freq;
int octave;
int amp;
NOISETYPE type;
DIMENSION dims;
noise(int freq,int octave, int amp, NOISETYPE type, DIMENSION dims):
freq(freq), octave(octave), amp(amp), type(type),dims(dims) {
}
/// to explain the image generator
/// \param x int
/// \param y int
/// ^ these here is the position the noise will start rendering
/// \param w
/// \param h
/// these are the image width and height. PLEASE DO NOT GET CONFUSED
buffer* gen(short w, short h,int x, int y);
};
buffer* cloud(noise* noise,short w, short h,int x, int y);
buffer* random(noise* noise, short w, short h,int x, int y);

View file

@ -1,10 +0,0 @@
#include "../noise.h"
class noiserandom:public noise {
};
noiserandom* createnoise() {
noiserandom* neo=new noiserandom();
return neo;
}

View file

@ -1,8 +0,0 @@
i refreshsecs 3
i tdfrefresh 5
i imagesize 512
{ lua
" CLOUD cloud
" NOISE noise
}

View file

@ -1,2 +1,2 @@
#include "graph/window.h" #include "graph/window.h"

View file

@ -1,24 +0,0 @@
#include "noise.h"
#include <cstddef>
Image* noise::gen(short w, short h, int x, int y) {
switch (this->type) {
case CLOUD:
return cloud(this,w, h, x, y);
case RANDOM:
return random(this,w, h, x, y);
default:
return nullptr;
}
}
Image* cloud(noise* noise,short w, short h,int x, int y) {
}
Image* random(noise* noise,short w, short h,int x, int y) {
}

View file

@ -1,40 +0,0 @@
#pragma once
struct buffer {
char**pixel;//rgba format
};
enum NOISETYPE {
CLOUD,
RANDOM,
};
enum DIMENSION {
ONE,TWO,THREE,FOUR
};
class noise {
public:
int freq;
int octave;
int amp;
NOISETYPE type;
DIMENSION dims;
noise(int freq,int octave, int amp, NOISETYPE type, DIMENSION dims):
freq(freq), octave(octave), amp(amp), type(type),dims(dims) {
}
/// to explain the image generator
/// \param x int
/// \param y int
/// ^ these here is the position the noise will start rendering
/// \param w
/// \param h
/// these are the image width and height. PLEASE DO NOT GET CONFUSED
buffer* gen(short w, short h,int x, int y);
};
buffer* cloud(noise* noise,short w, short h,int x, int y);
buffer* random(noise* noise, short w, short h,int x, int y);

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <utility>
#include <vector> #include <vector>
#include "../gr.h" #include "../gr.h"
@ -11,26 +12,27 @@
namespace nodes { namespace nodes {
struct node{ struct node{
public: enginend::theme*theme{};
enginend::theme* theme;
virtual void boot()=0; virtual void boot()=0;
virtual void tick()=0; virtual void tick()=0;
virtual void draw()=0; virtual void draw()=0;
virtual void exit()=0; virtual void exit()=0;
virtual ~node()=0;
}; };
} }
struct group : public virtual enginend::nodes::node { struct group : public virtual enginend::nodes::node {
std::vector<node*> children; std::vector<node*> children;
explicit group(std::vector<enginend::nodes::node *> nodes):children(nodes){}; explicit group(std::vector<enginend::nodes::node *> nodes):children(std::move(nodes)){};
void boot(){for (node* n: children){n->boot();}} void boot() override {for (node* n: children){n->boot();}}
void tick(){for (node* n: children){n->tick();}} void tick() override {for (node* n: children){n->tick();}}
void draw(){for (node* n: children){n->draw();}} void draw() override {for (node* n: children){n->draw();}}
void exit(){for (node* n: children){n->exit();}} void exit() override {for (node* n: children){n->exit();}}
}; };
typedef struct theme { struct theme {
Color booleanbutton[6],button[3],booleantext[6],buttontext[3],text,buttonborder[3],booleanborder[6],border,background Color booleanbutton[6],button[3],booleantext[6],buttontext[3],text,buttonborder[3],booleanborder[6],border,background
,textfieldbg ,textfieldbg
; ;

View file

@ -2,6 +2,7 @@
#include "nodes.h" #include "nodes.h"
#include "node2d.h" #include "node2d.h"
#include "node3d.h"
#include "node2drelative.h" #include "node2drelative.h"
#include <list> #include <list>

View file

@ -1 +0,0 @@
#include "game.h"

View file

@ -1,7 +0,0 @@
#pragma once
#include <enginend/engine.h>
class game :public virtual enginend::scene {
};

View file

@ -0,0 +1 @@
#include "entity.h"

View file

@ -0,0 +1,18 @@
#pragma once
#include <enginend/engine.h>
struct ENTITYTYPE {
enginend::nodes::trid::node3d* node;
bool ISBILLBOARD;
};
struct entity: enginend::nodes::node{
ENTITYTYPE self;
entity();
void boot()override;
void tick()override;
void draw()override;
void exit()override;
~entity();
};

View file

@ -0,0 +1,26 @@
#pragma once
#include <enginend/engine.h>
class world :public enginend::scene{
enginend::group *players;
enginend::group *entities;
enginend::group *buildings;
// server side
world() {
players=new enginend::group({});
entities=new enginend::group({});
nodes.push_back(players);
};
void tick() override;
~world();
Model terrain;
std::vector<Model*> buildingmodels;
std::vector<Model*> entitymodels;
std::vector<Model*> models;
// client side
void boot() override;
void draw() override;
void exit() override;
};

3558
include/misc/fastnoise.h Normal file

File diff suppressed because one or more lines are too long