Drag and Drop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jade Francis
    New Member
    • Feb 2012
    • 1

    #1

    Drag and Drop

    hi guys I'm desperately needing you help....

    I'm doing a C++ version of Peg Solitaire and i want the peg to be able to DRAG and DROP using the mouse...

    What i did is, i assign move in keyboard functions because i don't have any idea how to implement the DRAG and DROP...pls.... i really need your help...


    here's what i did.....


    Code:
    if( NewBoard )
    {
     
    	for (int i = 0, y = 155; i < 5; i++,y+=70)
    {
    
    	for (int j = 0,x = 350 ; j < 3; j++, x+=90)
    		{
    	if( _2DArray[i][j] != 0)
    	monmon->Render(bbDC,m_spriteDC, x, y);
    
    		}
    
    	}
    	
    	}
    	
    
    //////1st Move;///
    	if(IsBufferedKeyDown('A')|| xxx == 1)
    	{
    		xxx = 1;
    	for (int i = 0, y = 155; i < 5; i++,y+=70)
    	{
    
    	for (int j = 0,x = 350 ; j < 3; j++, x+=90)
    		{
    if(_2DArray[4][0]==1 && _2DArray[4][1]==1||_2DArray[4])
    	{
    		_2DArray[4][0]=0;
    		_2DArray[4][1]=0;
    		_2DArray[4][2]=1;
    	}
    
    	if(_2DArray[i][j] !=0)
    		{
    	monmon->Render(bbDC,m_spriteDC, x, y);
    			}
    			
    		}
    	}
    	NewBoard= false;
    	}
    ///////end of 1st moved
    
    //////////////////2nd Move//////
    
    	 if(IsBufferedKeyDown('S')|| xxx == 2)
    	{
    		xxx = 2;
    	for (int i = 0, y = 155; i < 5; i++,y+=70)
    	{
    
    	for (int j = 0,x = 350 ; j < 3; j++, x+=90)
    		{
    	if(_2DArray[2][1]==1 && _2DArray[3][1]==1)
    			{
    				_2DArray[2][1]=0;
    				_2DArray[3][1]=0;
    				_2DArray[4][1]=1;
    			}
    
    			if(_2DArray[i][j] !=0)
    			{
    	monmon->Render(bbDC,m_spriteDC, x, y);
    			}
    			
    		}
    	}
    	NewBoard= false;
    	}
    	///end of 2nd moved
    PLEASE Help Me.....
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Please do not double post. The reason you have no answers is that you question doesn't really make sense. Your code looks to be fairly pure C++ but "Drag and Drop" is a function of a Graphical User Interface so it is hard to see how it can apply to your program design or your code.

    Comment

    Working...