void start_cb (GtkWidget * widget, TetWin * tetwin) { tet_window_reset(tetwin); tet_checker_clear_all (tetwin->checker); tet_checker_clear_all (tetwin->preview); tet_checker_fill_all(tetwin->checker,FALSE); Shape cur,next; next=get_shape_type(); tet_window_set_preview (tetwin, next); nextshape = tet_shape_new (tetwin->checker, 0, CHECKER_MID, next); cur=get_shape_type(); curshape = tet_shape_new (tetwin->checker, -1, CHECKER_MID, cur); tetwin->shape=curshape; tetwin->timeout=g_timeout_add(800,(GSourceFunc)timeout_act,tetwin); tetwin->key_sig_no=g_signal_connect(G_OBJECT(tetwin->window), "key-press-event", G_CALLBACK(move_cb), tetwin); gtk_widget_set_sensitive(tetwin->start,FALSE); gtk_widget_set_sensitive(tetwin->pause,TRUE); gtk_widget_set_sensitive(tetwin->stop,TRUE); }
void render_game_area(){ UINT8 x, y, rect_x, rect_y; /*blocks that have fallen down*/ for(x = 0; x < NUM_CELLS_X; x++){ for(y = 0; y < NUM_CELLS_Y; y++){ if(grid[x][y] && grid_tiles[x][y] != 0){ set_ga(x, y, grid_tiles[x][y]); } } } //current block if(has_current_block){ for(x = 0; x < 4; x++){ for(y = 0; y < 4; y++){ if((*get_block_grid())[x][y]){ rect_x = (current_block_pos_x + x); rect_y = (current_block_pos_y + y); set_ga(rect_x, rect_y, get_shape_type() + TILE_BLOCKS_START); } } } } }
bool EditPointOP::OnMouseDrag(int x, int y) { if (ee::ZoomViewOP::OnMouseDrag(x, y)) return true; m_pos = m_stage->TransPosScrToProj(x, y); if (m_captured.shape && get_shape_type(m_captured.shape->GetShapeDesc()) == ST_POINT) { auto point = std::dynamic_pointer_cast<PointShape>(m_captured.shape); point->SetPos(m_pos); ee::SetCanvasDirtySJ::Instance()->SetDirty(); } return false; }
gboolean timeout_act(TetWin*win) { int n_eliminated; CollisionType col; // TetShape*shape=win->shape; TetChecker*checker=win->checker; TetChecker*preview=win->preview; /*fall*/ tet_shape_move_down(win->shape); col=tet_shape_is_collision(win->shape); if(COLLISION_FILL &col){ //can not fall anymore; tet_shape_move_restore(win->shape); n_eliminated=tet_checker_eliminate(checker,win->shape->x); win->score+=n_eliminated; tet_window_set_info(win,"."); tet_shape_free(win->shape); /*get next shape*/ // win->shape=nextshape; tet_window_set_shape(win,nextshape); col=tet_shape_is_collision(win->shape); if(COLLISION_FILL&col){ g_message("GameOver.."); tet_window_over(win); return FALSE; } tet_shape_realize(win->shape); Shape next=get_shape_type(); nextshape=tet_shape_new(checker,0,3,next); tet_window_set_preview(win,next); return TRUE; }else{ tet_shape_realize(win->shape); return TRUE; } }
bool EditPointOP::OnMouseLeftDown(int x, int y) { if (ee::ZoomViewOP::OnMouseLeftDown(x, y)) return true; m_pos = m_stage->TransPosScrToProj(x, y); m_shapes_impl->GetShapeSelection()->Clear(); int tolerance = m_node_capture ? m_node_capture->GetValue() : 0; if (tolerance != 0) { NodeCapture capture(m_shapes_impl, tolerance); capture.captureEditable(m_pos, m_captured); if (m_captured.shape && get_shape_type(m_captured.shape->GetShapeDesc()) == ST_POINT) { m_shapes_impl->GetShapeSelection()->Add(m_captured.shape); } } else { m_captured.Clear(); } return false; }