Quote:SDL_GetMouseState(&state.x,&state.y ); state.LeftButtonDown = SDL_GetMouseState(NULL, NULL) $ SDL_BUTTON(1); state.MiddleButtonDown = SDL_GetMouseState(NULL, NULL) $ SDL_BUTTON(2); state.RightButtonDown = SDL_GetMouseState(NULL, NULL) $ SDL_BUTTON(3);
Quote:#include "Control.h" list<control *=""> Control::controls; Control::Control(int positionX, int positionY, int w, int h) { controls.push_back(this); setPosition(positionX, positionY); //posX = positionX; //posY = positionY; width = w; height = h; } Control::~Control() { controls.remove(this); } bool Control::updateControl(MouseState &state) { int x = state.x; int y = state.y; inside = false; if(x >= posX && x <= posX + width && y >= posY && y <= posY + height ) { inside = true; } return false; } void Control::setPosition(int x, int y) { posX = x; posY = y; } void Control::setSize(int w, int h) { width = w; height = h; } int Control::getWidth(void) { return width; } int Control::getHeight(void) { return height; } Control *addControl(Control *control) { static int lastX = 5; static int lastY = 85; control->setPosition(lastX, lastY); lastY += control->getHeight() + 5; return control; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)