starting the rewrite of forespend.

This commit is contained in:
kin fuyuki 2025-12-25 13:21:58 -03:00
commit d36dc68f8a
No known key found for this signature in database
GPG key ID: 0E4E8E519FB71401
19 changed files with 833 additions and 290 deletions

View file

@ -7,7 +7,7 @@
#include <chrono>
using namespace enginend;
using namespace enginend::nodes;
netio nete{};
/*
@ -111,7 +111,6 @@ public:
Texture2D buttonslabel[8];
Font gamename,changelog,information;
bool vsync=true;
scene s;
RenderTexture2D target;
text version;
std::string selectedversion="";
@ -169,7 +168,7 @@ public:
playbtn[0]=LoadTexture("res/playoff.png");
playbtn[1]=LoadTexture("res/playon.png");
playbutton= new button(&playbtn[0], {255,255,255,255},406,(18*11)+17+9,153,59,std::function<void()>(playbuttonfunc));
s.nodes=std::list<node*>{
currentscene->nodes=std::list<node*>{
new background(&bg,0,0,600,300),
new textured(&buttonfore,3,36,62,62),
new textured(&buttonlock,3,36+((62+4)*1),62,62),
@ -189,7 +188,7 @@ public:
new text(nullptr,Color{255,255,255,255},Color{0,0,0,0},96+16,(16*14)-3,1,1,information,20,"downloaded verified"),
&version,
};
s.boot();
currentscene->boot();
}
int buttondelay=0;
void tick() override {
@ -234,14 +233,14 @@ public:
}
}
}
s.tick();
currentscene->tick();
buttondelay--;
}
bool changedmenu=true;
bool itemchanged=true;
void draw() override {
BeginTextureMode(target);
s.draw();
currentscene->draw();
EndTextureMode();
BeginDrawing();
ClearBackground(BLANK);
@ -267,7 +266,7 @@ public:
}
}
void exit() override {
s.exit();
currentscene->exit();
}
};

View file

@ -1,9 +1,35 @@
#include "client.h"
client::client(){}
void client::boot() {}
void client::draw() {}
void client::exit() {}
void client::tick() {}
#include "scenes/mainmenu.h"
client::client() {
}
void client::boot() {
this->framerate=60;
this->tickrate=20;
InitWindow(380,240,"forespend - 0.03h");
// SetConfigFlags();
this->currentscene=new mainmenu();
this->currentscene->boot();
target=LoadRenderTexture(380,240);
}
void client::draw() {
BeginTextureMode(target);
this->currentscene->draw();
EndTextureMode();
BeginDrawing();
ClearBackground(WHITE);
DrawTexturePro(target.texture, {0, 0, 380,240}, {0, 0, (float)GetScreenWidth(), (float)GetScreenHeight()}, {0, 0}, 0, WHITE);
EndDrawing();
}
void client::exit() {
this->currentscene->exit();
delete this->currentscene;
}
void client::tick() {
this->currentscene->tick();
}

View file

@ -1,9 +1,10 @@
#pragma once
#include <incmgr.h>
class client :public program{
class client :public enginend::program{
public:
RenderTexture2D target;
const char* CONF() final{return "client.tdf";}
client();
void boot() override;

View file

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

View file

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

View file

@ -1 +1 @@
#include "mainmenu.h"
#include "mainmenu.h"

View file

@ -1,6 +1,22 @@
#pragma once
#include <incmgr.h>
#include <enginend/scenes/node2drelative.h>
class mainmenu :public virtual scene{
class mainmenu :public virtual enginend::scene{
public:
void boot() override {
this->nodes=std::list<enginend::nodes::node*>{
new enginend::nodes::relative::animated(AT("res/images/sky.gif"),0,0,10,10,5)
};
enginend::scene::boot();
}
void tick() override {
enginend::scene::tick();
}
void draw() override {
enginend::scene::draw();
}
void exit() override {
enginend::scene::exit();
}
};

View file

@ -1,11 +1,57 @@
#include <atomic>
#include <incmgr.h>
#include <thread>
#include "server/server.h"
#include "client/client.h"
PLATFORM platform=LINUX;
std::string androidpackage="kn.kinfuyuki.forespend";
inline const char* COMMONCONFIG(){return "common.tdf";}
tiny::ErrorLevel tiny::level{6};
int main(int argc, char** argv) {
enginend::program* game;
tiny::startup("forespend","0.03g-rewrite");
bool isserver = false;
if (argc>1) {
for (int i=1;i<argc;i++) {
if (argv[i]=="server") {
isserver = true;
}
}
}
if (isserver) game = new server();else game = new client();
game->boot();
std::atomic<bool> running{true};
std::thread tickthread([game, &running]() {
double tickrate=1.0/game->tickrate;
auto lasttick=std::chrono::high_resolution_clock::now();
while (running) {
auto now=std::chrono::high_resolution_clock::now();
double elapsed=std::chrono::duration_cast<std::chrono::duration<double>>(now-lasttick).count();
if (elapsed>=tickrate) {
game->tick();
lasttick=now;
} else {
std::this_thread::sleep_for(std::chrono::duration<double>(tickrate-elapsed));
}
}
});
double framerate=1.0/game->framerate;
auto lastframe=std::chrono::high_resolution_clock::now();
while (!WindowShouldClose()) {
auto now=std::chrono::high_resolution_clock::now();
double elapsed=std::chrono::duration_cast<std::chrono::duration<double>>(now-lastframe).count();
if (elapsed>=framerate) {
game->draw();
lastframe=now;
} else {
WaitTime(framerate-elapsed);
}
}
game->exit();
return 0;
}

View file

@ -2,7 +2,7 @@
#include <incmgr.h>
class server : public program{
class server : public enginend::program{
public:
server();
const char* CONF() final{return "client.tdf";}