// $Id: crystal.cc,v 1.4 2006/08/05 09:08:58 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 "crystal.h" // ******************* // *** CONSTRUCTOR *** // ******************* FS::Crystal::Crystal(int _y, int _width, int _height, int _map_x, int _row, int _row_length_pixels, CrystalColor _color) : CollectableSprite(CRYSTAL) { y = _y + CRYSTAL_Y_OFFSET; width = _width; height = _height; map_x = _map_x + CRYSTAL_X_OFFSET; row = _row; row_length_pixels = _row_length_pixels; original_color = current_color = _color; active = true; sprite_rect.y = y; sprite_rect.w = width; sprite_rect.h = height; dirty_rect.y = y; dirty_rect.h = height; coll_box_x_offset = COLL_BOX_X_OFFSET; coll_box_y_offset = COLL_BOX_Y_OFFSET; coll_box.w = COLL_BOX_WIDTH; coll_box.h = COLL_BOX_HEIGHT; bounding_box.w = width; bounding_box.h = height; } // FS::Crystal::Crystal() // ****************** // *** DESTRUCTOR *** // ****************** FS::Crystal::~Crystal() { // ?! } // FS::Crystal::~Crystal() // ************************ // *** MEMBER FUNCTIONS *** // ************************ // ************************************************** void FS::Crystal::reset() { current_color = original_color; active = true; } // FS::Crystal::reset() // ************************************************** void FS::Crystal::update(const int * current_start_pixels, const int * pixels_to_move, const int * old_pixels_to_move, const Direction * directions, bool is_first_pass, PlayDisplay * pd) { int pixels_moved = pixels_to_move[row] - old_pixels_to_move[row]; calc_x(current_start_pixels[row]); calc_sprite_rect(); // Initial values for dirty_rect. switch (directions[row]) { case LEFT_TO_RIGHT: dirty_rect.x = x - pixels_moved; if (dirty_rect.x < 0) { dirty_rect.x += row_length_pixels; } // if dirty_rect.w = pixels_moved + width; break; case RIGHT_TO_LEFT: dirty_rect.x = x; dirty_rect.w = width + pixels_moved; break; } // switch update_visible = adjust_rect(&dirty_rect); if (sprite_visible) { pd->request_blit( ((ImageIDs) (current_color + IMAGE_ID_CRYSTAL_OFFSET)), NULL, &sprite_rect ); } // if if (update_visible) { pd->request_update(dirty_rect); } // if } // FS::Crystal::update() // ************************************************** // **************************************************