Permalink
Browse files

boyscouting

  • Loading branch information...
stefanhendriks committed Aug 24, 2013
1 parent c42e635 commit 65dc212f3d0e48aec116cb5d36066c08f14fe255
Showing with 8 additions and 15 deletions.
  1. +2 −3 game.cpp
  2. +4 −7 mouse.cpp
  3. +2 −5 mouse.h
View
@@ -86,7 +86,7 @@ void Game::onEvent(SDL_Event* event) {
if (event->type == SDL_USEREVENT) {
if (event->user.code == D2TM_SELECT) {
- MouseClickedStruct *s = static_cast<MouseClickedStruct*>(event->user.data1);
+ D2TMSelectStruct *s = static_cast<D2TMSelectStruct*>(event->user.data1);
int mx = map_camera->worldCoordinateX(s->x);
int my = map_camera->worldCoordinateY(s->y);
@@ -115,7 +115,7 @@ void Game::onEvent(SDL_Event* event) {
devastator->unselect();
unit->unselect();
} else if (event->user.code == D2TM_BOX_SELECT) {
- MouseDraggedRectStruct *s = static_cast<MouseDraggedRectStruct*>(event->user.data1);
+ D2TMBoxSelectStruct *s = static_cast<D2TMBoxSelectStruct*>(event->user.data1);
int rectX = map_camera->worldCoordinateX(s->start_x);
int rectY = map_camera->worldCoordinateY(s->start_y);
@@ -160,7 +160,6 @@ void Game::render() {
void Game::updateState() {
SDL_PumpEvents();
- mouse.update_state();
if (keyboard.isUpPressed()) map_camera->moveUp();
if (keyboard.isDownPressed()) map_camera->moveDown();
View
@@ -43,7 +43,7 @@ void Mouse::onEvent(SDL_Event* event) {
if (dragging_rectangle()) {
SDL_Event clickEvent;
- MouseDraggedRectStruct *s;
+ D2TMBoxSelectStruct *s;
int start_x = rect_x;
int start_y = rect_y;
@@ -53,7 +53,7 @@ void Mouse::onEvent(SDL_Event* event) {
if (end_x < start_x) swap(end_x, start_x);
if (end_y < start_y) swap(end_y, start_y);
- s = new MouseDraggedRectStruct;
+ s = new D2TMBoxSelectStruct;
s->start_x = start_y;
s->start_y = start_y;
s->end_x = end_x;
@@ -68,9 +68,9 @@ void Mouse::onEvent(SDL_Event* event) {
} else {
SDL_Event clickEvent;
- MouseClickedStruct *s;
+ D2TMSelectStruct *s;
- s = new MouseClickedStruct;
+ s = new D2TMSelectStruct;
s->x = event->button.x;
s->y = event->button.y;
@@ -106,9 +106,6 @@ void Mouse::onEvent(SDL_Event* event) {
}
-void Mouse::update_state() {
-}
-
void Mouse::draw(SDL_Surface* screen) {
if (state == MOUSE_POINTING) {
if (dragging_rectangle()) rectangleRGBA(screen, rect_x, rect_y, _x, _y, 255, 255, 255, 255);
View
@@ -14,15 +14,15 @@ const int MOUSE_ORDER_MOVE = 1;
typedef struct {
int x;
int y;
-} MouseClickedStruct;
+} D2TMSelectStruct;
typedef struct {
int start_x;
int start_y;
int end_x;
int end_y;
-} MouseDraggedRectStruct;
+} D2TMBoxSelectStruct;
class Mouse {
@@ -32,12 +32,9 @@ class Mouse {
void onEvent(SDL_Event* event);
- void update_state();
-
bool left_button_clicked() { return _left_button_clicked; }
bool right_button_clicked() { return _right_button_clicked; }
-
void state_pointing() { state = MOUSE_POINTING; }
void state_order_move() { state = MOUSE_ORDER_MOVE; }

0 comments on commit 65dc212

Please sign in to comment.