Beispiel #1
0
void OnTimer(HWND hwnd, UINT id)
{
	int isMan;
	if (IsImpact())
	{
		KillTimer(g_hwnd, 1);
		LineClear();
		NextFigure();
		PaintNewFigur();
		if (IsImpact())
		{
			KillTimer(g_hwnd, 1);
			MessageBox(NULL, TEXT("Game Over."), TEXT("Exit"), MB_OK);
		}
		else Repaint();
		return;
	}
	EraseOldFigur();
	if (g_pPozFigure.y<VERTICAL_LINE)g_pPozFigure.y++;
	PaintNewFigur();
	for (int i = 0; i< HORIZONTAL_LINE; i++)
	{
		if (g_iStok[i][24] == 30)
		{
			srand(time(NULL));
			isMan = rand() % 100;
			if (isMan > 70 && man_counter < MAX_MEN)
				CreateThread(NULL, 0, CreateManThread, NULL, 0, NULL);
			break;
		}
	}
}
Beispiel #2
0
void Board::Update()
{
	io_service io;
	deadline_timer t(io, boost::posix_time::milliseconds(lines_info.back().first));
	t.wait();

	y++;

	if (IsCollision())
	{
		y--;
		SaveToBoard(currentShape, x, y);
		NextShape();
	}
	LineClear();
	if(lines_toNextLevel == 0)
	{
		lines_info.pop_back();
		level++;
		lines_toNextLevel = lines_info.back().second;
		speed = lines_info.back().first;
	}
}
Beispiel #3
0
void Update(STATE* state)
{
    time_t rawtime;
    struct tm* timeinfo;

    // update the clock
    time(&rawtime);
    timeinfo = localtime(&rawtime);
    strftime(state->clock, TETRIS_CLOCK_BUFSIZE, "[%H.%M:%S]", timeinfo);

    state->level = state->lines / 10 + state->init_level;
    state->speed = state->init_speed - (state->delta * state->level);

    if (state->game_over_f || state->pause_f)
        return;

    if (state->line_clear_f) {
        if (state->line_clear_t >=
                (state->line_clear_timeout ? state->line_clear_timeout : state->speed)
                || ! state->do_clear) {

            state->line_clear_f = 0;
            LineClear(state);
            EventQuery(state);

        } else if (! state->pause_f) {
            state->line_clear_t ++;
        }
    }

    if (state->tetrad && !TetradUpdate(state)) {
        EventTetrad(state);
    }

    return;
}