fix timeup issues when endsequence triggered
[supertux.git] / src / mousecursor.cpp
index 9814fa8..8fd776a 100644 (file)
@@ -1,21 +1,28 @@
-
-/***************************************************************************
- *                                                                         *
- *   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 <rick2@aeiou.pt>
+//  $Id$
+//
+//  SuperTux -  A Jump'n Run
+//  Copyright (C) 2004 Ricardo Cruz <rick2@aeiou.pt>
+//
+//  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)
 {
-  texture_load(&cursor,cursor_file.c_str(),USE_ALPHA);
+  cursor = new Surface(cursor_file, USE_ALPHA);
 
   cur_state = MC_NORMAL;
   cur_frame = 0;
@@ -29,7 +36,7 @@ MouseCursor::MouseCursor(std::string cursor_file, int frames)
 
 MouseCursor::~MouseCursor()
 {
-  texture_free(&cursor);
+  delete cursor;
 
   SDL_ShowCursor(SDL_ENABLE);
 }
@@ -48,8 +55,8 @@ void MouseCursor::draw()
 {
   int x,y,w,h;
   Uint8 ispressed = SDL_GetMouseState(&x,&y);
-  w = cursor.w / tot_frames;
-  h = cursor.h / MC_STATES_NB;
+  w = cursor->w / tot_frames;
+  h = cursor->h / MC_STATES_NB;
   if(ispressed &SDL_BUTTON(1) || ispressed &SDL_BUTTON(2))
     {
       if(cur_state != MC_CLICK)
@@ -64,7 +71,7 @@ void MouseCursor::draw()
         cur_state = state_before_click;
     }
 
-  if(timer_get_left(&timer) < 0 && tot_frames > 1)
+  if(timer.get_left() < 0 && tot_frames > 1)
     {
       cur_frame++;
       if(cur_frame++ >= tot_frames)
@@ -73,5 +80,5 @@ void MouseCursor::draw()
       timer.start(MC_FRAME_PERIOD);
     }
 
-  texture_draw_part(&cursor, w*cur_frame, h*cur_state , x, y, w, h);
+  cursor->draw_part(w*cur_frame, h*cur_state , x, y, w, h);
 }