Skip to content

Commit

Permalink
add -G option that add an orange TGV
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmo-ray committed Jun 26, 2019
1 parent 923e7d7 commit 83e20c2
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 4 deletions.
3 changes: 3 additions & 0 deletions sl.1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Little version.
.B \-F
It flies like the galaxy express 999.
.TP
.B \-G
It's French like Oscar.
.TP
.B \-c
C51 appears instead of D51.
.PP
Expand Down
64 changes: 61 additions & 3 deletions sl.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void add_smoke(int y, int x);
void add_man(int y, int x);
int add_C51(int x);
int add_D51(int x);
int add_TGV(int x);
int add_sl(int x);
void option(char *str);
int my_mvaddstr(int y, int x, char *str);
Expand All @@ -55,6 +56,7 @@ int ACCIDENT = 0;
int LOGO = 0;
int FLY = 0;
int C51 = 0;
int TGV = 0;

int my_mvaddstr(int y, int x, char *str)
{
Expand All @@ -75,6 +77,7 @@ void option(char *str)
case 'F': FLY = 1; break;
case 'l': LOGO = 1; break;
case 'c': C51 = 1; break;
case 'G': TGV = 1; break;
default: break;
}
}
Expand All @@ -96,6 +99,18 @@ int main(int argc, char *argv[])
nodelay(stdscr, TRUE);
leaveok(stdscr, TRUE);
scrollok(stdscr, FALSE);
/*
* first Non prototype TGV was orange
*/
if (TGV == 1) {
if (has_colors()) {
start_color();
init_pair(1, COLOR_WHITE, COLOR_BLACK);
init_pair(2, COLOR_YELLOW, COLOR_BLACK);
} else {
TGV = 0;
}
}

for (x = COLS - 1; ; --x) {
if (LOGO == 1) {
Expand All @@ -104,12 +119,18 @@ int main(int argc, char *argv[])
else if (C51 == 1) {
if (add_C51(x) == ERR) break;
}
else if (TGV == 1) {
if (add_TGV(x) == ERR) break;
}
else {
if (add_D51(x) == ERR) break;
}
getch();
refresh();
usleep(40000);
getch();
refresh();
if (TGV)
usleep(20000);
else
usleep(40000);
}
mvcur(0, COLS - 1, LINES - 1, 0);
endwin();
Expand Down Expand Up @@ -199,6 +220,43 @@ int add_D51(int x)
return OK;
}

int add_TGV(int x)
{
static char *tgv[TGVPATTERNS][TGVHEIGHT + 1]
= {{TGVSTR0, TGVSTR1, TGVSTR2, TGVSTR3, TGVSTR4, TGVSTR5, TGVSTR6,
TGVWHL1, TGVDEL},
{TGVSTR0, TGVSTR1, TGVSTR2, TGVSTR3, TGVSTR4, TGVSTR5, TGVSTR6,
TGVWHL2, TGVDEL}};
static char *vagoon[TGVHEIGHT + 1]
= {TGVVAG0, TGVVAG1, TGVVAG2, TGVVAG3, TGVVAG4, TGVVAG5, TGVVAG6, TGVVAG7, TGVDEL};

int y, i, dy = 0;

if (x < - TGVLENGTH) return ERR;
y = LINES / 2 - 5;

if (FLY == 1) {
y = (x / 7) + LINES - (COLS / 7) - TGVHEIGHT;
dy = 1;
}
attron(COLOR_PAIR(2));
for (i = 0; i <= TGVHEIGHT; ++i) {
my_mvaddstr(y + i, x, tgv[((TGVLENGTH + x) / 2) % TGVPATTERNS][i]);
my_mvaddstr(y + i + dy, x + 55, vagoon[i]);
}
attroff(COLOR_PAIR(2));

if (ACCIDENT == 1) {
add_man(y + 2, x + 14);

add_man(y + dy + 3, x + 85);
add_man(y + dy + 3, x + 90);
add_man(y + dy + 3, x + 95);
add_man(y + dy + 3, x + 100);
}
return OK;
}

int add_C51(int x)
{
static char *c51[C51PATTERNS][C51HEIGHT + 1]
Expand Down
27 changes: 26 additions & 1 deletion sl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,37 @@
*========================================
*/

#define TGVHEIGHT 8
#define TGVLENGTH 114
#define TGVPATTERNS 2

#define TGVSTR0 " ______________ / "
#define TGVSTR1 " ____________/______________|__\\_______ "
#define TGVSTR2 " _____/ |IIIIIIIIIII|_______________________| "
#define TGVSTR3 " __/__/_|_| ______________________________| "
#define TGVSTR4 " __/ | | / |||||||||||| TGV || | "
#define TGVSTR5 " /> [] | | /___________||||||||||||______|| | "
#define TGVSTR6 " \\_==================================================| "
#define TGVWHL1 " |___/==0==0==|_________________________/===0==0==\\| "

#define TGVWHL2 " |___/0==0==0=|_________________________/=0==0==0=\\| "

#define TGVDEL " "

#define TGVVAG0 " ___________ "
#define TGVVAG1 " |_====____|\\________________________________________ "
#define TGVVAG2 "o| |||| ___ | "
#define TGVVAG3 "H|______________|___|_________________________________| "
#define TGVVAG4 "H| |||| |[]| |[]1| [] [ ] [ ] [ ] [ ] | "
#define TGVVAG5 "H|__||||_|__|___|___|_________________________________| "
#define TGVVAG6 "D|==============|===|=================================| "
#define TGVVAG7 " _/ 0==0 |____________________________________/ 0=| "

#define D51HEIGHT 10
#define D51FUNNEL 7
#define D51LENGTH 83
#define D51PATTERNS 6


#define D51STR1 " ==== ________ ___________ "
#define D51STR2 " _D _| |_______/ \\__I_I_____===__|_________| "
#define D51STR3 " |(_)--- | H\\________/ | | =|___ ___| "
Expand Down

0 comments on commit 83e20c2

Please sign in to comment.