Skip to content

Commit

Permalink
added gravity; broke camera colors bitrotted
Browse files Browse the repository at this point in the history
  • Loading branch information
GeneralGuy4872 committed Jan 11, 2021
1 parent 28fc780 commit 156751d
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 51 deletions.
6 changes: 3 additions & 3 deletions geography.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ that converts solar wind into an antigravity ridge which keeps the ring
centered (antigravity, of course being the technical term for the force
exerted by matter with negitive mass...no?). elemental planes and the prime
plane are connected by wormholes, whose apetures travel forward in time
at 1m/s/s, and are also always in the same 3-dimensional moment-slice of
the universe; these usually contain a bridge so that objects traversing
them do not get tidally shredded by straying from a safe path.
at 1s/s and are also always in the same moment-slice of the multiverse;
these usually contain a bridge so that objects traversing them do not get
tidally shredded by straying from a safe path.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"human","","s"},{"el","f","ves"},{"dwarf","","s"},{"gnome","","s"},{"hobbit","","s"},{"half el","f","ves"},{"drow","",""},{"or,"c","ks"},{"half or","c","ks"},{"half dragon","","s"},/*half celestial*/,{"tiefling","","s"},{"half air elemental","","s"},{"half water elemental","","s"},{"half earth elemental","","s"},{"half fire elemental","","s"},
{"merfolk","",""},{"sea el","f","ves"},{"satyr","","es"},{"fair","y","ies"},{"pixie","","s"},{"naiad","","s"},{"wood el","f","ves"},{"dryad","","s"},{"naga","","s"},{"kobald","","s"},{"centaur","","s"},{"sphinx","","es"},{"half electric elemental","","s"},{"half ice elemental","","s"},{"half nature elemental","","s"},{"half metal elemental","","s"},
{"siren","","s"},{"harp","y","ies"},{"eriny","s","es"},{"ker","r","es"},{"cecaelia","","e"},{"drider","","s"},{"scorpio","","nes"},{"manticore","",""},

32 changes: 32 additions & 0 deletions src/alpha/NOTE
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SOLID BODY (NOT ELASTIC) FOR PLAYER

---

Drop voxel-style terrain use geom-style terrain and offload live
organization to Irrlicht; static data file for a geom is:

unsigned char : red
unsigned char : green
unsigned char : blue
unsigned char : alpha
unsigned char : metallic
unsigned char : softness
unsigned char : lightsource
unsigned q16.16 : size x
unsigned q16.16 : size y
unsigned q16.16 : size z
unsigned char : x resolution
unsigned char : y resolution
unsigned char : z resolution
unsigned q16.16 [x res][y res]
unsigned q16.16 [x res][z res]
unsigned q16.16 [y res][z res]

data file is read into memory as needed just like a texture would be

---

characters and entities should display as sprites for now (set of 24); low-
poly hitbox can be added


8 changes: 8 additions & 0 deletions src/alpha/modularized/eventloop.incplusplus
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ class MainEventReciever : public irr::IEventReceiver {
CHECKPOINT(THREAD__EVENT,__LINE__);
} break;

case irr::KEY_KEY_Q : {
CHECKPOINT(THREAD__EVENT,__LINE__);
pthread_mutex_lock(&CAMLOCK);
puts("working");
pthread_mutex_unlock(&CAMLOCK);
CHECKPOINT(THREAD__EVENT,__LINE__);
} break;

case irr::KEY_KEY_S : {
CHECKPOINT(THREAD__EVENT,__LINE__);
pthread_mutex_lock(&CAMLOCK);
Expand Down
5 changes: 5 additions & 0 deletions src/alpha/modularized/globals.incplusplus
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pthread_mutex_t JITTER_ADV_LOCK = PTHREAD_MUTEX_INITIALIZER;
float JITTER_ADVERAGE;
typedef std::map<char,irr::scene::IMeshSceneNode *> NODES_t;
NODES_t NODES;
double (*PLAYER_VELOCITY)[4];
irr::core::vector3df PLAYER_POS_BUFFER;
irr::core::vector3df CAMERA_POS_BUFFER;
bool * CAMERA_MANUAL_OVERRIDE;

#define THREAD__MAIN 0
#define THREAD__EVENT 1
Expand All @@ -19,6 +23,7 @@ std::atomic_int EXELINE[THREADCOUNT];
#define CHECKPOINT(X,Y) EXELINE[X] = Y

irr::scene::ICameraSceneNode * CAMERA;
irr::scene::IMeshSceneNode * PLAYER;
pthread_mutex_t CAMLOCK = PTHREAD_MUTEX_INITIALIZER;
std::atomic_bool STEALCURSOR;
std::atomic_bool YINVERT;
39 changes: 39 additions & 0 deletions src/alpha/modularized/irrcontext.incplusplus
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,47 @@ namespace irrcontext {
irr::gui::IGUIEnvironment * guienv;
irr::scene::IMeshManipulator * meshmanipr;
irr::gui::ICursorControl * cursctrl;
irr::scene::IMetaTriangleSelector * trisel;
irr::scene::ISceneNodeAnimator * colresanim;
std::map<irr::scene::IMeshSceneNode *,irr::scene::ITriangleSelector *> dictionary;
irr::ITimer * timer;
double deltatime;
uint32_t then;
uint32_t now;
}

namespace IWF {
namespace FUNC {

::irr::scene::IMeshSceneNode * initcube (float size = 10,::irr::scene::ISceneNode * parent = NULL,::irr::core::vector3df position = ::irr::core::vector3df(0,0,0),::irr::core::vector3df rotation = ::irr::core::vector3df(0,0,0),::irr::core::vector3df scale = ::irr::core::vector3df(1,1,1)) {
irr::scene::IMeshSceneNode * retval = ::irrcontext::smgr->addCubeSceneNode(size,parent,-1,position,rotation,scale);
irr::scene::ITriangleSelector * tri = ::irrcontext::smgr->createTriangleSelector(retval->getMesh(),retval);
retval->setTriangleSelector(tri);
::irrcontext::trisel->addTriangleSelector(tri);
::irrcontext::dictionary[retval] = tri;
return retval;
}

::irr::scene::IMeshSceneNode * initcubef (float size = 10,::irr::scene::ISceneNode * parent = NULL,float positionx = 0, float positiony = 0, float positionz = 0,float rotationx = 0, float rotationy = 0, float rotationz = 0,float scalex = 1, float scaley = 1, float scalez = 1) {
irr::core::vector3df position = {positionx,positiony,positionz};
irr::core::vector3df rotation = {rotationx,rotationy,rotationz};
irr::core::vector3df scale = {scalex,scaley,scalez};
return ::IWF::FUNC::initcube(size,parent,position,rotation,scale);
}

::irr::scene::IMeshSceneNode * initidcube (float size = 10,::irr::scene::ISceneNode * parent = NULL,int32_t id = -1,::irr::core::vector3df position = ::irr::core::vector3df(0,0,0),::irr::core::vector3df rotation = ::irr::core::vector3df(0,0,0),::irr::core::vector3df scale = ::irr::core::vector3df(1,1,1)) {
irr::scene::IMeshSceneNode * retval = ::irrcontext::smgr->addCubeSceneNode(size,parent,id,position,rotation,scale);
irr::scene::ITriangleSelector * tri = ::irrcontext::smgr->createTriangleSelector(retval->getMesh(),retval);
retval->setTriangleSelector(tri);
::irrcontext::trisel->addTriangleSelector(tri);
::irrcontext::dictionary[retval] = tri;
return retval;
}

::irr::scene::IMeshSceneNode * initidcubef (float size = 10,::irr::scene::ISceneNode * parent = NULL,int32_t id = -1,float positionx = 0, float positiony = 0, float positionz = 0,float rotationx = 0, float rotationy = 0, float rotationz = 0,float scalex = 1, float scaley = 1, float scalez = 1) {
irr::core::vector3df position = {positionx,positiony,positionz};
irr::core::vector3df rotation = {rotationx,rotationy,rotationz};
irr::core::vector3df scale = {scalex,scaley,scalez};
return ::IWF::FUNC::initidcube(size,parent,id,position,rotation,scale);
}
}}
46 changes: 27 additions & 19 deletions src/alpha/modularized/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* prealpha *
**************/

#define SNAPSHOT "AFTERNOON/07/AUG/2020"
#define SNAPSHOT "NIGHT/10/JAN/2021"

/* this program currently requires a second terminal to be used; this is
* done by passing the terminal's device file (which can be obtained with
Expand Down Expand Up @@ -78,6 +78,8 @@ SYSINT initialize (char *argv[]) {
setvbuf(stdout, NULL, _IONBF, 0);
SCRAM = 0;
JITTERMAX = 0xF;
PLAYER_VELOCITY = calloc(3,sizeof(double));
CAMERA_MANUAL_OVERRIDE = calloc(1,sizeof(bool));

pthread_create(&iwf$$threads$$curses,NULL,iwf$$threads$$curses$$function,argv);
pthread_create(&iwf$$threads$$jitterbug,NULL,iwf$$threads$$jitterbug$$loop,NULL);
Expand All @@ -91,23 +93,21 @@ SYSINT initialize (char *argv[]) {
irrcontext::meshmanipr = irrcontext::smgr->getMeshManipulator();
irrcontext::cursctrl = irrcontext::device->getCursorControl();
irrcontext::timer = irrcontext::device->getTimer();
irrcontext::trisel = irrcontext::smgr->createMetaTriangleSelector();

irrcontext::guienv->addStaticText(L"IWannaFly Devtest prealpha snapshot " SNAPSHOT,irr::core::rect<irr::s32>(10,10,260,22),1);
CAMERA = irrcontext::smgr->addCameraSceneNode(NULL,irr::core::vector3df(0,0,0),irr::core::vector3df(1,1,1));
CAMERA->setUpVector(irr::core::vector3df(0,0,1));
PLAYER = IWF::FUNC::initidcube(.4,NULL,20);
irrcontext::colresanim = irrcontext::smgr->createCollisionResponseAnimator(irrcontext::trisel,CAMERA,irr::core::vector3df(.2,.2,.2),irr::core::vector3df(0,0,-0.98),irr::core::vector3df(0,0,0.001));
PLAYER->addAnimator(irrcontext::colresanim);
irrcontext::meshmanipr->setVertexColors(PLAYER->getMesh(),RGBColor(0x55,0x55,0xFF));

for (int x = -1;x < 2;x += 1) {
for (int y = -1;y < 2;y += 1) {
for (int z = -1;z < 2;z += 1) {
if (x || y || z) {
irr::scene::IMeshSceneNode * tmp = irrcontext::smgr->addCubeSceneNode(
10.0,
NULL,
((z * 9) + (y * 3) + x),
irr::core::vector3df(
(x * 25),
(y * 25),
(z * 25)));
irr::scene::IMeshSceneNode * tmp = IWF::FUNC::initidcubef(10.0,NULL,((z * 9) + (y * 3) + x),(x * 25),(y * 25),(z * 25));
NODES[(z * 9) + (y * 3) + x] = tmp;
}}}}
irrcontext::smgr->addLightSceneNode();
Expand All @@ -125,23 +125,31 @@ main (int argc, char *argv[]) {
while (irrcontext::device->run()) {
JITTER = 0;
if (SCRAM) exit(0);
CHECKPOINT(THREAD__MAIN,__LINE__);
pthread_mutex_lock(&CAMLOCK);
if (*CAMERA_MANUAL_OVERRIDE) {
CAMERA->setPosition(irr::core::vector3df(0,0,0));
(*CAMERA_MANUAL_OVERRIDE) = false;
}
CAMERA->setTarget(CAMCOORD.euclid());
CAMERA_POS_BUFFER = CAMERA->getPosition();
PLAYER_POS_BUFFER = PLAYER->getPosition();
{
irr::core::vector3df tmp = PLAYER->getPosition();
tmp.X = tmp.X + (*PLAYER_VELOCITY)[0];
tmp.Y = tmp.Y + (*PLAYER_VELOCITY)[1];
tmp.Z = tmp.Z + (*PLAYER_VELOCITY)[2];
PLAYER->setPosition(tmp);
CAMERA->setPosition(tmp);
}
pthread_mutex_unlock(&CAMLOCK);
CHECKPOINT(THREAD__MAIN,__LINE__);
irrcontext::driver->beginScene(true, true, RGBAColor(0,0,0xAA,0xF0));
CHECKPOINT(THREAD__MAIN,__LINE__);
irrcontext::driver->beginScene(true, true, RGBAColor(0,0,0x55,0xEE));
irrcontext::smgr->drawAll();
CHECKPOINT(THREAD__MAIN,__LINE__);
irrcontext::guienv->drawAll();
CHECKPOINT(THREAD__MAIN,__LINE__);
irrcontext::driver->endScene();
CHECKPOINT(THREAD__MAIN,__LINE__);
(*PLAYER_VELOCITY)[0] = ((int)(((*PLAYER_VELOCITY)[0] / 2) * 1000000)) / 1000000.0; //if this underflows, then the optimizer is screwing you
(*PLAYER_VELOCITY)[1] = ((int)(((*PLAYER_VELOCITY)[1] / 2) * 1000000)) / 1000000.0;
(*PLAYER_VELOCITY)[2] = ((int)(((*PLAYER_VELOCITY)[2] / 2) * 1000000)) / 1000000.0;
irrcontext::now = irrcontext::timer->getTime();
CHECKPOINT(THREAD__MAIN,__LINE__);
irrcontext::deltatime = (irrcontext::now - irrcontext::then) / 1000.0;
CHECKPOINT(THREAD__MAIN,__LINE__);
irrcontext::then = irrcontext::now;
CHECKPOINT(THREAD__MAIN,__LINE__);
}}
20 changes: 20 additions & 0 deletions src/alpha/modularized/maineventloop.incplusplus
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ class MainEventReciever : public irr::IEventReceiver {
CHECKPOINT(THREAD__EVENT,__LINE__);
switch (event.KeyInput.Key) {

case irr::KEY_SPACE : {
CHECKPOINT(THREAD__EVENT,__LINE__);
pthread_mutex_lock(&CAMLOCK);
if ((*PLAYER_VELOCITY)[2]) {
(*PLAYER_VELOCITY)[2] = 1 + (1 / (*PLAYER_VELOCITY)[2]);
} else {
(*PLAYER_VELOCITY)[2] = 1;
}
pthread_mutex_unlock(&CAMLOCK);
CHECKPOINT(THREAD__EVENT,__LINE__);
} break;

case irr::KEY_KEY_Q : {
CHECKPOINT(THREAD__EVENT,__LINE__);
pthread_mutex_lock(&CAMLOCK);
(*CAMERA_MANUAL_OVERRIDE) = true;
pthread_mutex_unlock(&CAMLOCK);
CHECKPOINT(THREAD__EVENT,__LINE__);
} break;

case irr::KEY_KEY_W : {
CHECKPOINT(THREAD__EVENT,__LINE__);
pthread_mutex_lock(&CAMLOCK);
Expand Down
68 changes: 39 additions & 29 deletions src/alpha/modularized/ncursesthread.incplusplus
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ void * iwf$$threads$$curses$$function (void * input) {
noecho();
keypad(NULL,1);

mvprintw(3,3,"IWannaFly");
mvprintw(4,4,"prealpha devtest");
mvprintw(5,5,"revision snapshot:");
mvprintw(6,5,SNAPSHOT);
mvprintw(2,3,"IWannaFly");
mvprintw(3,4,"prealpha devtest");
mvprintw(4,5,"revision snapshot:");
mvprintw(4,5,SNAPSHOT);

irr::core::vector3df placeholder;
float placeholder2;
Expand All @@ -36,37 +36,47 @@ void * iwf$$threads$$curses$$function (void * input) {
int tmp5;

for (;;sleep(1)) {
CHECKPOINT(THREAD__NCURSES,__LINE__);
pthread_mutex_lock(&CAMLOCK);
mvprintw(8,8,"camera azimuth : % 15.10f°",CAMCOORD.az * (180 / M_PI));
mvprintw(9,8,"camera elevation : % 15.10f°",CAMCOORD.el * (180 / M_PI));
mvprintw(11,8,"camera basis vector:");
mvprintw(6,8,"camera azimuth : % 15.10f°",CAMCOORD.az * (180 / M_PI));
mvprintw(7,8,"camera elevation : % 15.10f°",CAMCOORD.el * (180 / M_PI));

mvprintw(8,8,"camera basis vector:");
placeholder = CAMCOORD.euclid();
pthread_mutex_unlock(&CAMLOCK);
CHECKPOINT(THREAD__NCURSES,__LINE__);
mvprintw(12,10,"% 12.10fx",placeholder.X);
mvprintw(13,10,"% 12.10fy",placeholder.Y);
mvprintw(14,10,"% 12.10fz",placeholder.Z);
mvprintw(16,8,"cursor grabbed? >%s",STEALCURSOR ? "yes" : "no ");
CHECKPOINT(THREAD__NCURSES,__LINE__);
mvprintw(9,10,"% 12.10fx",placeholder.X);
mvprintw(9,35,"% 12.10fy",placeholder.Y);
mvprintw(9,60,"% 12.10fz",placeholder.Z);

mvprintw(11,8,"camera position:");
pthread_mutex_lock(&CAMLOCK);
placeholder = CAMERA_POS_BUFFER;
pthread_mutex_unlock(&CAMLOCK);
mvprintw(12,10,"% 15.10fx",placeholder.X);
mvprintw(12,35,"% 15.10fy",placeholder.Y);
mvprintw(12,60,"% 15.10fz",placeholder.Z);

mvprintw(14,8,"player position:");
pthread_mutex_lock(&CAMLOCK);
placeholder = PLAYER_POS_BUFFER;
pthread_mutex_unlock(&CAMLOCK);
mvprintw(15,10,"% 15.10fx",placeholder.X);
mvprintw(15,35,"% 15.10fy",placeholder.Y);
mvprintw(15,60,"% 15.10fz",placeholder.Z);

mvprintw(17,8,"player velocity:");
pthread_mutex_lock(&CAMLOCK);
mvprintw(18,10,"% 15.10fx",(*PLAYER_VELOCITY)[0]);
mvprintw(18,35,"% 15.10fy",(*PLAYER_VELOCITY)[1]);
mvprintw(18,60,"% 15.10fz",(*PLAYER_VELOCITY)[2]);
pthread_mutex_unlock(&CAMLOCK);

mvprintw(20,8,"cursor grabbed? >%s",STEALCURSOR ? "yes" : "no ");

pthread_mutex_lock(&JITTER_ADV_LOCK);
mvprintw(17,8,"adverage jitter : %4.4f",JITTER_ADVERAGE);
mvprintw(21,8,"adverage jitter : %4.4f",JITTER_ADVERAGE);
pthread_mutex_unlock(&JITTER_ADV_LOCK);

CHECKPOINT(THREAD__NCURSES,__LINE__);
tmp = JITTERMAX;
mvprintw(18,8,"(max jitter : %3i)",tmp);
CHECKPOINT(THREAD__NCURSES,__LINE__);

tmp0 = EXELINE[0];
tmp1 = EXELINE[1];
tmp2 = EXELINE[2];
tmp4 = EXELINE[4];
tmp5 = EXELINE[5];
CHECKPOINT(THREAD__NCURSES,__LINE__);
mvprintw(20,8,"line of execution : % 4i % 4i % 4i SELF % 4i % 4i",tmp0,tmp1,tmp2,tmp4,tmp5);
mvprintw(22,8,"(max jitter : %3i)",tmp);

CHECKPOINT(THREAD__NCURSES,__LINE__);
refresh();
CHECKPOINT(THREAD__NCURSES,__LINE__);
}};
Loading

0 comments on commit 156751d

Please sign in to comment.