This commit is contained in:
kin fuyuki 2026-02-22 03:57:10 -03:00
commit 78868f5b52
No known key found for this signature in database
GPG key ID: 0E4E8E519FB71401
13 changed files with 267 additions and 10 deletions

4
.gitmodules vendored
View file

@ -19,3 +19,7 @@
[submodule "lib/tiny-lua"] [submodule "lib/tiny-lua"]
path = lib/tiny-lua path = lib/tiny-lua
url = https://github.com/kin-fuyuki/tiny-lua.git url = https://github.com/kin-fuyuki/tiny-lua.git
[submodule "lib/luajit"]
path = lib/luajit
url = https://github.com/LuaJIT/LuaJIT.git
branch = v2.0

View file

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -w -Oz -g") set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -w -Oz -g -mavx2")
if (DEFINED PLATFORMNAME) if (DEFINED PLATFORMNAME)
SET(CURRPLATFORM ${PLATFORMNAME}) SET(CURRPLATFORM ${PLATFORMNAME})

View file

118
engine/noisedev/main.cpp Normal file
View file

@ -0,0 +1,118 @@
#include <enginend/engine.h>
#include <enginend/graph/noise.h>
#include <luajit/lua.hpp>
#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;
noiserenderer(){
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{}
void draw() override {
}
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

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

View file

@ -0,0 +1,22 @@
#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) {
}

32
engine/src/graph/noise.h Normal file
View file

@ -0,0 +1,32 @@
#pragma once
#include "window.h"
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
Image* gen(short w, short h,int x, int y);
};
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

@ -7,7 +7,7 @@ else ()
endif (DEFINED PLATFORMNAME) endif (DEFINED PLATFORMNAME)
set(CMAKE_CXX_FLAGS "-std=c++11 -w -g -Wno-error -O0") set(CMAKE_CXX_FLAGS "-std=c++11 -w -g -Wno-error -Oz -mavx2")
file(GLOB_RECURSE ENDLAUNCHER "src/*.cpp") file(GLOB_RECURSE ENDLAUNCHER "src/*.cpp")
add_executable(endlauncher ${ENDLAUNCHER}) add_executable(endlauncher ${ENDLAUNCHER})

View file

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20) cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -Oz -w -g") set(CMAKE_CXX_FLAGS "-std=c++26 -Wno-error -Oz -w -g -mavx2")
file(GLOB_RECURSE FORESPEND_SOURCES CONFIGURE_DEPENDS "src/*.cpp") file(GLOB_RECURSE FORESPEND_SOURCES CONFIGURE_DEPENDS "src/*.cpp")
add_executable(forespend ${FORESPEND_SOURCES}) add_executable(forespend ${FORESPEND_SOURCES})
if(NOT DEFINED ${ARCH}) if(NOT DEFINED ${ARCH})

View file

@ -1,7 +1,80 @@
# kin, if ur seeing this, please me of future.. complete the colors ;w;
# please look in the reference for the image result while reading this on res/npcs/canidmonstertutorial.png
# and canidmonster/*.png to see how it works on the spritesheet
# how to use this file
# here is the entity name:
" type canidmonster " type canidmonster
{ proccol # color ranges have the colors per color mask, from min to max during
i r 255 # noise generation
i g 0 { sprite
i b 255 # emote definition (yes, defines can have space :3c)
stare around
look down
breathe
# folder where the sprites will be
" folder canidmonster
# fb: front back | lr: left right | ud: up down
i fb-framew 32
i fb-frameh 128
# note: i recommend 2x width on the side view in case of the running animation being wide
# well this is mostly for vertically standing beings, for horizontal then do whatever
i lr-framew 64
i lr-frameh 128
i ud-framew 64
i ud-frameh 32
# frame count, not defined animations wont be loaded
i idle 4
i walk 8
i run 8
i swim 8
}
{ colorranges
# define range names
1
2
3
shiny
# if generate a shiny one, all colors must be the same
{ forcedequals
shiny
}
# the class name will be the color used as mask, if you use a color range, then the color generated
# will be a tint over the existing texture instead of full replacement. it will overlay one another
# ex color range:
#{ aaaaaa-ffffff
# in this example, the color ffffff is the belly
{ ffffff
# here we set which noise, this is an optional setting since it wont do noise if you dont set
# it will just use the first color for the range
" noise random
# here you set if you want it to repeat, if yes then it will use the 4d torus technique to seamlessly repeat
# 20 here is horizontal, 10 is vertical
#" param repeat 20 10
i frequency 1
i amplitude 1
i octave 1
# now we finally define the ranges, the name is the range between 1.0 and 0.0
# this have a 2d range format.
# x_y.y
# x is the name of the range, since you could have multiple color ranges
# this range for example is good for gray fur with brown spots
h 1_0.35 777777
h 1_0.3 bbbbbb
h 1_0.29 6b4422
h ezra_0.0 ffffff
# also you can make ranges glow! (not be affected by ambient light)
{ glow
3
}
}
# end of range ffffff
} }

1
lib/luajit Submodule

@ -0,0 +1 @@
Subproject commit 5db4b03aeaf0f72eb817b468461b896466f820fd

@ -1 +1 @@
Subproject commit 2707a41755ffdecbde19775c84ea4097bb72b587 Subproject commit 1d60210e1b3487c4d1b1f48e28174b8521940f65

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
folders=("engine/src" "lib/raylib/include" "lib/tiny/inc") folders=("engine/src" "lib/raylib/include" "lib/tiny/inc" "lib/luajit/inc")
names=("enginend" "raylib" "tiny") names=("enginend" "raylib" "tiny" "luajit")
outdir="include" outdir="include"
types=("h" "hpp") types=("h" "hpp")