// $Id: sprite.h,v 1.4 2006/08/05 09:08:59 matthew Exp $ // Fish Supper // Copyright (C) 2006 Matthew Clarke // // 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. #ifndef _SPRITE_H_ #define _SPRITE_H_ #include "SDL.h" // for SDL_Rect class Sprite { protected: int x; int y; int old_x; int old_y; int width; int height; //bool visible; // can sprite be SEEN? bool active; // is sprite being used? float velocity; // pixels per millisecond int pixels_moved; bool sprite_visible; // any of sprite on screen? bool trace_visible; // any bits of old or new sprite on screen? SDL_Rect dirty_rect; // dirty pixels need re-drawing SDL_Rect sprite_rect; // how much of this sprite needs re-drawing SDL_Rect erase_rect; // with bg colour or backdrop? int coll_box_x_offset; int coll_box_y_offset; SDL_Rect coll_box; SDL_Rect bounding_box; // convenience methods for setting up SDL_Rects int max(int a, int b); int min(int a, int b); public: Sprite(); // default constructor virtual ~Sprite(); // virtual destructor - because Sprite will act as // a base class void move(int xx, int yy); // move sprite to new (given) coords //bool is_visible() const { return visible; } //void set_visible(bool v) { visible = v; } bool is_active() const { return active; } void set_active(bool a) { active = a; } void set_velocity(float vel) { velocity = vel; } float get_velocity() const { return velocity; } void set_size(int w, int h); int get_x() const { return x; } int get_y() const { return y; } int get_old_x() const { return old_x; } int get_old_y() const { return old_y; } int get_pixels_moved() const { return pixels_moved; } int get_width() const { return width; } int get_height() const { return height; } bool is_sprite_visible() const { return sprite_visible; } bool is_trace_visible() const { return trace_visible; } void set_sprite_visible(bool b) { sprite_visible = b; } void set_trace_visible(bool b) { trace_visible = b; } // Fast way of deactivating a sprite - i.e. setting // active, sprite_visible and trace_visible to false. void deactivate(); //bool is_collision(const Sprite & s) const; const SDL_Rect & get_coll_box(); const SDL_Rect & get_bounding_box(); // return SDL_Rect structs: SDL_Rect get_dirty_rect() { return dirty_rect; } // make this const? SDL_Rect * get_sprite_rect() { return &sprite_rect; } SDL_Rect * get_erase_rect() { return &erase_rect; } }; // class Sprite #endif