Exemplo n.º 1
0
/**
  * @brief Function to get from the user the command he wants (network, join, messaging etc...
  * @param p_structCommon : Struct with all program informations
  */
void userCommandGetter(structProgramInfo* p_structCommon)
{
    if(p_structCommon->sUserCommand != NULL)
    {
        free(p_structCommon->sUserCommand);
        p_structCommon->sUserCommand = NULL;
    }
    p_structCommon->sUserCommand = (char*)malloc((USER_COMMAND_LENGHT + 1) * sizeof(char));
    if(p_structCommon->sUserCommand == NULL)
    {
        log_err("No more memory available... End%s", " ");
        exit(ENOMEM);
    }
    bzero(p_structCommon->sUserCommand, USER_COMMAND_LENGHT + 1);

    /* ncurses options to display input & display the cursor */
    echo();
    curs_set(1);
    nodelay(stdscr, 0);

    drawElement(0, p_structCommon->iRow - 2, ':', enumLogLine);
    drawElement(1, p_structCommon->iRow - 2, '>', enumLogLine);
    mvscanw(p_structCommon->iRow - 2, 3,"%[^\n]", p_structCommon->sUserCommand);

    /* ncurses options to undo modifications */
    nodelay(stdscr, 1);
    curs_set(0);
    noecho();
}
Exemplo n.º 2
0
/**
 * Draw a single layer
 * @param cr Draw to thgis context
 * @param l The layer to draw
 */
void DocumentView::drawLayer(cairo_t* cr, Layer* l)
{
	XOJ_CHECK_TYPE(DocumentView);

	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);

#ifdef DEBUG_SHOW_REPAINT_BOUNDS
	int drawed = 0;
	int notDrawed = 0;
#endif // DEBUG_SHOW_REPAINT_BOUNDS
	for (Element* e : *l->getElements())
	{
#ifdef DEBUG_SHOW_ELEMENT_BOUNDS
		cairo_set_source_rgb(cr, 0, 1, 0);
		cairo_set_line_width(cr, 1);
		cairo_rectangle(cr, e->getX(), e->getY(), e->getElementWidth(), e->getElementHeight());
		cairo_stroke(cr);
#endif // DEBUG_SHOW_REPAINT_BOUNDS
		//cairo_new_path(cr);

		if (this->lX != -1)
		{
			if (e->intersectsArea(this->lX, this->lY, this->width, this->height))
			{
				drawElement(cr, e);
#ifdef DEBUG_SHOW_REPAINT_BOUNDS
				drawed++;
#endif // DEBUG_SHOW_REPAINT_BOUNDS
			}
#ifdef DEBUG_SHOW_REPAINT_BOUNDS
			else
			{
				notDrawed++;
			}
#endif // DEBUG_SHOW_REPAINT_BOUNDS

		}
		else
		{
#ifdef DEBUG_SHOW_REPAINT_BOUNDS
			drawed++;
#endif // DEBUG_SHOW_REPAINT_BOUNDS
			drawElement(cr, e);
		}
	}

#ifdef DEBUG_SHOW_REPAINT_BOUNDS
	g_message("DBG:DocumentView: draw %i / not draw %i", drawed, notDrawed);
#endif // DEBUG_SHOW_REPAINT_BOUNDS
}
Exemplo n.º 3
0
void imageElement::draw(int x, int y, float _scale) {
    ofPushMatrix();
    ofTranslate(x + position.x * _scale, y + position.y * _scale );
    ofRotateZ(this->rotation);
    drawElement(_scale);
    ofPopMatrix();
}
Exemplo n.º 4
0
void imageElement::draw() {
    ofPushMatrix();
    ofTranslate(position.x, position.y);
    ofRotateZ(this->rotation);
    drawElement(1.0f);
    ofPopMatrix();
}
Exemplo n.º 5
0
void drawLevel (Level* level)
{
    int i, j;

    for (i=0; i<LEVEL_MAX_HEIGHT; i++)
    {
        for (j=0; j<LEVEL_MAX_WIDTH; j++)
        {
            drawElement(i, j, level->elements[i][j]);
        }
    }

    drawElement(level->hero.position.x, level->hero.position.y, re_hero);
    drawMessage(level);
    refresh();
}
Exemplo n.º 6
0
void SphereSet::draw(RenderContext* renderContext)
{
  material.beginUse(renderContext);

  for(int i=0;i<center.size();i++) drawElement(renderContext, i);
  
  material.endUse(renderContext);
}
Exemplo n.º 7
0
void DocumentView::drawSelection(cairo_t* cr, ElementContainer* container)
{
	XOJ_CHECK_TYPE(DocumentView);

	for (Element* e : *container->getElements())
	{
		drawElement(cr, e);
	}
}
Exemplo n.º 8
0
void 
drawGroup(e2dGroup* group)  {
    e2dGroupIterator iter = e2dGroupGetChildIterator(group);
    while(e2dGroupIteratorHasNext(&iter))  {
        drawElement(e2dGroupIteratorNext(&iter));
    }
    drawAxis();
    drawRect(group->element.bboxPosition, group->element.bboxWidth, group->element.bboxHeight);
}
Exemplo n.º 9
0
void
drawClone(e2dClone* clone) {
    glPushMatrix();
    glTranslatef((clone->position).x, (clone->position).y, 0);
    drawElement(clone->pointsToElement);
    glPopMatrix();
    drawAxis();
    drawRect(clone->element.bboxPosition, clone->element.bboxWidth, clone->element.bboxHeight);
}
Exemplo n.º 10
0
//--------------------------------------------------------------
void Calligraphy::draw() {

    drawElement( baseArch->framesCenter[11][5].x, baseArch->framesCenter[11][5].y, 255 );

    for (int i=0; i<calligraphies.size(); i++) {
        int _h = ofMap(i, 0, 110, 0, 255);

        calligraphies[i].drawElement( calliPos[i].x, calliPos[i].y, _h );
    }

}
Exemplo n.º 11
0
void Shape::draw(RenderContext* renderContext)
{ 
  drawBegin(renderContext);
  SAVEGLERROR;
  
  for(int i=0;i<getElementCount();i++) 
    drawElement(renderContext, i);
    
  SAVEGLERROR;  
  drawEnd(renderContext);
  SAVEGLERROR;
}
Exemplo n.º 12
0
void SphereSet::renderZSort(RenderContext* renderContext)
{
  std::multimap<float,int> distanceMap;
  for (int index = 0 ; index < center.size() ; ++index ) {
    float distance = renderContext->getDistance( center.get(index) );
    distanceMap.insert( std::pair<float,int>(-distance,index) );
  }

  material.beginUse(renderContext);
  for ( std::multimap<float,int>::iterator iter = distanceMap.begin(); iter != distanceMap.end() ; ++ iter ) {
    drawElement( renderContext, iter->second );
  }  
  material.endUse(renderContext);
}
Exemplo n.º 13
0
void PrimitiveSet::renderZSort(RenderContext* renderContext)
{
  // sort by z-depth
  
  std::multimap<float,int> distanceMap;
  for (int index = 0 ; index < nprimitives ; ++index ) {
    float distance = renderContext->getDistance( getCenter(index) );
    distanceMap.insert( std::pair<float,int>(-distance,index) );
  }

  // render ordered

  drawBegin(renderContext);
  
  for ( std::multimap<float,int>::iterator iter = distanceMap.begin(); iter != distanceMap.end() ; ++ iter ) {
    drawElement( renderContext, iter->second );
  }  
  
  drawEnd(renderContext);
}
Exemplo n.º 14
0
bool  xSceneHelperDrawable::drawImm(IBaseRenderer* pRenderer, unsigned int passedTime, xGeomLib::xCamera* pCamera)
{
	IDrawElement*   pDrawElement = drawElement(0);
	IRenderEffect*  pEffect      = effect(0);

	if(pDrawElement && pCamera && false == pDrawElement->isVisible(pCamera , m_trans) )
		return false; 

	if(pEffect )
	{
		pEffect->drawImm(pDrawElement  , this , passedTime );
		return true;
	}
	else
	{
		m_Pass.setRenderer( pRenderer );
		m_Pass.setDrawable(pDrawElement);
		m_Pass.setRenderPassArg( this );
		pRenderer->drawPass(  &m_Pass , passedTime , true);	
	}
	return false;
}
Exemplo n.º 15
0
bool     xSceneHelperDrawable::draw(IBaseRenderer* pRenderer , xGeomLib::xCamera* pCamera)
{
	IDrawElement*   pDrawElement = drawElement(0);
	IRenderEffect*  pEffect      = effect(0);

	if(pDrawElement && pCamera && false == pDrawElement->isVisible(pCamera , m_trans) )
		return false; 

	if(pEffect )
	{
		pEffect->draw(pDrawElement  , this);
		return true;
	}
	else
	{
		m_Pass.setRenderer( pRenderer  );
		m_Pass.setDrawable(pDrawElement);
		m_Pass.setRenderPassArg( this );
		pRenderer->drawPass( xStringHash(L"overlay") , &m_Pass);	
	}
	return false;
}
Exemplo n.º 16
0
/** @brief	To clean a layer of the grid
  * @param p_iLayerOrig : analyse informations of this layer
  * @param p_iLayerDest : to modify this layer
  * @param p_iFillingValue : value to put in the grid
  * @param p_iToReplace : kind of point to replace in the selected grid. POINT_ALL is the default behavior
  * @param p_structCommon : Struct with all program informations
  */
void cleanGridLayer(unsigned int p_iLayerOrig,
                    int p_iToReplace,
                    unsigned int p_iLayerDest,
                    int p_iFillingValue,
                    structProgramInfo* p_structCommon)
{
    unsigned int l_iX;
    unsigned int l_iY;


    for(l_iY = 0; l_iY < p_structCommon->iSizeY ; l_iY++)
    {
        for(l_iX = 0; l_iX < p_structCommon->iSizeX ; l_iX++)
        {
            if(p_iToReplace == POINT_ALL)
            {
                p_structCommon->cGrid[p_iLayerDest][l_iY][l_iX] =  p_iFillingValue;
            }
            else
            {
                if(p_structCommon->cGrid[p_iLayerOrig][l_iY][l_iX] == p_iToReplace)
                {
                    p_structCommon->cGrid[p_iLayerDest][l_iY][l_iX] = p_iFillingValue;
                }
                if(p_iLayerDest == COLOR_MATRIX &&
                   p_structCommon->cGrid[p_iLayerOrig][l_iY][l_iX] == p_iToReplace)
                {
    				/* Draw the block of the current user (the other blocks are draw by
    				   another function) */
                    drawElement(l_iX + p_structCommon->iOffsetX, l_iY + p_structCommon->iOffsetY,
                        p_structCommon->cGrid[TEXT_MATRIX][l_iY][l_iX],
                        p_iFillingValue);
                }
            }
        }
    }
}
Exemplo n.º 17
0
void BaseElement::draw()
{
    glPushMatrix();
        // Translate to the correct location
        glTranslatef(x, y, z);
        
        glPushMatrix();
            // Set the rotation of the element
            glRotatef(rotation, 0, 0, 1);
            
            // Set the color of the element
            glColor4f(color->color.red,color->color.green,color->color.blue, color->color.alpha);
            glPointSize(1);
            
            // Draw the Element
            drawElement();
           
            // Draw the bounding box corners if selected
            if(selected || moveable)
            {
                drawCorners();
            }  
    
        glPopMatrix();
    
    glFlush();
    glPopMatrix();
    
    //DEBUG - bounds
    /*if(selected || moveable)
    {
        glPushMatrix();
        bounds->draw(selectedCorner);
        glPopMatrix();
    }*/
    //DEBUG - bounds
}
Exemplo n.º 18
0
bool     xSceneSerializeObject::draw(IBaseRenderer* pRenderer , xGeomLib::xCamera* pCamera)
{
	int _nElement = this->nDrawElement();
	IRenderEffect* pEffect = this->effect();
	for(int i = 0 ; i  < _nElement ; i ++ )
	{
		IDrawElement*   pDrawElement = drawElement(i);

		if(pDrawElement && pCamera && false == pDrawElement->isVisible( pCamera , m_trans ) )
			continue ;
		if(pEffect)
		{
			pEffect->draw(pDrawElement , this);
		}
		else
		{
			m_Pass.setRenderer( pRenderer  );
			m_Pass.setDrawable( pDrawElement );
			m_Pass.setRenderPassArg( this );
			pRenderer->drawPass( xStringHash(L"default") , &m_Pass);
		}
	}
	return true;
}
Exemplo n.º 19
0
bool  xSceneSerializeObject::drawImm(IBaseRenderer* pRenderer, unsigned int passedTime, xGeomLib::xCamera* pCamera)
{
	int _nElement = this->nDrawElement();
	IRenderEffect* pEffect = this->effect();
	for(int i = 0 ; i  < _nElement ; i ++ )
	{
		IDrawElement*   pDrawElement = drawElement(i);

		if(pDrawElement && pCamera && false == pDrawElement->isVisible( pCamera , m_trans ) )
			continue ;
		if(pEffect)
		{
			pEffect->drawImm(pDrawElement  , this , passedTime);
		}
		else
		{
			m_Pass.setRenderer(pRenderer );
			m_Pass.setDrawable(pDrawElement);
			m_Pass.setRenderPassArg( this );
			pRenderer->drawPass( &m_Pass , passedTime , true);	
		}
	}
	return false;
}
Exemplo n.º 20
0
	void SDL_Canvas::drawEnviroment(vector<EnviromentElement>& enviroment) 
	{	
		vector<EnviromentElement>::iterator it;
		for(it = enviroment.begin(); it != enviroment.end(); it++)
			drawElement(*it);
	}
Exemplo n.º 21
0
void
MeshEdgeElementTable::drawElement(Renderer* renderer, int index, bool selected)
{
  drawElement(renderer, index, 1, selected);
}
Exemplo n.º 22
0
void Map::draw()
{
	int xPosition;//For each different ship displayed on the radar.
	int yPosition;

	float divisorX = (game->sectorWidth/2 - game->screenWidth)/xCenter;//sets the accuracy of the map (aka the zoom)
	float divisorY = (game->sectorHeight/2 - game->screenHeight)/yCenter;

	glEnable (GL_TEXTURE_2D);//needed to render the texture

	glEnable (GL_BLEND);//This eliminates the black background
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	xPosition = ((game->player.ship.trueX) - game->screenWidth)/divisorX + xCenter;//We draw the player ship in the center of the radar display
	yPosition = ((game->player.ship.trueY) - game->screenHeight)/divisorY + yCenter;
	xPosition -= (-(game->screenWidth/2))/divisorX;//This is to make it match up with the player's position on the radar
	yPosition -= (-(game->screenHeight/2))/divisorY;

	drawElement (xPosition, yPosition, 0, 0, 1);//Draw the player

	xPosition = ((game->player.destinationXPos) - game->screenWidth)/divisorX + xCenter;//We draw the player ship in the center of the radar display
	yPosition = ((game->player.destinationYPos) - game->screenHeight)/divisorY + yCenter;
	xPosition -= (-(game->screenWidth/2))/divisorX;//This is to make it match up with the player's position on the radar
	yPosition -= (-(game->screenHeight/2))/divisorY;

	drawElement (xPosition, yPosition, 1, 0, 0);

	
	//Draw all the stars in yellow
	for (int i = 0; i < game->solarSystem.system.size(); i++)
	{
		xPosition = ((game->solarSystem.system[i]->sun.xPos + game->player.ship.trueX - game->screenWidth) - game->screenWidth)/divisorX + xCenter;//We draw the player ship in the center of the radar display
		yPosition = (game->solarSystem.system[i]->sun.yPos + game->player.ship.trueY - game->screenHeight)/divisorY + yCenter;
		xPosition -= (-(game->screenWidth/2))/divisorX;//This is to make it match up with the player's position on the radar
		yPosition -= (-(game->screenHeight/2))/divisorY;
		
		float rGov = game->solarSystem.system[i]->planet[0]->controllingGovernment->r;
		float gGov = game->solarSystem.system[i]->planet[0]->controllingGovernment->g;
		float bGov = game->solarSystem.system[i]->planet[0]->controllingGovernment->b;
		
		/*for (int a = 0; a < game->government.gov.size(); a++)
		{
			if (game->solarSystem.system[i]->planet[0]->controllingGovernment == game->government.gov[a])
			{
				if (a == 0)
				{
					r = 1;
					g = 0;
					b = 0;
				}
				if (a == 1)
				{
					r = 0;
					g = 1;
					b = 0;
				}
				if (a == 2)
				{
					r = 0;
					g = 0;
					b = 1;
				}
				if (a == 3)
				{
					r = 1;
					g = 1;
					b = 0;
				}
				if (a == 4)
				{
					r = 1;
					g = 0;
					b = 1;
				}
				if (a == 5)
				{
					r = 0;
					g = 1;
					b = 1;
				}

			}
		}*/
		drawElement (xPosition, yPosition, rGov, gGov, bGov);//Draw the star in whatever color the controlling govt. is
	}

	glColor3f (0, 0, 0);//set the colour back to black
	glDisable(GL_BLEND);
	glDisable(GL_TEXTURE_2D);
}
Exemplo n.º 23
0
/** @brief	The game loop function
  * @param  p_structCommon : Struct with all program informations
  */
void playGame(structProgramInfo* p_structCommon)
{
	unsigned char l_cKey;
    char* l_sTopText;
    unsigned int l_iWatchdog;
	unsigned int l_iCursorX;
	unsigned int l_iCursorY;
    unsigned int l_iMovement;	/* store the wanted move, if impossible this variable */
    unsigned int l_iCurrentSocketIndex;		/* allow the program to go back */
    int l_iNewCoordinates;
    char l_bForceRedraw;

    l_bForceRedraw = TRUE;
	l_cKey = 0;
    l_iNewCoordinates = -1;
	l_iMovement = 0;
	l_iCursorX = 1;
	l_iCursorY = 1;
    p_structCommon->iLastXUsed = l_iCursorX;
    p_structCommon->iLastYUsed = l_iCursorY;
    l_iCurrentSocketIndex = 0;
	p_structCommon->iOffsetX = (p_structCommon->iCol / 2) - (p_structCommon->iSizeX / 2);
	p_structCommon->iOffsetY = (p_structCommon->iRow / 2) - (p_structCommon->iSizeY / 2);
    l_sTopText = (char*)malloc((p_structCommon->iCol + 1) * sizeof(char));
    if(l_sTopText == NULL) exit(-ENOMEM);

	p_structCommon->iCurrentUserColor = enumRouge; /* Main user, or server always red. If multiplayer and client, it receive another color suring connection  */
    p_structCommon->cUserMove = 0;

	/* Init the game, screen stuff etc... */
	gameInit(p_structCommon);

	do
	{
        snprintf(   l_sTopText,
                    p_structCommon->iCol,
                    "Your turn to play [ ] | Connected [ ] | Current port [%d] | Nickname %s",
                    p_structCommon->iTcpPort,
                    p_structCommon->sUserName);
        if(p_structCommon->bMyTurnToPlay == TRUE)
        {
            l_sTopText[19] = 'X';
        }
        else
        {
            l_sTopText[19] = ' ';
        }

        if(p_structCommon->bMutexInitialized == TRUE)
        {
            l_sTopText[35] = 'X';
        }
        else
        {
            l_sTopText[35] = ' ';
        }

        if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_lock(p_structCommon->pthreadMutex);}
        usleep(TIME_BETWEEN_TWO_REQUEST);
        initBar();
        topText(l_sTopText);

		/* Display wursor each time */
		displayCursor(l_iCursorX, l_iCursorY, p_structCommon->iOffsetX, p_structCommon->iOffsetY, FALSE, p_structCommon->cGrid);
        pointCounting(p_structCommon->cGrid, p_structCommon->iPoints, p_structCommon->iSizeX, p_structCommon->iSizeY);
        displayRanking(p_structCommon->iPoints, p_structCommon->iCol, p_structCommon->iRow);
        topText(l_sTopText);
		refresh();
        usleep(TIME_BETWEEN_TWO_REQUEST);
        if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_unlock(p_structCommon->pthreadMutex);}

		l_cKey = getch();

        /* In order to allow an alone player to play alone */
        if(p_structCommon->bMutexInitialized == FALSE)
        {
            p_structCommon->bMyTurnToPlay = TRUE;
        }

		switch(l_cKey)
		{

			case 'D':
			{
				/* LEFT */
				l_iCursorX = (l_iCursorX < 1) ? p_structCommon->iSizeX - 1 : l_iCursorX - 1;
                p_structCommon->cUserMove = 'd';
				l_iMovement = DIRECTION_LEFT;
				break;
			}
			case 'C':
			{
				/* RIGHT */
				l_iCursorX = (l_iCursorX > p_structCommon->iSizeX - 2) ?
                    0 : l_iCursorX + 1;
                p_structCommon->cUserMove = 'c';
				l_iMovement = DIRECTION_RIGHT;
				break;
			}
			case 'A':
			{
				/* UP */
				l_iCursorY = (l_iCursorY < 1) ? p_structCommon->iSizeY - 1 : l_iCursorY - 1;
                p_structCommon->cUserMove = 'a';
				l_iMovement = DIRECTION_UP;
				break;
			}
			case 'B':
			{
				/* DOWN */
				l_iCursorY = (l_iCursorY > p_structCommon->iSizeY - 2) ?
                    0 : l_iCursorY + 1;
                p_structCommon->cUserMove = 'b';
				l_iMovement = DIRECTION_DOWN;
				break;
			}
            case ':':
            {
                /* Command mode */
                l_bForceRedraw = TRUE;
                logBar(p_structCommon, CLEAN_L2, "");
                if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_lock(p_structCommon->pthreadMutex);}
                logBar(p_structCommon, DISPLAY, "");
                if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_unlock(p_structCommon->pthreadMutex);}

                /* Get command from the user, the command set by the user will be saved in p_structCommon->sUserCommand */
                userCommandGetter(p_structCommon);
                /* Analyse user command */
                l_iNewCoordinates = userCommandExecute(p_structCommon);
                if(l_iNewCoordinates > - 1)
                {
                    if(l_iNewCoordinates > - 1 && l_iNewCoordinates < (signed)p_structCommon->iSizeX)
                    {
                        /* belongs to the interval [0 ; p_structCommon->iSizeX[ ==> redefine X coordinate */
                        l_iCursorX = l_iNewCoordinates;
                        l_bForceRedraw = FALSE;
                    }
                    else if(l_iNewCoordinates >= (signed)p_structCommon->iSizeX &&
                            l_iNewCoordinates < (signed)p_structCommon->iSizeX + (signed)p_structCommon->iSizeY)
                    {
                        /* belongs to the interval [p_structCommon->iSizeX ; p_structCommon->iSizeX + p_structCommon->iSizeY[ ==> redefine Y coordinate */
                        l_iCursorY = l_iNewCoordinates - (p_structCommon->iSizeX);
                        l_bForceRedraw = FALSE;
                    }
                }

                if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_lock(p_structCommon->pthreadMutex);}
                displayCursor(l_iCursorX, l_iCursorY, p_structCommon->iOffsetX, p_structCommon->iOffsetY, l_bForceRedraw, p_structCommon->cGrid);
                refresh();

                /* Clean the screen */
                logBar(p_structCommon, DISPLAY, "");
                if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_unlock(p_structCommon->pthreadMutex);}
                break;
            }
            case 'q':
            case 'Q':
            {
                p_structCommon->bNetworkDisconnectionRequiered = TRUE;

                /* Started threads have to down this flag -- bMutexInitialized means we have at least one thread started */
                while(p_structCommon->bNetworkDisconnectionRequiered == TRUE &&
                      p_structCommon->bMutexInitialized == TRUE)
                {
                    usleep(TIME_BETWEEN_TWO_REQUEST);
                    for(l_iCurrentSocketIndex = 0; l_iCurrentSocketIndex < MAX_CONNECTED_CLIENTS ; l_iCurrentSocketIndex++)
                    {
                        if(p_structCommon->iClientsSockets[l_iCurrentSocketIndex] != 0)
                        {
                            break;
                        }
                    }
                    if(l_iCurrentSocketIndex >= MAX_CONNECTED_CLIENTS - 1)
                    {
                        break;
                    }
                }   
                break;

                /* Normally, network.c have clean the mutex at the end of all connexions */
                if(p_structCommon->bMutexInitialized == TRUE)
                {
                    pthread_mutex_destroy(p_structCommon->pthreadMutex);
                    p_structCommon->bMutexInitialized = FALSE;
                }
            }
			case ' ':
			{
                if(p_structCommon->bMyTurnToPlay != TRUE)
                {
                    break;
                }

				/* When the user drop a rock */
                p_structCommon->cUserMove = 'r';
                p_structCommon->iLastXUsed = l_iCursorX;
                p_structCommon->iLastYUsed = l_iCursorY;

				/* Put the color information in the matrix */
				p_structCommon->cGrid[COLOR_MATRIX][l_iCursorY][l_iCursorX] =
					p_structCommon->iCurrentUserColor;

				/* Put the text information in the matrix */
				p_structCommon->cGrid[TEXT_MATRIX][l_iCursorY][l_iCursorX] =
					' ';

                /* declare this point to be synchronized with all clients */
                p_structCommon->cGrid[SYNC_MATRIX][l_iCursorY][l_iCursorX] = POINT_TO_SYNC;

                /* Draw the block of the current user (the other blocks are draw by
                    another function) */
                if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_lock(p_structCommon->pthreadMutex);}
				drawElement(l_iCursorX + p_structCommon->iOffsetX, l_iCursorY + p_structCommon->iOffsetY,
					p_structCommon->cGrid[TEXT_MATRIX][l_iCursorY][l_iCursorX],
					p_structCommon->iCurrentUserColor);
                if(p_structCommon->bMutexInitialized != TRUE) {pthread_mutex_unlock(p_structCommon->pthreadMutex);}

                /* Check neighborhood - If there is two contigous blocks of the player's
                   color that means there is maybee a loop */
                loopCompletion(l_iCursorX, l_iCursorY, p_structCommon->iCurrentUserColor, p_structCommon);

                /* Reset this player turn */
                p_structCommon->bMyTurnToPlay = FALSE;
                break;
			}

			default:
			{
				/* Else, do nothing */
				break;
			}
		}

		/* Check code, in order to forbid access to already reserved boxes */
		if((unsigned int)p_structCommon->cGrid[COLOR_MATRIX][l_iCursorY][l_iCursorX] != enumNoir)
		{
			/* So there is something here and it is not me */
			switch(l_iMovement)
			{
				case DIRECTION_UP:
				l_iCursorY++;
				break;
				case DIRECTION_DOWN:
				l_iCursorY--;
				break;
				case DIRECTION_LEFT:
				l_iCursorX++;
				break;
				case DIRECTION_RIGHT:
				l_iCursorX--;
				break;
				default:
				/* Who, error ! */
				perror("Unknown code");
				break;
			}

			/* If we go out of the screen by the upper or wester side put it in 0:0 and
			let the next block check if this block is empty or not */
			if(l_iCursorY >= p_structCommon->iSizeY || l_iCursorX >= p_structCommon->iSizeX)
			{
				l_iCursorX = 0;
				l_iCursorY = 0;
			}

			/* If with bad luck you go over the grid */
            l_iWatchdog = 0;
			while((unsigned int)p_structCommon->cGrid[COLOR_MATRIX][l_iCursorY][l_iCursorX] != enumNoir)
			{
				/* Find random coordinate with the simplest way */
				l_iCursorX = rand() % p_structCommon->iSizeX;
				l_iCursorY = rand() % p_structCommon->iSizeY;

                l_iWatchdog++;
                if(l_iWatchdog > (p_structCommon->iSizeX * p_structCommon->iSizeY) / 2)
                {
                    if(isTheGridFull(p_structCommon) == TRUE)
                    {
                        endOfTheGame(p_structCommon);
                        return;
                    }
                }
			}
		}
	}while((l_cKey != 'q') && (l_cKey != 'Q'));		/* until q/Q pressed */

    free(l_sTopText);

}