From 58dc358efe685d7657657d6362806c7e27a9cc22 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 21 Dec 2022 23:10:18 +0000 Subject: Changed win sceen. --- util.c | 59 +++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 22 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 736ea47..41d09e6 100644 --- a/util.c +++ b/util.c @@ -103,6 +103,17 @@ double DRand() return (double)(rand() % 1000) / 1000.0; } +static void Plot3D(double x, double y, double z, char glyph) +{ + int ix; + int iy; + + ix = COLS/2 + x / (z / 30.0); + iy = LINES/2 + y / (z / 30.0); + + mvaddch(iy, ix, glyph); +} + void WinScreen() { static const char *text[] = @@ -112,6 +123,20 @@ void WinScreen() " # # # # # # # # # # # ##", " # # # # # ## ## # # # #", " # ## ## # # ## # #", + " ", + " ", + " ", + "### ### #### ### ###", + "# # # # # # # ", + "### ### ### ## ## ", + "# # # # # #", + "# # # #### ### ### ", + " ", + " ### ### ## ### ####", + "# # # # # # # ", + " ## ### #### # ### ", + " # # # # # # ", + "### # # # ### ####", NULL, }; @@ -119,7 +144,7 @@ void WinScreen() typedef struct { - double x,y,yi; + double x,y,z; } Star; Star *star; @@ -135,13 +160,9 @@ void WinScreen() for(f = 0; f < NO_STAR; f++) { - star[f].x = rand() % COLS; - star[f].y = rand() % LINES; - - do - { - star[f].yi = (double)(rand() % 20) / 10.0; - } while(star[f].yi == 0); + star[f].x = rand() % 1000 - 500; + star[f].y = rand() % 1000 - 500; + star[f].z = rand() % 1000; } halfdelay(1); @@ -152,25 +173,21 @@ void WinScreen() { for(f = 0; f < NO_STAR; f++) { - mvaddch(star[f].y, star[f].x, ' '); + Plot3D(star[f].y, star[f].x, star[f].z, ' '); - star[f].y -= star[f].yi; + star[f].z -= 30; - if (star[f].y < 0) + if (star[f].z < 0) { - star[f].x = rand() % COLS; - star[f].y = LINES - 1; - - do - { - star[f].yi = (double)(rand() % 20) / 10.0; - } while(star[f].yi == 0); + star[f].x = rand() % 1000 - 500; + star[f].y = rand() % 1000 - 500; + star[f].z = 1000; } } for(f = 0; f < NO_STAR; f++) { - mvaddch(star[f].y, star[f].x, '.'); + Plot3D(star[f].y, star[f].x, star[f].z, '.'); } for(f = 0 ; text[f]; f++) @@ -182,7 +199,7 @@ void WinScreen() { if (text[f][i] != ' ') { - mvaddch(f + 4, x++, text[f][i]); + mvaddch(f + 2, x++, text[f][i]); } else { @@ -191,8 +208,6 @@ void WinScreen() } } - Centre(f + 7, "PRESS SPACE"); - refresh(); } -- cgit v1.2.3