first start of fallin' demo
parent
2783a1b503
commit
7860e1eace
@ -1,6 +1,27 @@
|
||||
#include "demo.h"
|
||||
|
||||
int fallin_demo(struct notcurses* nc){
|
||||
|
||||
// make a copy of the standard plane so that we don't need rederive the
|
||||
// world in the event of a resize event
|
||||
struct ncplane* ndup = ncplane_dup(notcurses_stdplane(nc), NULL);
|
||||
if(!ndup){
|
||||
return -1;
|
||||
}
|
||||
ncplane_erase(notcurses_stdplane(nc));
|
||||
int dimx, dimy, atotal;
|
||||
ncplane_dim_yx(ndup, &dimy, &dimx);
|
||||
atotal = dimy * dimx;
|
||||
// FIXME shuffle up a list of all coordinates, then walk through them. each
|
||||
// one ought be turned into its own small ncplane, erased from ndup, and the
|
||||
// plane set falling.
|
||||
while(atotal--){
|
||||
if(notcurses_render(nc)){
|
||||
ncplane_destroy(ndup);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if(ncplane_destroy(ndup)){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <clocale>
|
||||
#include <cassert>
|
||||
#include <unistd.h>
|
||||
#include <notcurses.h>
|
||||
|
||||
int main(int argc, char** argv){
|
||||
setlocale(LC_ALL, "");
|
||||
notcurses_options opts{};
|
||||
opts.inhibit_alternate_screen = true;
|
||||
struct notcurses* nc;
|
||||
if((nc = notcurses_init(&opts, stdout)) == nullptr){
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
struct ncplane* n = notcurses_stdplane(nc);
|
||||
int dimx, dimy;
|
||||
ncplane_dim_yx(n, &dimy, &dimx);
|
||||
|
||||
int averr;
|
||||
auto ncv = ncplane_visual_open(n, "../data/dsscaw-purp.png", &averr);
|
||||
if(!ncv){
|
||||
goto err;
|
||||
}
|
||||
if(!ncvisual_decode(ncv, &averr)){
|
||||
goto err;
|
||||
}
|
||||
if(ncvisual_render(ncv, 0, 0, 0, 0)){
|
||||
goto err;
|
||||
}
|
||||
if(notcurses_render(nc)){
|
||||
goto err;
|
||||
}
|
||||
sleep(1);
|
||||
return notcurses_stop(nc) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
|
||||
err:
|
||||
notcurses_stop(nc);
|
||||
return EXIT_FAILURE;
|
||||
}
|
Loading…
Reference in New Issue