mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 09:39:03 -04:00
witherworms breed, paint xray banner
This commit is contained in:
parent
2a256192ad
commit
f9e18fa1ee
@ -240,11 +240,11 @@ snakey(struct notcurses* nc, snake* s, int dimy, int dimx){
|
|||||||
// our colocality (unless they're summary area walls).
|
// our colocality (unless they're summary area walls).
|
||||||
static void *
|
static void *
|
||||||
snake_thread(void* vnc){
|
snake_thread(void* vnc){
|
||||||
const int snakecount = 3; // FIXME base count off area
|
|
||||||
struct notcurses* nc = vnc;
|
struct notcurses* nc = vnc;
|
||||||
struct ncplane* n = notcurses_stdplane(nc);
|
struct ncplane* n = notcurses_stdplane(nc);
|
||||||
int dimy, dimx;
|
int dimy, dimx;
|
||||||
ncplane_dim_yx(n, &dimy, &dimx);
|
ncplane_dim_yx(n, &dimy, &dimx);
|
||||||
|
int snakecount = dimy / 15;
|
||||||
snake snakes[snakecount];
|
snake snakes[snakecount];
|
||||||
for(int s = 0 ; s < snakecount ; ++s){
|
for(int s = 0 ; s < snakecount ; ++s){
|
||||||
init_snake(&snakes[s], dimy, dimx);
|
init_snake(&snakes[s], dimy, dimx);
|
||||||
|
@ -15,6 +15,9 @@ static const char* leg[] = {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
perframecb(struct notcurses* nc, struct ncvisual* ncv __attribute__ ((unused))){
|
perframecb(struct notcurses* nc, struct ncvisual* ncv __attribute__ ((unused))){
|
||||||
|
static int startr = 0x80;
|
||||||
|
static int startg = 0xff;
|
||||||
|
static int startb = 0x80;
|
||||||
static int frameno = 0;
|
static int frameno = 0;
|
||||||
int dimx, dimy;
|
int dimx, dimy;
|
||||||
struct ncplane* n = notcurses_stdplane(nc);
|
struct ncplane* n = notcurses_stdplane(nc);
|
||||||
@ -23,16 +26,24 @@ perframecb(struct notcurses* nc, struct ncvisual* ncv __attribute__ ((unused))){
|
|||||||
int y = dimy - sizeof(leg) / sizeof(*leg) - 3;
|
int y = dimy - sizeof(leg) / sizeof(*leg) - 3;
|
||||||
int x = dimx - frameno;
|
int x = dimx - frameno;
|
||||||
for(size_t l = 0 ; l < sizeof(leg) / sizeof(*leg) ; ++l, ++y){
|
for(size_t l = 0 ; l < sizeof(leg) / sizeof(*leg) ; ++l, ++y){
|
||||||
|
int r = startr;
|
||||||
|
int g = startg - (l * 0x8);
|
||||||
|
int b = startb;
|
||||||
ncplane_set_bg_rgb(n, l * 0x4, 0x20, l * 0x4);
|
ncplane_set_bg_rgb(n, l * 0x4, 0x20, l * 0x4);
|
||||||
ncplane_set_fg_rgb(n, 0x80, 0xff - (l * 0x10), 0x80);
|
|
||||||
int xoff = x;
|
int xoff = x;
|
||||||
while(xoff + (int)strlen(leg[l]) <= 0){
|
while(xoff + (int)strlen(leg[l]) <= 0){
|
||||||
xoff += strlen(leg[l]);
|
xoff += strlen(leg[l]);
|
||||||
}
|
}
|
||||||
do{
|
do{
|
||||||
|
ncplane_set_fg_rgb(n, r, g, b);
|
||||||
int len = dimx - xoff;
|
int len = dimx - xoff;
|
||||||
if(xoff < 0){
|
if(xoff < 0){
|
||||||
len = strlen(leg[l]) + xoff;
|
len = strlen(leg[l]) + xoff;
|
||||||
|
}else if(xoff == 0){
|
||||||
|
int t = startr;
|
||||||
|
startr = startg;
|
||||||
|
startg = startb;
|
||||||
|
startb = t;
|
||||||
}
|
}
|
||||||
if(len > (int)strlen(leg[l])){
|
if(len > (int)strlen(leg[l])){
|
||||||
len = strlen(leg[l]);
|
len = strlen(leg[l]);
|
||||||
@ -45,13 +56,17 @@ perframecb(struct notcurses* nc, struct ncvisual* ncv __attribute__ ((unused))){
|
|||||||
stroff = -xoff;
|
stroff = -xoff;
|
||||||
xoff = 0;
|
xoff = 0;
|
||||||
}
|
}
|
||||||
if(y == 22)fprintf(stderr, "printing %d at %d (%d)\n", len, xoff, dimx);
|
|
||||||
ncplane_printf_yx(n, y, xoff, "%*.*s", len, len, leg[l] + stroff);
|
ncplane_printf_yx(n, y, xoff, "%*.*s", len, len, leg[l] + stroff);
|
||||||
xoff += len;
|
xoff += len;
|
||||||
|
int t = r;
|
||||||
|
r = g;
|
||||||
|
g = b;
|
||||||
|
b = t;
|
||||||
}while(xoff < dimx);
|
}while(xoff < dimx);
|
||||||
}
|
}
|
||||||
++frameno;
|
++frameno;
|
||||||
notcurses_render(nc);
|
notcurses_render(nc);
|
||||||
|
// FIXME we'll need some delay here
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user