LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: { hdc = GetDC(hWnd); GetClientRect(hWnd,&rect); int ret = SetTimer(hWnd, TIMER_ID, 5, NULL); initFigures(); break; } case WM_PAINT: { BeginPaint(hWnd, &ps); Paint(hWnd, &ps); EndPaint(hWnd, &ps); } break; case WM_LBUTTONDOWN: { Figure *figure; figure = new Figure(rand()%rect.right, rand()%rect.bottom, 100, 100); figure->setCircle(false); figure->setDir(rand()%4); figure->setVelocity(rand()%8 + 1); figure->setColor(rand()%250, rand()%250, rand()%250); vec.push_back(*figure); vectorSize++; break; } case WM_MOUSEWHEEL : { int deltaZ = (short) HIWORD(wParam); if(deltaZ > 0) { velocity += 2; }else { if(velocity > 0) velocity -= 2; } break; } case WM_TIMER: { InvalidateRect(hWnd, &rect, FALSE); } break; case WM_DESTROY: { KillTimer(hWnd, TIMER_ID); PostQuitMessage(0); return 0; } } return DefWindowProc(hWnd, msg, wParam, lParam); }
Board::Board() : m_figures( std::move( initFigures() ) ) , m_whiteKing( static_cast< King* > ( m_figures.at( 20 ).data() ) ) , m_blackKing( static_cast< King* > ( m_figures.at( 4 ).data() ) ) { newGame(); }
Board::Board( const Board & other ) : QAbstractListModel( Q_NULLPTR ) , m_figures( std::move( initFigures() ) ) , m_whiteKing( static_cast< King* > ( m_figures.at( 20 ).data() ) ) , m_blackKing( static_cast< King* > ( m_figures.at( 4 ).data() ) ) { copyState( other ); }
Board & Board::operator = ( const Board & other ) { if( this != &other ) { m_figures = std::move( initFigures() ); m_whiteKing = static_cast< King* > ( m_figures.at( 20 ).data() ); m_blackKing = static_cast< King* > ( m_figures.at( 4 ).data() ); copyState( other ); } return *this; }
Board::Board(Player* white, Player* black, AMFWriter* streamWriter ) { whitePlayer = white; blackPlayer = black; white->board = this; black->board = this; //init white and black figures for (unsigned int i = 0; i < 8; i++) { for( unsigned int j = 0; j < 8; j++) { boardState[i][j] = NULL; } } initFigures(streamWriter); //TODO: implement fog moveTurn = Figure::WHITE; }