X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmousecursor.cpp;h=ff794b206b018b7a73120b145d1b2ade05214ada;hb=157cef71aeb9ae25b7bb90f37dda11bc09329d11;hp=91f727bebac1e307a5570927c11cc9a95efe8730;hpb=8fa514bf18494f19ca1fbae3512354f0fab22bce;p=supertux.git diff --git a/src/mousecursor.cpp b/src/mousecursor.cpp index 91f727beb..ff794b206 100644 --- a/src/mousecursor.cpp +++ b/src/mousecursor.cpp @@ -1,29 +1,38 @@ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -// by Ricardo Cruz +// $Id$ +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Ricardo Cruz +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "screen.h" #include "mousecursor.h" -MouseCursor::MouseCursor(std::string cursor_file, int frames) +MouseCursor* MouseCursor::current_ = 0; + +MouseCursor::MouseCursor(std::string cursor_file, int frames) : mid_x(0), mid_y(0) { cursor = new Surface(cursor_file, USE_ALPHA); - + cur_state = MC_NORMAL; cur_frame = 0; tot_frames = frames; timer.init(false); timer.start(MC_FRAME_PERIOD); - + SDL_ShowCursor(SDL_DISABLE); } @@ -44,6 +53,12 @@ void MouseCursor::set_state(int nstate) cur_state = nstate; } +void MouseCursor::set_mid(int x, int y) +{ + mid_x = x; + mid_y = y; +} + void MouseCursor::draw() { int x,y,w,h; @@ -73,5 +88,5 @@ void MouseCursor::draw() timer.start(MC_FRAME_PERIOD); } - cursor->draw_part(w*cur_frame, h*cur_state , x, y, w, h); + cursor->draw_part(w*cur_frame, h*cur_state , x-mid_x, y-mid_y, w, h); }