
#include "spec.h"


/*
back to terminal rain
i have more colors !!!
*/

void LightFilter(){
/*
will override Pth, Plt, Prnt to pass through a light filter
declare you light source
and plot over, the ligth will change the fg colors
each light source have an hollow

*/


}


#define LIGHTW 40
#define LIGHTH 25
Color _lightFilter[LIGHTH][LIGHTW] = {Black};
void LghtSrc(Let col, Let row, Color clr){
	if (col < 0 && col >= LIGHTW ) return;
	if (row < 0 && row >= LIGHTH ) return;
	_lightFilter[row][col] = clr;
	_lightFilter[row-1][col] = clr;
	_lightFilter[row+1][col] = clr;
	_lightFilter[row][col-1] = clr;
	_lightFilter[row][col+1] = clr;
}
void LghtRst(){
	for (int x=0;x<LIGHTW;x++)
	for (int y=0;y<LIGHTH;y++)
	_lightFilter[y][x]=Black;
}
Color LghtAt(Let col, Let row){
	if (col < 0 && col >= LIGHTW ) return Black;
	if (row < 0 && row >= LIGHTH ) return Black;
	return _lightFilter[row][col];
}
void LPrnt(Let str[],Let col, Let row, Color clr){
	Prnt(str,col,row,clr+LghtAt(col,row));
}

void LPlt(Let col, Let row, Color clr){
	Plt(col,row,clr+LghtAt(col,row));
}

void LPth(Let str[],Let col, Let row, Color clr){
	Pth(str,col,row,clr+LghtAt(col,row));
}
void LSqr(Let col,Let row,Let w, Let h,Color clr){
	for (int y=row;y<row+h;y++)
	for (int x=col;x<col+w;x++)
	LPlt(x,y,clr);
}

/*
2-9 repeat next character, single digit consecutive digit are added up
@ make next L corner and T junction rotate clockwise 90 deg and rotate reset to 0, because it is a swirl, that spin clockwise, can be repeated
{ save last position and direction, not stackable by design
} restore last position and direction, if none return to down with 0,0 as coordinate
v ^ < > change direction, with repeat move in that direction
T a down pointing T junction rotate clockwise 90 foreach @ before
L a L corner Up Right like the actual L. rotate clockwise foreach @ before
- draw horzontal line, can be repeated
| draw vertical line, repeatable

each draw character move in given direction

soon:
colors
*/

union {
	char pth[100];
	struct {
		char RailA;
		char RailB;
		char RailC;
		char RailD;
		char Windows[16];
		char Down[3];
		char Wagon[28];
		char DownAgain[5];
		char RailW;
		char RailX;
		char RailY;
		char RailZ;
	} obj;
} Train = {"0000- # # # #<        v2 ^2|3@T{|@L>29-2@Lv|@T2|}>29- v >0000-"};
//          
Let train = 0;
void TerminalRain(Co c){
    Sqr(0,0,40,25,Black);

    //bar
    Pth("9-@T{^3|}v3|",0,3,Magenta);
    Lbl("BAR",8,4,Magenta+Colors);

    Plt(5,6,Cyaner);
    Plt(5,7,Cyan+Colors);
    Plt(4,7,Cyan);
    Plt(6,7,Cyan);

    //nudes
    Pth("^6|3@T>3-",13,7,Yellow);
    Lbl("Nudes",14,1,Yellow+Colors);
    Plt(12,5,Yellowless);

    //motel
    Pth("<8-@Lv|3@T{2|}>-      -",38,2,Blue);
    Prnt("[Mot3l]",31,4,Blue+Colors);
    Plt(35,6,White);

    //ram

	//one wagon
    train++;
    train = train % 40;
    int trainx = 10 - (train/2);
    if (trainx < 0) trainx=-trainx;

   
    if (trainx>27) Train.obj.RailA = '0'+9;
    if (trainx>18) Train.obj.RailB = '0'+9;
    if (trainx>9) Train.obj.RailC = '0'+9;
    Train.obj.RailD = '0' + (trainx%9);
if (26-trainx > 27) Train.obj.RailW = '9';
if (26-trainx > 18) Train.obj.RailX = '9';
if (26-trainx > 9) Train.obj.RailY = '9';
Train.obj.RailZ = '0' + ((40-trainx)%9);
    Pth(Train.pth,0,13,Red);



    
    AnyKey(c,0);
}
