Ejemplo n.º 1
0
// Update button based on events
int Button::update(SDL_Event event)
{
	int x = 0;
	int y = 0; 
	if( event.type == SDL_MOUSEBUTTONDOWN )
	{
		if( event.button.button == SDL_BUTTON_LEFT )
		{
			x = event.button.x; 
			y = event.button.y;
			if( ( x > getX()) && ( x < getX() + getWidth() ) && ( y > getY() ) && ( y < getY() + getHeight() ) ) 
			{
				setBoxColor(255, 255, 0);
				//return 1;
			}
		}
	}

	else if( event.type == SDL_MOUSEBUTTONUP )
	{
		if( event.button.button == SDL_BUTTON_LEFT )
		{
			x = event.button.x; 
			y = event.button.y;
			if( ( x > getX()) && ( x < getX() + getWidth() ) && ( y > getY() ) && ( y < getY() + getHeight() )) 
			{
				setBoxColor(255, 255, 255);
				return 1;
			}
		}
	}
	return 0;
}
Ejemplo n.º 2
0
Box::Box(Renderer *renderer,  int x, int y, int w, int h, D3DCOLOR color, bool show)
	: RenderBase(renderer), m_bShown(false)
{
	setPos(x, y);
	setBoxWidth(w);
	setBoxHeight(h);
	setBoxColor(color);
	setShown(show);

	setBoxColor(color);
	setBorderWidth(0);
	setBorderShown(false);
}