Exemple #1
0
/*
 * displays every edge and the associated vertices starting at head
 */
void displayEdges(edgeSet * head)
{
  if(head!=NULL)
  {
    displayEdge(head);
    displayEdges(head->nextEdge);
  }
}
Exemple #2
0
int		main(void)
{
    int		key;
    int		i;
    int		iframe;
    Bullet	*bul = new Bullet[200];
    Bullet	*bulEn = new Bullet[100];
    Ship	*ship = new Ship[50];
    Ast		*ast = new Ast[50];
    Star	*stars = new Star[100];
    Player	*player = new Player;

    key = 0;
    iframe = 0;

    srand(time(NULL));

    initscr();
    initColor();
    keypad(stdscr, TRUE);
    curs_set(0);
    nodelay(stdscr, TRUE);

    while (key != 'q' && player->getLife() > 0)
    {
        usleep(19000);

        clear();

        spawnStars(stars, iframe);
        spawnEnemy(ship, iframe);
        spawnAst(ast, iframe);

        displayText(player);
        displayEdge();
        displayStars(stars);
        displayEnemy(ship, player);
        displayAst(ast, player);
        displayBullet(bul, ship, ast, player);
        displayEnemyBullet(bulEn, ship, player);

        mvaddch(player->getX(), player->getY(), '>'|COLOR_PAIR(4));

        key = getch();

        refresh();

        if (key == 258 && player->getX() < 30)
            player->setX(player->getX() + 1);
        else if (key == 259 && player->getX() > 4)
            player->setX(player->getX() - 1);
        else if (key == 260 && player->getY() > 4)
            player->setY(player->getY() - 1);
        else if (key == 261 && player->getY() < 52)
            player->setY(player->getY() + 1);
        else if (key == 32)
        {
            i = 0;
            while (bul[i].getY() < 100 && i < 200)
                i++;
            bul[i].setX(player->getX());
            bul[i].setY(player->getY() + 1);
        }

        iframe++;
        if (iframe == 100)
            iframe = 0;
    }
    clear();
    refresh();
    endwin();
}