Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GameField::handleEvents(SDL_Event & event) {
- int x = 0,
- y = 0;
- int x_pos = 0,
- y_pos = 0;
- int cols = 0,
- rows = 0;
- if (event.type == SDL_MOUSEBUTTONDOWN) {
- if (event.button.button == SDL_BUTTON_LEFT) {
- x = event.button.x;
- y = event.button.y;
- for (int b = 0; b < BOX_MAX; b++) {
- x_pos = ((BOX_SPRITE_WIDTH * cols) + BOX_SPRITE_WIDTH);
- y_pos = ((BOX_SPRITE_HEIGHT * rows) + BOX_SPRITE_HEIGHT);
- if (x >= GameField::box[b].x && x <= x_pos) {
- if (y >= GameField::box[b].y && y <= y_pos) {
- if (GameField::box[b].type == EMPTY) {
- GameField::box[b].type = CIRCLE;
- for (int bb = 0; bb < BOX_MAX; bb++) {
- if (GameField::box[bb].last == true) {
- GameField::box[bb].last = false;
- }
- }
- GameField::box[b].last = true;
- }
- break;
- }
- }
- if (cols == (BOX_MAX_COLS - 1)) {
- if (rows == (BOX_MAX_ROWS - 1))
- rows = 0;
- else
- rows++;
- cols = 0;
- } else {
- cols++;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment