TetrisManager::TetrisManager(QWidget* parent, const char* name)
:QMainWindow(parent, name),
 state(Tetris::stopped) {
 	
	//Resize window to a fixed size
	setFixedSize(BOARD_WIDTH + 30 + 100, BOARD_HEIGHT + 20);
	
	//Create member
	gameBoard = new TetrisBoard(this, "board");
	gameStats = new TetrisStats(this, "stats");
	timer = new QTimer(this);
	
	//Set location
	gameBoard->move(10, 10);
	gameStats->move(BOARD_WIDTH + 20, 10);
	
	//Connect events related to board
	connect(gameBoard, SIGNAL(gameover()),
		this, SLOT(gameover()));
	connect(gameBoard, SIGNAL(blockFallen()),
		this, SLOT(blockFallen()));
	
	//Connect events between board and stats
	connect(gameBoard, SIGNAL(rowClear(int)),
		gameStats, SLOT(rowClear(int)));
	
	//Connect events related to timer
	connect(timer, SIGNAL(timeout()),
		this, SLOT(updateMovement()));
}
Esempio n. 2
0
	void move()
	{
		for(auto &b: bullets){
			if(b){
				b.move();
			}
		}

		player_.move();
		auto p = player_.get_position();
		auto r = paint::rect(p, player_.get_size());
		auto s = get_size();
		if(r.left < 0.f)
			p.x = 0.f;
		else if(r.right >= s.width)
			p.x = s.width - 1.f - r.width();
		if(r.top < 0.f)
			p.y = 0.f;
		else if(r.bottom >= s.height)
			p.y = s.height - 1.f - r.height();
		player_.set_position(p);

		auto rect = get_rect();

		for(auto it = enemy_bullets.begin(); it != enemy_bullets.end(); ++it){
			(*it)->move(player_);
			if((*it)->is_colliding(player_)){
				gameover();
				return;
			}

			float r = (*it)->get_radius();
			if(!(*it)->get_center().is_inside(rect - paint::point(r, r) + paint::size(r, r))){
				delete *it;
				*it = nullptr;
			}
		}
		enemy_bullets.erase(std::remove(enemy_bullets.begin(), enemy_bullets.end(), nullptr), enemy_bullets.end());

		for(auto it = enemies.begin(); it != enemies.end(); ++it){
			(*it)->move(player_, enemy_bullets);

			if((*it)->is_colliding(player_)){
				gameover();
				return;
			}

			for(auto &b: bullets){
				if(b && (*it)->is_colliding(b)){
					b.set_active(false);
					delete *it;
					*it = nullptr;
					break;
				}
			}
		}
		auto remover = std::remove(enemies.begin(), enemies.end(), nullptr);
		score += static_cast<int>(std::distance(remover, enemies.end()));
		enemies.erase(remover, enemies.end());
	}
Esempio n. 3
0
//汉字掉落状态捕捉函数,当新汉字掉落完,并清除出新汉字盒子时,掉落完毕
void ChrsGrid::onChrsDropping(float dt) 
{
	//如果新汉字都掉落完,停止该捕捉函数,并恢复触摸
	if (m_NewChrs.empty())
	{
		unschedule(schedule_selector(ChrsGrid::onChrsDropping));

		//判断是否是死图
		while (isDeadMap())
		{
			//这里稍后做一个更新的算法
			//1.根据布局大小创建出汉字阵列
			//2.布局坐标以左下角为原点,x右y上为正方向
			for (int x = 0; x < m_col; x++)
			{
				for (int y = 0; y < m_row; y++)
				{ 
					m_ChrsBox[x][y]->removeFromParent();
					m_ChrsBox[x][y] = createAChr(x, y); 
				}
			}
		}

		//游戏步数减去1,并加分
		auto gamescene = getGameScene();
		int cur_step = gamescene->subStep();
		int cur_score = gamescene->addScore(m_bonus);
		m_bonus = 0;

		int step_need = gamescene->getStepNeed();
		int score_need = gamescene->getScoreNeed();

		//判断游戏是否结束
		if (cur_step == 0)
		{
			if (cur_score < score_need)
			{
				gamescene->gameover(false);
			}
			else
			{
				gamescene->gameover(true);
			}
			this->unscheduleAllSelectors();
		}
		else
		{
			if (cur_score >= score_need)
			{
				gamescene->gameover(true);
				this->unscheduleAllSelectors();
			}
			else
			{
				//游戏没有结束,恢复触摸
				_eventDispatcher->resumeEventListenersForTarget(this);
			}
		}
	}
}
Esempio n. 4
0
//function to make paw deal damage
void damagepaw (claw &enemy)
{
	for (int i = 0; i < 5; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			for (int k = 0; k < 2; ++k)
			{
				for (int l = 0; l < 3; ++l)
				{
					if (check == 0)
					{
						if (elapsedTime >= 5.9)
						{
							if ( (charLocation.X + l == enemy.loc3.X + j) && (charLocation.Y + k == enemy.loc3.Y + i) )
							{
								Beep(3440, 100);
								life--;
							}

							if (life <= 0)
							{
								gameover();
							}
						}
					}

					else
					{
						if (elapsedTime >= 36.9)
						{
							if ( (charLocation.X + l == enemy.loc3.X + j) && (charLocation.Y + k == enemy.loc3.Y + i) )
							{
								Beep(3440, 100);
								life--;
							}

							if (life <= 0)
							{
								gameover();
							}
						}
					}
				}
			}
		}
	}
}
Esempio n. 5
0
void Game::keyPressEvent(QKeyEvent *event)
{
    if(event->type() == QKeyEvent::KeyPress)
    {
        switch (event->key()) {
        case Qt::Key_Left:
            countback=0;
            die=ifdie();
            gameover(die);
            ifwin();
            setthesame();
            addLeftRow();
            checkSame();
            ui->score->setText(str);
            break;
        case Qt::Key_Right:
            countback=0;
            die=ifdie();
            gameover(die);
            ifwin();
            setthesame();
            addRightRow();
            checkSame();
            ui->score->setText(str);
            break;
        case Qt::Key_Up:
            countback=0;
            die=ifdie();
            gameover(die);
            ifwin();
            setthesame();
            addUpCol();
            checkSame();
            ui->score->setText(str);
            break;
        case Qt::Key_Down:
            countback=0;
            die=ifdie();
            gameover(die);
            ifwin();
            setthesame();
            addDownCol();
            checkSame();
            ui->score->setText(str);
            break;
        }
    }
}
Esempio n. 6
0
void run_ufos() {
    for (i=0; i < level*2+3; ++i) {
        if (ufos[i].alive == 0) {
            continue;
        }

        if (ufos[i].pos.x >= cols - 8) {
            ufos[i].goRight = 0;
            ufos[i].pos.y += 1;
        }

        if (ufos[i].pos.x <= 1) {
            ufos[i].goRight = 1;
            ufos[i].pos.y += 1;
        }

        if (ufos[i].goRight == 0) {
            ufos[i].pos.x -= 2;
        } else {
            ufos[i].pos.x += 2;
        }

        if (rand() % 100 < SHOOT_PERCENT) {
            add_shot(mk_shot(ufos[i].pos, 0, UFO_ART_SIZE/2));
        }

        if (ufos[i].pos.y == rows-1) {
            gameover("The UFOs have landed. Earth will be destroyed.");
            quit("Better luck next time!\n");
        }
    }
}
Esempio n. 7
0
void MainWindow::move()
{
    auto s_head = getHead();
    auto s_food = QPoint(food_pos.x(), food_pos.y());
    auto s_foot = getFoot();
    state_now = find_way(s_head, s_food);
    if(state_now == -1){
        state_now = find_way(s_head, s_foot);
    }
    if(state_now == to_left)
    {
        go_left();
    }else if(state_now == to_right){
        go_right();
    }else if(state_now == to_up){
        go_up();
    }else if(state_now == to_down){
        go_down();
    }else{
        state_now = getRandomStep(s_head);
        if(state_now == -1){
            QMessageBox::information(0, "", "end");
            gameover();
        }else if(state_now == to_left){
            go_left();
        }else if(state_now == to_right){
            go_right();
        }else if(state_now == to_up){
            go_up();
        }else if(state_now == to_down){
            go_down();
        }
    }
    update();
}
Esempio n. 8
0
int main(void)
{
  initscr();
  noecho();
  noecho();
  curs_set(0); 

  int grid[COLS][LINES];

  init_life (grid);
  printgrid (grid);
  
  for (;;)
    {
      run_life (grid);
      printgrid (grid);
      refresh();
      if (gameover(grid) == 0)
	break;
      usleep (50000);
    }

  refresh();
  endwin();
  return 0;
}
Esempio n. 9
0
//function to make tail deal damage
void damagetail (tail &enemy)
{
	for (int i = 0; i < 4; ++i)
	{
		for (int j = 0; j < 13; ++j)
		{
			for (int k = 0; k < 2; ++k)
			{
				for (int l = 0; l < 3; ++l)
				{
					if ( (charLocation.X + l == enemy.loc1.X + j) && (charLocation.Y + k == enemy.loc1.Y + i) )
					{
						Beep(3440, 100);
						life--;
					}

					if (life <= 0)
					{
						gameover();
					}
				}
			}
		}
	}
}
Esempio n. 10
0
int main()
{
	srand(time(NULL));
    char ch;
	int t,flag=0;
    generate(0);
    print();
	while(1)
    {
        flag=0;
        if(gameover())
        break;
        ch=getch();
        t=isfull();
        switch(ch)
        {
            case 'w' : flag=shiftu();break;
            case 'a' : flag=shiftl();break;
            case 's' : flag=shiftd();break;
            case 'd' : flag=shiftr();
        }
        system("cls");
        if(!t && flag)
        generate(1);
        print();
    }
    printf("Game over  !! :)\n");
	return 0;
}
Esempio n. 11
0
void game_over_entry(void)
{
	f_nosound=1;
	process_sleep(0x40*3);
	gameover();
	process_suicide();
}
Esempio n. 12
0
void checkwin(vars *varia)
{
    if (varia->gioco.serpente.numsezioni==(varia->gioco.larg*varia->gioco.alt))
        {
        gameover(varia,2);
        }
}
Esempio n. 13
0
void MainWindow::moveOne(QPoint p)
{
    if(is_in(p) == false){
        gameover();
        return;
    }
    bool flag = false;
    if(map[p.x()][p.y()] == food) flag = true;
    map[p.x()][p.y()] = snake_body;
    que.push_back(QPoint(p.x(), p.y()));
    if(flag == false){
        p = que.front();
        map[p.x()][p.y()] = none;
        que.pop_front();
    }else{
        createfood();
    }
    auto iter = que.begin() + 1;
    for(; iter != que.end(); ++iter)
    {
        map[iter -> x()][iter -> y()] = snake_body;
    }
    iter = que.end() - 1;
    map[iter -> x()][iter -> y()] = snake_head;
    iter = que.begin();
    map[iter -> x()][iter -> y()] = snake_foot;
}
Esempio n. 14
0
int CMainLoop::mainloop(void)
{
	if(debug_1==0)
	{
		setGameMode(GMODE_LOAD);//
		debug_1=1;
	}
	switch(gmode)
	{
		case GMODE_TITLE://タイトル画面
			title();
			break;

		case GMODE_LOAD:
			load();
			break;

		case GMODE_BODY://ゲーム本体
			body();
			break;

		case GMODE_CONFIG:
			config();
			break;

		case GMODE_GAMEOVER:
			gameover();
			break;

		case GMODE_END:
			end();
			break;
	}
	return 0;
}
Esempio n. 15
0
int main(int argc, const char *argv[])
{
	int ret;
	char ch;
	
	srand(time(NULL));
	ret = fb_open();
	key_init();	
	draw_back();
	draw_grid();
	signal(SIGALRM, sig_handler);
	alarm(1);

	while (1) {
		ch = getchar();
		switch (ch) {
			case 'a':
				if(canleft(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_x--;
				}
				break;
			case 'd':
				if(canright(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_x++;
				}
				break;	
			case 's':
				if(candown(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_y++;
				}
				break;
			case 'w':
				if(canchange(pos_x,pos_y,cur_type,arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					type_chg(&cur_type);
				}
				break;
			default :
				break;
		}
		draw_type(pos_x, pos_y, cur_type, COLOR);
		draw_grid();
		if(!candown(pos_x, pos_y, cur_type, arr)) {
			draw_flag(pos_x, pos_y, cur_type, arr);
			if(gameover(arr)) {
				exit(0);
			}
			deleteone(arr);
			pos_x = XNUM/2; pos_y = 0;
			cur_type = rand()%14;
		}
	}

	fb_close();

	return 0;
}
Esempio n. 16
0
//----------------------------------------------------------------------------------------------------------------------
void Game::update()
{
  // only update if game is acutally playing
  if(m_playing)
  {
    // if the music is paused when changing levels
    if(Mix_PausedMusic()==1)
    {
      // play the music
      Mix_ResumeMusic();
    }
    // update all the game's systems
    m_controlSys.update(m_rotX, m_rotY);
    m_sensorSys.update();
    m_autoSys.update();
    // get rid of dead boids
    cleanup();
    m_flightSys.update();
    m_combatSys.update();
    // check if vulnerable boid lists are empty
    if(m_world->m_stdBoids.empty() && m_world->m_ldrBoids.empty())
    {
      // increment the level
      ++m_level;
      // if level is still within max levels
      if(m_level<m_maxLevels)
      {
        // congratulations for beating level, loading new level
        Mix_PauseMusic();
        // load next level after reset
        m_world->resetWorld();
        loadLevel(m_levelList[m_level]);
      }
      else
      {
        // finished the game, return to menu
        gameover();
      }
    }
    if(m_world->m_player->m_auto.m_dead)
    {
      // gameover, return to menu
      gameover();
    }
  }
}
Esempio n. 17
0
void Mushroom::update(float delta) {
	float y = this->getPositionY();
	if (y < -LOCAL_RESOLUTION.height / 2 - this->getContentSize().height) {
		gameover();
		return;
	}
	PhySprite::update(delta);
}
Esempio n. 18
0
/*
 * Move to a particular position and see if we hit a mine.
 * If not, then count the number of mines adjacent to us so it can be seen.
 * If we are stepping onto a location where we remembered a mine is at,
 * then don't do it.  Moving is only allowed to old locations, or to
 * locations adjacent to old ones.
 */
static void
movetopos(POS newpos)
{
    POS		fixpos;		/* position to fix up */
    CELL		cell;		/* current cell */
    GR_COUNT	count;		/* count of cells */
    GR_COUNT	i;		/* index for neighbors */

    if ((newpos < 0) || (newpos >= (FULLSIZE * FULLSIZE)) || !playing)
        return;

    cell = board[newpos];

    if (isedge(cell) || (isseen(cell)) || isold(cell))
        return;

    count = isold(cell);
    for (i = 0; i < 8; i++)
        if (isold(board[newpos + steptable[i]]))
            count++;

    if (count <= 0)
        return;

    cell = (cell & F_FLAGS) | F_OLD;
    steps++;

    PRINTSTEPS;

    if (ismine(cell)) {		/* we hit a mine */
        legs--;
        board[newpos] = (F_REMEMBER | F_MINE);
        cell = (F_EMPTY | F_OLD);
        board[newpos] = cell;
        drawbomb(newpos, redgc, GR_TRUE);
        clearcell(newpos);
        setcursor();
        for (i = 0; i < 8; i++) {
            fixpos = newpos + steptable[i];
            if (isold(board[fixpos])) {
                board[fixpos]--;
                drawcell(fixpos);
            }
        }
        drawstatus();
    }

    count = 0;
    for (i = 0; i < 8; i++)
        if (ismine(board[newpos + steptable[i]]))
            count++;
    board[newpos] = cell | (count + '0');

    drawcell(newpos);

    if ((legs <= 0) || (newpos == boardpos(size,size)))
        gameover();
}
Esempio n. 19
0
void SinglePlayer(void)
{
    /* 啟動鍵盤控制 */
    initializeKeyInput();
    char ch='0';
    winTimes=0;  //Left
    loseTimes=0;
    count = 0;
    int pick = -1;
    int initime=clock();
    int time;

    while(winTimes<3 && loseTimes<3)
    {

        clearScreen();
        if(turn == 0)
        {
            ch = getKeyEventVirtual();
            switch(ch)
            {
            case 0x58: //左方拍桌

                check(pick,initime);
                initime = clock();
                break;
            case 0x5A:
                if(count==pick)
                {
                    Loser();
                }
                else
                    getNewCard();
                initime = clock();
                break;
            }
        }
        else
        {
            if(waitForKeyDown(3.0))
            {
                ch = getKeyEventVirtual();
                if(ch == 0x58){
                    check(pick,initime);
                    initime = clock();
                }
            }
            else //if(tick > WAIT_TIME)
            {
                getNewCard();
                initime = clock();
            }
        }
    }
    if(loseTimes==3)
        gameover();
    showingPlane =2;
}
Esempio n. 20
0
int start_game(snake psnake,food Tfood)
{
   move_snake(psnake);
   draw_snake(psnake);
   //检测按键:当按键为Q/q时,返回-1
   if(wait_for_press(psnake)==-1){
	   print_infowin("Quit Game!");
       gameover(gamewin, "Quit Game!");
	   return -1;
   }
   //检测贪吃蛇状态:1.是否吃到食物;2.是否触碰自己或者边界.
   if(check_snake(psnake,Tfood)<0){
	 gameover(gamewin,"GAME OVER!!!");
	 print_infowin("QUIT GMAE!");
	 return -1;
   }
   else
	 return 1;
}
Esempio n. 21
0
void gestionVie (perso p, grille g, int type, int i)
{
	if (mort(p) == 1)
	{
		if (type == 0) //joueur
			gameover(p, g);
		else
			killBob(p, i);
	}
}
Esempio n. 22
0
void Clientcontrol::init(Args &args)
// TODO removeint port, std::string readPath, std::string writePath, std::string mapfile, verboseEnum verbosity, char* ip, bool dontGrab, bool fullscreen, int polygonMax)
{
  initShared(args.verbosity, args.fullscreen); // init everything shared between client and server

  if (args.graphicsActive) {
    graphicsActive = true;
    graphics = new GraphicsOpenGL;
    out << VERBOSE_NORMAL << "Initialising graphics...\n";
    graphics->init(out, graphics->makeWindowInfo(0, 0, 100, 100, true, true, 60, 24, args.fullscreen, "Title"),
          "/usr/share/fonts/bitstream-vera/Vera.ttf", 42);
  }else graphicsActive = false;

  client.init(out, args.port, net.getFlagsize(), net.getUnitsize());
  level.init(out, *graphics);
  //map.init(out, *graphics, polygonMax);

/*#ifdef _MSC_VER
  if (mapfile == "") map.load("C:\\temp\\trev\\15152304-MM-topo_00.gml");
  else map.load(mapfile);
#else
  map.load("/usr/not-backed-up/work/map/15152304-MM-topo_01.gml");
  //map.load("C:\\temp\\trev\\18492304-MM-topo_00.gml"); // ripon
#endif*/

  out << VERBOSE_QUIET << "Using ip address: " << args.ip << '\n';

  if (!client.openConnection(args.ip.c_str())) {
    gameover();
    std::cerr << "Could not connect to server at address: " << args.ip << std::endl;
    exit(1);
  }

  if (!args.dontGrab) input.grab();

  // for now just keep these at /tmp
  //readPath = "/tmp";
  //writePath = "/tmp";

  //transfercontrol.setReadPath(readPath);
  //transfercontrol.setWritePath(writePath);

  soundDev.initOutput(out);
  talk.initOutput(out);
  talk.setSoundDev(soundDev);
  if (soundDev.grab() && talk.openCaptureDevice()) {
    talk.setPlayDevice(soundDev.getPlayDevice());
    talk.setCaptureDevice(soundDev.getCaptureDevice());
    talk.initStream();
    out << VERBOSE_LOUD << "Initialised stream.\n";
    //talk.captureStart(); // use this if not using key to talk
  }
  
  out << VERBOSE_QUIET << "Finished init.\n";
}
Esempio n. 23
0
void collision(char **tela, int score_global) {     //Teste para colisões, para finalizar o jogo.
  int i, j, aux, aux_two;
  aux = 0;
	aux_two = 0;

  for(i = 0; i < LINHAS; i++)
    for(j = 0; j < COLUNAS; j++) {
      if(tela[i][j] == 'X') {
        aux++;
      }
      if(tela[i][j] == '@') {
			  aux_two++;
			}
    }
  if(aux < 8) {
  	gameover(tela, score_global);
  }

	if(aux_two < (COLUNAS + COLUNAS) ) {
		gameover(tela, score_global);
	}
}
Esempio n. 24
0
void gameloop(struct game *state)
{

  printf("gameloop: current board '%s' with player %c\n",state->board,state->player);

  displayGame(state);

  if(gameover(state) == 1) {
	return;
  }

  makePlayerMove(state,getPlayerMove(state));

  displayGame(state);

  if(gameover(state) == 1) {
	return;
  }

  makeComputerMove(state);

  gameloop(state);

}
Esempio n. 25
0
int main()
{
    srand(time(NULL));
    mapdisplay(map,player);
    mapdisplay(map,player);
    while(1)
    {
        clear_screen();
        printf("score=%d,hp=%d\n",score,player[hp]);
        mapdisplay(map,player);
        switch (getch())
        {
        case 'w':
        case 'W':
            if(player[Y]-1>=0)
                player[Y]--;
            break;

        case 's':
        case 'S':
            if(player[Y]<=MAPY/2-2)
                player[Y]++;
            break;

        case 'a':
        case 'A':
            if(player[X]-1>=0)
                player[X]--;
            break;

        case 'd':
        case 'D':
            if(player[X]<=MAPX-2)
                player[X]++;
            break;
        }
        if(rand() % 100 + 1<=12)
        {
            if(battle()==0)
            {
                gameover();
                return 0;
            }
        }
    }
    return 0;
}
Esempio n. 26
0
void jump(char **tela, int score_global) {  //Função que cuida da movimentação do "tijolo" para cima.
    int i, j;

    for(i = 0; i < LINHAS; i++)
            for(j = 0; j < COLUNAS; j++) {
                    if(tela[i][j] == 'X') {
			                     if(tela[i - 1][j] == '#') {
				                        gameover(tela, score_global);
			                      }
			                      else {
                                tela[i - 1][j] = 'X';
                                tela[i][j] = '.';
			                      }
                    }
            }
    collision(tela, score_global);
}
Esempio n. 27
0
void Snake::game_loop()
{
	update_positions();
	intersect();
	render();

	if (finished())
	{
		gameover();
		return;
	}

	Timers::oneshot(
		std::chrono::milliseconds(_head_dir.x() == 0 ? 120 : 70),
		[this](auto) { this->game_loop(); }
	);
}
Esempio n. 28
0
// Updates all nescessary sprites, images, buttons etc.
void update(void)
{
    static _Bool called = false;
    GDATAPTR game = get_game_data();
    update_background();
    if(game->gamestarted && game->paused)
    {
        paused(score, survival_time, lives);
    }
    else if(lives == 0)
    {
        gameover(score, survival_time);
    }
    else if(game->gamestarted)
    {
        if(!called)
        {
            //cpSpaceResizeStaticHash(get_global_cpSpace(), 700.0, 4*10);
            cpSpaceAddCollisionHandler(get_global_cpSpace(), 1, 2, collision_begin, NULL, NULL, NULL, NULL);
            cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 2, collision_static_begin, NULL, NULL, NULL, NULL);
            cpSpaceAddCollisionHandler(get_global_cpSpace(), 0, 1, collision_static_begin, NULL, NULL, NULL, NULL);
            called = false;
        }
        logic();
        update_clouds();
        cpSpaceStep(get_global_cpSpace(), 1.0f/60.0f);
        cpSpaceEachBody(get_global_cpSpace(), &update_sprites, NULL);
        update_ground();
        update_lives();
        add_element_to_render_queue(NULL, 0, 0, 0, RCOLOR(0, 0, 0, 255), update_score);
        add_element_to_render_queue(NULL, 290, 0, 0, RCOLOR(0, 0, 0, 255), update_survivaltime);
    }
    else if(game->options)
    {
        options();
    }
    else if(game->howtoplay)
    {
        howtoplay();
    }
    else if(game->highscores)
    {
        highscores();
    }
}
Esempio n. 29
0
void automovedown(void) {
  if (shape_buf != SHPBUF_EMPTY) {
    if (trycreateshape() == 0) {
      createshape();
    } else {
      gameover();
      g_movbuf.shape = -1;
      g_ghost.shape = -1;
    }
    return;
  }

  if (trymove(MOVE_DOWN) == 0) {
    domove(MOVE_DOWN);
  } else {
    steadyall();
  }
}
Esempio n. 30
0
void sig_handler(int s)
{
	alarm(1);
	if(candown(pos_x, pos_y, cur_type, arr)) {
		draw_type(pos_x, pos_y, cur_type, BACK);
		pos_y++;
		draw_type(pos_x, pos_y, cur_type, COLOR);
		draw_grid();
	}else {
		draw_flag(pos_x, pos_y, cur_type, arr);
		if(gameover(arr)) {
			exit(0);
		}
		deleteone(arr);
		pos_x = XNUM/2; pos_y = 0;
		cur_type = rand()%14;
	}
}