Exemple #1
0
void setup()
{

     initscr();
     clear();
     noecho();
     crmode();
     curs_set(0);
     
     snake_init();
     food_create();
     snake_show_or_hide(SNAKE_BODY);
}
Exemple #2
0
void snake_show(int signum)
{
     snake_show_or_hide(BLANK);
     if(!snake_move())
     {
	  endwin();
	  exit(0);
     }

     if(is_touch_food(&food))
     {
	  snake_eat(&food);
	  food_create();
     }
     snake_show_or_hide(SNAKE_BODY);
}
Exemple #3
0
void
board_set(Board *self, int y, int x, Item item)
{
    int idx;
    if (y<0 || y>=self->h || x<0 || x>=self->w) return;

    idx = y*self->w+x;

    self->slots[idx].it = item;
    if (item == FOOD)
    {
	self->slots[idx].f = food_create(self, self->screen, y, x);
	food_draw(self->slots[idx].f);
    }
    else
    {
	food_destroy(self->slots[idx].f);
	self->slots[idx].f = 0;
	screen_putItem(self->screen, y, x, item);
    }
}