made tons of stuff lol
This commit is contained in:
parent
36f0dae96b
commit
54c3acf092
16 changed files with 450 additions and 94 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(games)
|
project(games)
|
||||||
SET(CMAKE_CXX_FLAGS "-std=c++23")
|
set(CMAKE_CXX_FLAGS "-std=c++17 -Wno-error")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(PLATFORM_DIR "windows")
|
set(PLATFORM_DIR "windows")
|
||||||
else()
|
else()
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
SET(CMAKE_CXX_FLAGS "-std=c++23 -Werror")
|
set(CMAKE_CXX_FLAGS "-std=c++17 -Wno-error")
|
||||||
file(GLOB_RECURSE ENGINE_SOURCES "src/*.cpp")
|
file(GLOB_RECURSE ENGINE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||||
add_library(enginend SHARED ${ENGINE_SOURCES})
|
add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/force_rebuild"
|
||||||
target_include_directories(enginend PUBLIC
|
COMMAND rm -f "${CMAKE_SOURCE_DIR}/link/libenginend.so"
|
||||||
${CMAKE_SOURCE_DIR}/include
|
COMMAND rm -rf "${CMAKE_SOURCE_DIR}/include/enginend"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
add_library(enginend SHARED ${ENGINE_SOURCES} "${CMAKE_BINARY_DIR}/force_rebuild")
|
||||||
target_link_directories(
|
target_link_directories(
|
||||||
enginend PUBLIC
|
enginend PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/link")
|
"${CMAKE_SOURCE_DIR}/link")
|
||||||
|
|
@ -32,4 +31,26 @@ foreach(HEADER ${HEADER_FILES})
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_DIR}"
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${DEST_DIR}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${HEADER}" "${DEST}"
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${HEADER}" "${DEST}"
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(test test.cpp)
|
||||||
|
|
||||||
|
set_target_properties(test PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/engine/test"
|
||||||
|
)
|
||||||
|
target_link_directories(
|
||||||
|
test PUBLIC
|
||||||
|
"${CMAKE_SOURCE_DIR}/link")
|
||||||
|
target_link_libraries(test PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/link/libenginend.so"
|
||||||
|
"${CMAKE_SOURCE_DIR}/link/libdesktopraylib.so"
|
||||||
|
)
|
||||||
|
target_include_directories(test PUBLIC
|
||||||
|
${CMAKE_SOURCE_DIR}/include
|
||||||
|
${CMAKE_SOURCE_DIR}/lib/raylib/build/raylib/include
|
||||||
|
)
|
||||||
|
target_include_directories(enginend PUBLIC
|
||||||
|
${CMAKE_SOURCE_DIR}/lib/raylib/build/raylib/include
|
||||||
|
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "gr.h"
|
#include "gr.h"
|
||||||
#include "aud.h"
|
#include "aud.h"
|
||||||
#include "program.h"
|
#include "program.h"
|
||||||
|
#include "scenes/scene.h"
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
#include <raylib.h>
|
|
||||||
#include "graph/window.h"
|
#include "graph/window.h"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
#include <raylib.h>
|
||||||
|
|
@ -1 +1,11 @@
|
||||||
#include "program.h"
|
#include "program.h"
|
||||||
|
|
||||||
|
long long calibrate() {
|
||||||
|
unsigned long long start = __rdtsc();
|
||||||
|
struct timespec ts;
|
||||||
|
ts.tv_sec = 0;
|
||||||
|
ts.tv_nsec = 100000000L; // 0.1 seconds
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
return (__rdtsc() - start) * 10;
|
||||||
|
}
|
||||||
|
const long long enginend::CPUCLOCK=calibrate();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,17 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#define CFG this->CONF()
|
#define CFG this->CONF()
|
||||||
|
#include <immintrin.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
namespace enginend{
|
||||||
|
extern const long long CPUCLOCK;
|
||||||
inline const char* COMMONCONFIG();
|
inline const char* COMMONCONFIG();
|
||||||
class program {
|
class program {
|
||||||
|
unsigned long long currenttick = __rdtsc();
|
||||||
|
unsigned long long currentframe = __rdtsc();
|
||||||
public:
|
public:
|
||||||
|
int tickrate;
|
||||||
|
int framerate;
|
||||||
program():client(false){}
|
program():client(false){}
|
||||||
program(bool isclient):client(isclient){}
|
program(bool isclient):client(isclient){}
|
||||||
virtual const char* CONF()=0;
|
virtual const char* CONF()=0;
|
||||||
|
|
@ -11,4 +20,23 @@ public:
|
||||||
virtual void tick()=0;
|
virtual void tick()=0;
|
||||||
virtual void draw()=0;
|
virtual void draw()=0;
|
||||||
virtual void exit()=0;
|
virtual void exit()=0;
|
||||||
};
|
bool shouldtick() {
|
||||||
|
unsigned long long now = __rdtsc();
|
||||||
|
unsigned long long interval = CPUCLOCK / tickrate;
|
||||||
|
if (now - currenttick >= interval) {
|
||||||
|
currenttick = now;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool shoulddraw() {
|
||||||
|
unsigned long long now = __rdtsc();
|
||||||
|
unsigned long long interval = CPUCLOCK / framerate;
|
||||||
|
if (now - currentframe >= interval) {
|
||||||
|
currentframe = now;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};}
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,251 @@
|
||||||
#include "nodes.h"
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct node2d :public node {
|
#include "nodes.h"
|
||||||
vec2 pos;
|
#include<tiny/term.h>
|
||||||
node2d(){}
|
|
||||||
node2d(float x,float y):pos(x,y){}
|
namespace enginend {
|
||||||
};
|
struct node2d :public node {
|
||||||
struct rect :virtual public node2d{
|
Vector2 pos;
|
||||||
vec2 size;
|
node2d(){}
|
||||||
rect(){}
|
node2d(float x,float y):pos(Vector2{x,y}){}
|
||||||
rect(float x,float y,float w, float h):size(w,h){
|
};
|
||||||
this->pos=vec2(x,y);
|
struct rect :virtual public node2d{
|
||||||
}
|
Vector2 size;
|
||||||
};
|
rect(){}
|
||||||
struct textured :virtual public rect{
|
rect(float x,float y,float w, float h):size(Vector2{w,h}){
|
||||||
int ID;
|
this->pos=Vector2{x,y};
|
||||||
textured(){}
|
}
|
||||||
textured(int id,float x,float y,float w, float h):ID(id){
|
};
|
||||||
this->pos=vec2(x,y);this->size=vec2(w,h);
|
struct textured :virtual public rect{
|
||||||
}
|
int ID;
|
||||||
};
|
textured(){}
|
||||||
struct colored :virtual public rect{
|
textured(int id,float x,float y,float w, float h):ID(id){
|
||||||
col c;
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};
|
||||||
colored(){}
|
}
|
||||||
colored(col color,float x,float y,float w, float h):c(color){
|
void boot()override{}
|
||||||
this->pos=vec2(x,y);this->size=vec2(w,h);
|
void tick()override{}
|
||||||
}
|
void draw()override{DrawTexture(LoadTexture(""),pos.x,pos.y,WHITE);}
|
||||||
};
|
void exit()override{}
|
||||||
struct tinted :virtual public colored, virtual public textured{
|
};
|
||||||
tinted(){}
|
struct colored :virtual public rect{
|
||||||
|
Color c;
|
||||||
tinted(int id,col color,float x,float y,float w, float h):
|
colored(){}
|
||||||
node2d(x, y),
|
colored(Color color,float x,float y,float w, float h):c(color){
|
||||||
rect(x, y, w, h),
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};
|
||||||
colored(color, x, y, w, h),
|
}
|
||||||
textured(id, x, y, w, h)
|
void boot()override{}
|
||||||
{
|
void tick()override{}
|
||||||
|
void draw()override{DrawRectangle(pos.x,pos.y,size.x,size.y,c);}
|
||||||
}
|
void exit()override{}
|
||||||
};
|
};
|
||||||
struct text :virtual tinted {
|
struct tinted :virtual public colored, virtual public textured{
|
||||||
Font font;
|
tinted(){}
|
||||||
std::string text;
|
tinted(int id,Color color,float x,float y,float w, float h):
|
||||||
};
|
node2d(x, y),
|
||||||
|
rect(x, y, w, h),
|
||||||
|
colored(color, x, y, w, h),
|
||||||
|
textured(id, x, y, w, h)
|
||||||
|
{}
|
||||||
|
void boot()override{this->colored::boot();this->textured::boot();}
|
||||||
|
void tick()override{this->colored::tick();this->textured::tick();}
|
||||||
|
void draw()override{DrawTexture(LoadTexture(""),pos.x,pos.y,c);}
|
||||||
|
void exit()override{this->colored::exit();this->textured::exit();}
|
||||||
|
};
|
||||||
|
struct text :public tinted {
|
||||||
|
protected:
|
||||||
|
std::string result;
|
||||||
|
public:
|
||||||
|
Font font;
|
||||||
|
float fontsize;
|
||||||
|
Color textcolor;
|
||||||
|
std::string content;
|
||||||
|
text(){ fontsize = 20; }
|
||||||
|
text(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt):
|
||||||
|
font(f),fontsize(fs),content(txt)
|
||||||
|
{
|
||||||
|
this->pos=Vector2{x,y};this->size=Vector2{w,h};this->ID=id;this->c=color;this->textcolor=textcol;
|
||||||
|
|
||||||
|
result=content;
|
||||||
|
size_t initpos = 0;
|
||||||
|
while((initpos = result.find("\n", initpos)) != std::string::npos) {
|
||||||
|
result.replace(initpos, 1, "\\n");
|
||||||
|
initpos += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void boot()override{this->tinted::boot();}
|
||||||
|
void tick()override {
|
||||||
|
this->tinted::tick();
|
||||||
|
if (result!=content) {
|
||||||
|
result=content;
|
||||||
|
size_t initpos = 0;
|
||||||
|
while((initpos = result.find("\n", initpos)) != std::string::npos) {
|
||||||
|
result.replace(initpos, 1, "\\n");
|
||||||
|
initpos += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void draw()override {
|
||||||
|
Vector2 minsize=MeasureTextEx(font, content.c_str(), fontsize, 1);
|
||||||
|
Vector2 charsize=MeasureTextEx(font, " ", fontsize, 1);
|
||||||
|
float p=charsize.x>charsize.y?charsize.x/minsize.x:charsize.y/minsize.y;
|
||||||
|
p=p*2;
|
||||||
|
int minh=(minsize.y>size.y)?minsize.y:size.y;
|
||||||
|
int minw=(minsize.x>size.x)?minsize.x:size.x;
|
||||||
|
DrawRectangle(pos.x-charsize.x,pos.y-charsize.y,minw+p,minh+p,c);
|
||||||
|
DrawTextEx(font, content.c_str(), pos, fontsize, 1, textcolor);
|
||||||
|
}
|
||||||
|
void exit()override{this->tinted::exit();}
|
||||||
|
};
|
||||||
|
struct button :virtual public tinted{
|
||||||
|
std::function<void()> function;
|
||||||
|
bool pressed;
|
||||||
|
button():pressed(false){}
|
||||||
|
button(int id,Color color,float x,float y,float w,float h,std::function<void()> func):function(func),pressed(false){
|
||||||
|
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->ID=id;this->c=color;
|
||||||
|
}
|
||||||
|
void boot()override{this->tinted::boot();}
|
||||||
|
void tick()override{
|
||||||
|
this->tinted::tick();
|
||||||
|
Vector2 mouse=GetMousePosition();
|
||||||
|
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})&&IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||||
|
if(function)function();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void draw()override{DrawRectangle(pos.x,pos.y,size.x,size.y,c);}
|
||||||
|
void exit()override{this->tinted::exit();}
|
||||||
|
};
|
||||||
|
struct slider :virtual public tinted{
|
||||||
|
float value;
|
||||||
|
float minvalue;
|
||||||
|
float maxvalue;
|
||||||
|
slider():value(0),minvalue(0),maxvalue(1){}
|
||||||
|
slider(int id,Color color,float x,float y,float w,float h,float min,float max,float val):value(val),minvalue(min),maxvalue(max){
|
||||||
|
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->ID=id;this->c=color;
|
||||||
|
}
|
||||||
|
void boot()override{this->tinted::boot();}
|
||||||
|
void tick()override{
|
||||||
|
this->tinted::tick();
|
||||||
|
Vector2 mouse=GetMousePosition();
|
||||||
|
if(CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y})&&IsMouseButtonDown(MOUSE_LEFT_BUTTON)){
|
||||||
|
float t=(mouse.x-pos.x)/size.x;
|
||||||
|
value=minvalue+t*(maxvalue-minvalue);
|
||||||
|
if(value<minvalue)value=minvalue;
|
||||||
|
if(value>maxvalue)value=maxvalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void draw()override{
|
||||||
|
DrawRectangle(pos.x,pos.y,size.x,size.y,DARKGRAY);
|
||||||
|
float t=(value-minvalue)/(maxvalue-minvalue);
|
||||||
|
DrawRectangle(pos.x,pos.y,size.x*t,size.y,c);
|
||||||
|
}
|
||||||
|
void exit()override{this->tinted::exit();}
|
||||||
|
};
|
||||||
|
struct textfield :public text{
|
||||||
|
textfield(){}
|
||||||
|
textfield(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs,std::string txt):
|
||||||
|
text(id,textcol,color,x,y,w,h,f,fs,txt){}
|
||||||
|
void boot()override{this->text::boot();}
|
||||||
|
void tick()override{this->text::tick();}
|
||||||
|
void draw()override{
|
||||||
|
Vector2 p=pos;
|
||||||
|
float lineheight=fontsize+2;
|
||||||
|
std::string line="";
|
||||||
|
Vector2 charsize=MeasureTextEx(font, " ", fontsize, 0);
|
||||||
|
Vector2 minsize=MeasureTextEx(font, content.c_str(), fontsize, charsize.x/2);
|
||||||
|
float po=charsize.x>charsize.y?charsize.x/charsize.y:charsize.y/charsize.x;po=po*5;
|
||||||
|
int minh=(minsize.y>size.y)?minsize.y:size.y;
|
||||||
|
int minw=(minsize.x>size.x)?minsize.x:size.x;
|
||||||
|
DrawRectangle(pos.x-(po/2),pos.y-(po/2),minw+(po*1.1),minh+(po*1.1),c);
|
||||||
|
DrawTextEx(font,content.c_str(),p,fontsize,charsize.x/2,this->textcolor);
|
||||||
|
}
|
||||||
|
void exit()override{this->text::exit();}
|
||||||
|
};
|
||||||
|
struct textinput :public text{
|
||||||
|
bool active;
|
||||||
|
int cursorpos;
|
||||||
|
textinput():active(false),cursorpos(0){}
|
||||||
|
textinput(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0){
|
||||||
|
this->pos=Vector2{x,y};this->size=Vector2{x,y};this->ID=id;this->c=color;this->font=f;this->content="";
|
||||||
|
this->textcolor=textcol;this->fontsize=fs;
|
||||||
|
}
|
||||||
|
void boot()override{this->text::boot();}
|
||||||
|
void tick()override{
|
||||||
|
this->text::tick();
|
||||||
|
Vector2 mouse=GetMousePosition();
|
||||||
|
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||||
|
active=CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y});
|
||||||
|
}
|
||||||
|
if(active){
|
||||||
|
int key=GetCharPressed();
|
||||||
|
while(key>0){
|
||||||
|
if(key>=32&&key<=125){
|
||||||
|
content+=static_cast<char>(key);
|
||||||
|
cursorpos++;
|
||||||
|
}
|
||||||
|
key=GetCharPressed();
|
||||||
|
}
|
||||||
|
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
||||||
|
content.pop_back();
|
||||||
|
cursorpos--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void draw()override{
|
||||||
|
this->text::draw();
|
||||||
|
if(active)DrawRectangle(pos.x+MeasureText(content.c_str(),fontsize),pos.y,2,fontsize,{0,0,0,127});
|
||||||
|
}
|
||||||
|
void exit()override{this->text::exit();}
|
||||||
|
};
|
||||||
|
struct textinputfield :public textfield{
|
||||||
|
bool active;
|
||||||
|
int cursorpos;
|
||||||
|
textinputfield():active(false),cursorpos(0){}
|
||||||
|
textinputfield(int id,Color textcol,Color color,float x,float y,float w,float h,Font f,float fs):active(false),cursorpos(0),
|
||||||
|
textfield(id,textcol,color,x,y,w,h,f,fs,""){}
|
||||||
|
void boot()override{this->textfield::boot();}
|
||||||
|
void tick()override{
|
||||||
|
this->textfield::tick();
|
||||||
|
Vector2 mouse=GetMousePosition();
|
||||||
|
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)){
|
||||||
|
active=CheckCollisionPointRec(mouse,{pos.x,pos.y,size.x,size.y});
|
||||||
|
}
|
||||||
|
if(active){
|
||||||
|
int key=GetCharPressed();
|
||||||
|
while(key>0){
|
||||||
|
if(key>=32&&key<=125){
|
||||||
|
content+=static_cast<char>(key);
|
||||||
|
cursorpos++;
|
||||||
|
}
|
||||||
|
key=GetCharPressed();
|
||||||
|
}
|
||||||
|
if(IsKeyPressed(KEY_BACKSPACE)&&content.length()>0){
|
||||||
|
content.pop_back();
|
||||||
|
cursorpos--;
|
||||||
|
}
|
||||||
|
if(IsKeyPressed(KEY_ENTER)){
|
||||||
|
content+='\n';
|
||||||
|
cursorpos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void draw()override{
|
||||||
|
this->textfield::draw();
|
||||||
|
if(active){
|
||||||
|
Vector2 p=pos;
|
||||||
|
float lineheight=fontsize+2;
|
||||||
|
std::string line="";
|
||||||
|
for(char ch:content){
|
||||||
|
if(ch=='\n'){
|
||||||
|
p.y+=lineheight;
|
||||||
|
line="";
|
||||||
|
}else{
|
||||||
|
line+=ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DrawRectangle(p.x+MeasureText(line.c_str(),fontsize),p.y,2,fontsize,BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void exit()override{this->textfield::exit();}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
|
#pragma once
|
||||||
#include "../gr.h"
|
#include "../gr.h"
|
||||||
#include "../aud.h"
|
#include "../aud.h"
|
||||||
#include "../net.h"
|
#include "../net.h"
|
||||||
struct node{
|
|
||||||
public:
|
namespace enginend {
|
||||||
|
struct node{
|
||||||
|
public:
|
||||||
|
|
||||||
virtual void init() {}
|
virtual void boot()=0;
|
||||||
virtual void render() {}
|
virtual void tick()=0;
|
||||||
virtual void update() {}
|
virtual void draw()=0;
|
||||||
virtual void close() {}
|
virtual void exit()=0;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,31 @@
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
struct scene{
|
|
||||||
std::list<node> nodes;
|
|
||||||
virtual void init() {}
|
namespace enginend {
|
||||||
virtual void render() {}
|
struct scene{
|
||||||
virtual void update() {}
|
std::list<enginend::node*> nodes;
|
||||||
virtual void close() {}
|
virtual void boot() {
|
||||||
};
|
for (enginend::node* n : nodes) {
|
||||||
|
n->boot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void draw() {
|
||||||
|
BeginDrawing();
|
||||||
|
for (enginend::node* n : nodes) {
|
||||||
|
n->draw();
|
||||||
|
}
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
virtual void tick() {
|
||||||
|
for (enginend::node* n : nodes) {
|
||||||
|
n->tick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void exit() {
|
||||||
|
for (enginend::node* n : nodes) {
|
||||||
|
n->exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
53
engine/test.cpp
Normal file
53
engine/test.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include <incmgr.h>
|
||||||
|
#include <raylib.h>
|
||||||
|
#include <enginend/scenes/node2d.h>
|
||||||
|
using namespace enginend;
|
||||||
|
class test:public program {
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool vsync = true;
|
||||||
|
scene s;
|
||||||
|
const char* CONF() final{return "test.tdf";}
|
||||||
|
test(){};
|
||||||
|
void boot() override {
|
||||||
|
SetConfigFlags(FLAG_VSYNC_HINT);
|
||||||
|
InitWindow(500,500,"test");
|
||||||
|
SetTargetFPS(GetMonitorRefreshRate(GetCurrentMonitor()));
|
||||||
|
this->tickrate=GetMonitorRefreshRate(GetCurrentMonitor());
|
||||||
|
s.nodes=std::list<node*>{
|
||||||
|
|
||||||
|
new colored(Color{255,255,255,255},0,0,500,500),
|
||||||
|
new textfield(0,Color{255,127,127,255},Color{127,127,127,255}
|
||||||
|
,100,100,220,32,GetFontDefault(),32,
|
||||||
|
"welcome to enginend!\n"
|
||||||
|
"hehe"
|
||||||
|
)
|
||||||
|
};
|
||||||
|
s.boot();
|
||||||
|
|
||||||
|
}
|
||||||
|
void tick() override {
|
||||||
|
if (shouldtick()) {
|
||||||
|
s.tick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void draw() override {
|
||||||
|
s.draw();
|
||||||
|
}
|
||||||
|
void exit() override {
|
||||||
|
s.exit();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tiny::ErrorLevel tiny::level{6};
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
tiny::startup((char*)"enginend test",(char*)"1.0");
|
||||||
|
test e;
|
||||||
|
e.boot();
|
||||||
|
while (!WindowShouldClose()) {
|
||||||
|
e.tick();
|
||||||
|
e.draw();
|
||||||
|
}
|
||||||
|
e.exit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
SET(CMAKE_CXX_FLAGS "-std=c++23")
|
set(CMAKE_CXX_FLAGS "-std=c++17 -Wno-error")
|
||||||
file(GLOB_RECURSE FORESPEND_SOURCES "src/*.cpp")
|
file(GLOB_RECURSE FORESPEND_SOURCES "src/*.cpp")
|
||||||
add_executable(forespend ${FORESPEND_SOURCES})
|
add_executable(forespend ${FORESPEND_SOURCES})
|
||||||
|
|
||||||
|
|
|
||||||
1
games/forespend/src/client/scenes/mainmenu.cpp
Normal file
1
games/forespend/src/client/scenes/mainmenu.cpp
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
#include "mainmenu.h"
|
||||||
6
games/forespend/src/client/scenes/mainmenu.h
Normal file
6
games/forespend/src/client/scenes/mainmenu.h
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#pragma once
|
||||||
|
#include <incmgr.h>
|
||||||
|
|
||||||
|
class mainmenu :public virtual scene{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#pragma GCC diagnostic ignored "-Wdelete-incomplete"
|
||||||
#ifndef TINYDATAFORMAT_H
|
#ifndef TINYDATAFORMAT_H
|
||||||
#define TINYDATAFORMAT_H
|
#define TINYDATAFORMAT_H
|
||||||
#define TINYDEFINEHEADER "0000_TDF_HEADER_DEFINE"
|
#define TINYDEFINEHEADER "0000_TDF_HEADER_DEFINE"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#pragma GCC diagnostic ignored "-Wvarargs"
|
||||||
#ifndef TINYTERM_H
|
#ifndef TINYTERM_H
|
||||||
#define TINYTERM_H
|
#define TINYTERM_H
|
||||||
|
|
||||||
|
|
@ -37,24 +38,24 @@ tiny::ErrorLevel tiny::level={1};
|
||||||
|
|
||||||
extern tiny::ErrorLevel level;
|
extern tiny::ErrorLevel level;
|
||||||
|
|
||||||
#define WHITE "\033[0m" /* White */
|
|
||||||
#define BLACK "\033[30m" /* Black */
|
const char* WHITE="\033[0m";
|
||||||
#define RED "\033[31m" /* Red */
|
const char* BLACK="\033[30m";
|
||||||
#define GREEN "\033[32m" /* Green */
|
const char* RED="\033[31m";
|
||||||
#define YELLOW "\033[33m" /* Yellow */
|
const char* GREEN="\033[32m";
|
||||||
#define BLUE "\033[34m" /* Blue */
|
const char* YELLOW="\033[33m";
|
||||||
#define MAGENTA "\033[35m" /* Magenta */
|
const char* BLUE="\033[34m";
|
||||||
#define CYAN "\033[36m" /* Cyan */
|
const char* MAGENTA="\033[35m";
|
||||||
#define WHITE "\033[37m" /* White */
|
const char* CYAN="\033[36m";
|
||||||
#define BGRED "\033[41m" /* Red */
|
const char* BGRED="\033[41m";
|
||||||
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
|
const char* BOLDBLACK="\033[1m\033[30m";
|
||||||
#define BOLDRED "\033[1m\033[31m" /* Bold Red */
|
const char* BOLDRED="\033[1m\033[31m";
|
||||||
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
|
const char* BOLDGREEN="\033[1m\033[32m";
|
||||||
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
|
const char* BOLDYELLOW="\033[1m\033[33m";
|
||||||
#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
|
const char* BOLDBLUE="\033[1m\033[34m";
|
||||||
#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
|
const char* BOLDMAGENTA="\033[1m\033[35m";
|
||||||
#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
|
const char* BOLDCYAN="\033[1m\033[36m";
|
||||||
#define BOLDWHITE "\033[1m\033[37m" /* Bold White */
|
const char* BOLDWHITE="\033[1m\033[37m";
|
||||||
#define ending \
|
#define ending \
|
||||||
mixer.append(info); mixer.append("\033[0m\n");\
|
mixer.append(info); mixer.append("\033[0m\n");\
|
||||||
const char * finalinfo=mixer.c_str();\
|
const char * finalinfo=mixer.c_str();\
|
||||||
|
|
@ -62,7 +63,7 @@ extern tiny::ErrorLevel level;
|
||||||
vfprintf (stdout, finalinfo, arg);\
|
vfprintf (stdout, finalinfo, arg);\
|
||||||
va_end (arg);
|
va_end (arg);
|
||||||
|
|
||||||
inline void echo(char * info,...){
|
inline void echo(const char * info,...){
|
||||||
if (level.value==4)
|
if (level.value==4)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
|
|
@ -73,36 +74,36 @@ inline void echo(char * info,...){
|
||||||
vfprintf (stdout, finalinfo, arg);
|
vfprintf (stdout, finalinfo, arg);
|
||||||
va_end (arg);}
|
va_end (arg);}
|
||||||
}
|
}
|
||||||
inline void warning( char * info,...){
|
inline void warning(const char * info,...){
|
||||||
if (level.value>=1)
|
if (level.value>=1)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
std::string mixer=YELLOW;ending
|
std::string mixer=YELLOW;ending
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void fatal( char * info,...){
|
inline void fatal(const char * info,...){
|
||||||
va_list arg;
|
va_list arg;
|
||||||
std::string mixer=BOLDWHITE+std::string(BGRED);ending
|
std::string mixer=BOLDWHITE+std::string(BGRED);ending
|
||||||
}
|
}
|
||||||
inline void error( char * info,...){
|
inline void error(const char * info,...){
|
||||||
if (level.value>=0)
|
if (level.value>=0)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
std::string mixer=BOLDRED;ending
|
std::string mixer=BOLDRED;ending
|
||||||
}}
|
}}
|
||||||
inline void success(char * info , ...){
|
inline void success(const char * info , ...){
|
||||||
if (level.value>=2)
|
if (level.value>=2)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
std::string mixer=GREEN;ending}
|
std::string mixer=GREEN;ending}
|
||||||
}
|
}
|
||||||
inline void message(char * info , ...){
|
inline void message(const char * info , ...){
|
||||||
if (level.value>=3)
|
if (level.value>=3)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
std::string mixer=BOLDWHITE;ending}
|
std::string mixer=BOLDWHITE;ending}
|
||||||
}
|
}
|
||||||
inline void startup(char* game,char*version){
|
inline void startup(const char* game,const char*version){
|
||||||
int lv=level.value;level.value=6;
|
int lv=level.value;level.value=6;
|
||||||
echo("%s %s",game,version);
|
echo("%s %s",game,version);
|
||||||
warning("be warned that");
|
warning("be warned that");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue