eagles level starts at lower-right

This commit is contained in:
nick black 2019-12-19 22:02:42 -05:00 committed by Nick Black
parent 712c7a16eb
commit d6bcb3211f
4 changed files with 40 additions and 12 deletions

View File

@ -1306,6 +1306,9 @@ ncvisual_simple_streamer(struct notcurses* nc, struct ncvisual* ncv __attribute_
// its return value handled as outlined for stream cb. Pretty raw; beware.
int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv,
int* averr, streamcb streamer);
// Return the plane to which this ncvisual is bound.
struct ncplane* ncvisual_plane(struct ncvisual* ncv);
```
### Panelreels

View File

@ -1380,6 +1380,9 @@ ncvisual_simple_streamer(struct notcurses* nc, struct ncvisual* ncv __attribute_
API int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv,
int* averr, streamcb streamer);
// Return the plane to which this ncvisual is bound.
API struct ncplane* ncvisual_plane(struct ncvisual* ncv);
// A panelreel is an notcurses region devoted to displaying zero or more
// line-oriented, contained panels between which the user may navigate. If at
// least one panel exists, there is an active panel. As much of the active

View File

@ -1,10 +1,9 @@
#include "demo.h"
static struct ncvisual*
outzoomed_map(struct notcurses* nc){
outzoomed_map(struct notcurses* nc, const char* map){
int averr;
struct ncvisual* ncv = ncvisual_open_plane(nc, "../tests/eagles.png", &averr,
0, 0, NCSCALE_SCALE);
struct ncvisual* ncv = ncvisual_open_plane(nc, map, &averr, 0, 0, NCSCALE_SCALE);
if(ncv == NULL){
return NULL;
}
@ -21,34 +20,53 @@ outzoomed_map(struct notcurses* nc){
return ncv;
}
// motherfucking eagles!
int eagle_demo(struct notcurses* nc){
struct ncvisual* zo;
if((zo = outzoomed_map(nc)) == NULL){
return -1;
}
static int
zoom_map(struct notcurses* nc, const char* map){
int averr;
// FIXME determine size that will be represented on screen at once, and how
// large that section has been rendered in the outzoomed map. take the map
// and begin opening it on larger and larger planes that fit on the screen
// less and less. eventually, reach our natural NCSCALE_NONE size and begin
// scrolling through the map, whooooooooosh.
struct ncvisual* ncv = ncvisual_open_plane(nc, "../tests/eagles.png", &averr,
0, 0, NCSCALE_NONE);
struct ncvisual* ncv = ncvisual_open_plane(nc, map, &averr, 0, 0, NCSCALE_NONE);
if(ncv == NULL){
return -1;
}
if(ncvisual_decode(ncv, &averr) == NULL){
ncvisual_destroy(ncv);
return -1;
}
// we start at the lower right corner of the outzoomed map
int truex, truey; // dimensions of true display
notcurses_term_dim_yx(nc, &truey, &truex);
struct ncplane* ncp = ncvisual_plane(ncv);
int vx, vy; // dimensions of unzoomed map
ncplane_dim_yx(ncp, &vy, &vx);
fprintf(stderr, "TRUE DIMS: %d/%d\n", vy, vx);
ncplane_move_yx(ncp, truey - vy, truex - vx);
if(ncvisual_render(ncv)){
ncvisual_destroy(ncv);
return -1;
}
if(notcurses_render(nc)){
ncvisual_destroy(ncv);
return -1;
}
nanosleep(&demodelay, NULL);
ncvisual_destroy(ncv);
ncvisual_destroy(zo);
return 0;
}
// motherfucking eagles!
int eagle_demo(struct notcurses* nc){
const char* map = "../tests/eagles.png";
struct ncvisual* zo;
if((zo = outzoomed_map(nc, map)) == NULL){
return -1;
}
ncvisual_destroy(zo);
if(zoom_map(nc, map)){
return -1;
}
return 0;
}

View File

@ -5,6 +5,10 @@
#include "notcurses.h"
#include "internal.h"
ncplane* ncvisual_plane(ncvisual* ncv){
return ncv->ncp;
}
static ncvisual*
ncvisual_create(void){
ncvisual* ret = malloc(sizeof(*ret));