fission demo: go both up and down #1896

This commit is contained in:
nick black 2021-07-07 04:29:36 -04:00
parent 20603e5012
commit 4a23acab2d
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
4 changed files with 14 additions and 8 deletions

View File

@ -27,7 +27,7 @@ The demonstrations include (see NOTES below):
* (***c***)hunli—the strongest woman in the world
* (***d***)ragon—the Harter-Heighway dragon curve
* (***e***)agle—they took some time off my life, back in the day
* (***f***)allin'—the screen falls apart under heavy blows
* (***f***)ission—the screen falls apart under heavy blows
* (***g***)rid—a gradient of color lain atop a great grid
* (***h***)ighcon—high contrast text atop various colors
* (***i***)ntro—a setting of tone

View File

@ -79,7 +79,7 @@ static struct {
{ "chunli", chunli_demo, true, },
{ "dragon", dragon_demo, false, },
{ "eagle", eagle_demo, true, },
{ "fallin'", fallin_demo, false, },
{ "fission", fission_demo, false, },
{ "grid", grid_demo, false, },
{ "highcon", highcontrast_demo, false, },
{ "intro", intro, false, },

View File

@ -34,7 +34,7 @@ int chunli_demo(struct notcurses* nc);
int dragon_demo(struct notcurses* nc);
int qrcode_demo(struct notcurses* nc);
int grid_demo(struct notcurses* nc);
int fallin_demo(struct notcurses* nc);
int fission_demo(struct notcurses* nc);
int highcontrast_demo(struct notcurses* nc);
int jungle_demo(struct notcurses* nc);
int yield_demo(struct notcurses* nc);

View File

@ -23,7 +23,9 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){
// ahead and get it kicked off
if(rangee - ranges + 1 < FALLINGMAX){
if(rangee < arrcount){
speeds[rangee - ranges] = 1;
int y;
ncplane_yx(arr[ranges], &y, NULL);
speeds[rangee - ranges] = y < stdy / 2 ? 1 : -1;
++rangee;
}
}
@ -38,7 +40,7 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){
int x, y;
ncplane_yx(ncp, &y, &x);
if(felloff){
if(y + speeds[i] >= stdy){
if(y + speeds[i] >= stdy || y + speeds[i] + ncplane_dim_y(ncp) < 0){
ncplane_destroy(ncp);
arr[ranges + i] = NULL;
if(ranges + i + 1 == rangee){
@ -58,7 +60,11 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){
}
if(!felloff){
ncplane_move_yx(ncp, y + speeds[i], x);
++speeds[i];
if(speeds[i] < 0){
--speeds[i];
}else{
++speeds[i];
}
}else if(i){
if(rangee - ranges - i){
memmove(speeds, speeds + i, (rangee - ranges - i) * sizeof(*speeds));
@ -91,8 +97,8 @@ shuffle_in(struct ncplane** arr, int count, struct ncplane* n){
return arr;
}
// ya playin' yourself
int fallin_demo(struct notcurses* nc){
// you played yourself https://genius.com/De-la-soul-fallin-lyrics
int fission_demo(struct notcurses* nc){
int dimx, dimy;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
size_t usesize = sizeof(bool) * dimy * dimx;