// $Id: sprite.cc,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. #include "sprite.h" // CONSTRUCTORS // ============ Sprite::Sprite() {} // DESTRUCTOR // ========== Sprite::~Sprite() {} // MEMBER FUNCTIONS // ================ void Sprite::move(int xx, int yy) { x = old_x = xx; y = old_y = yy; pixels_moved = 0; } // Sprite::move() void Sprite::set_size(int w, int h) { width = w; height = h; } // Sprite::set_size() int Sprite::max(int a, int b) { if (a >= b) { return a; } else { return b; } // if ... else } // Sprite::max() int Sprite::min(int a, int b) { if (a <= b) { return a; } else { return b; } // if ... else } // Sprite::min() void Sprite::deactivate() { sprite_visible = trace_visible = active = false; } // Sprite::deactivate() // ************************************************** /* bool Sprite::is_collision(const Sprite & s) const { return ( (x + coll_box.x) >= (s.x + s.coll_box.x) - coll_box.w + 1 && (x + coll_box.x) <= (s.x + s.coll_box.x) + s.coll_box.w -1 && (y + coll_box.y) >= (s.y + s.coll_box.y) - coll_box.h + 1 && (y + coll_box.y) <= (s.y + s.coll_box.y) + s.coll_box.h -1 ); } // Sprite::is_collision() */ // ************************************************** /* SDL_Rect Sprite::get_coll_box() const { SDL_Rect scratch = { sprite_rect.x + coll_box.x, sprite_rect.y + coll_box.y, coll_box.w, coll_box.h }; return scratch; } // Sprite::get_coll_box() */ // ************************************************** const SDL_Rect & Sprite::get_coll_box() { coll_box.x = sprite_rect.x + coll_box_x_offset; coll_box.y = sprite_rect.y + coll_box_y_offset; return coll_box; } // Sprite::get_coll_box() // ************************************************** const SDL_Rect & Sprite::get_bounding_box() { bounding_box.x = sprite_rect.x; bounding_box.y = sprite_rect.y; return bounding_box; } // Sprite::get_bounding_box() // **************************************************