// $Id: albert.h,v 1.5 2006/08/07 12:50:08 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 _ALBERT_H_ #define _ALBERT_H_ #include "sprite.h" #include "enums.h" #include "constants.h" #include "log.h" #include "playdisplay.h" #include "crystal.h" #include "SDL.h" #include "fish.h" #include "collisions.h" #include "starparticlesystem.h" namespace FS { // FIXME: ?! static const int NUM_COLL_BOXES = 4; static const int COLL_BOX_X_OFFSETS[] = { 34, 31, 38, 28 }; static const int COLL_BOX_Y_OFFSETS[] = { 28, 34, 31, 38 }; static const int COLL_BOX_WIDTHS[] = { 12, 25, 12, 25 }; static const int COLL_BOX_HEIGHTS[] = { 25, 12, 25, 12 }; class Albert : public Sprite { private: Orientation my_orientation; char actions; bool airborne; int start_time; int start_x; int start_y; int current_frame; ImageIDs current_strip; Log * host_log; int coll_box_x_offsets[NUM_COLL_BOXES]; int coll_box_y_offsets[NUM_COLL_BOXES]; SDL_Rect my_coll_boxes[NUM_COLL_BOXES]; void process_keypress(int t, KeyboardEvent * events, int n, bool running); void process_animation(int t); void calc_rects(); void calc_strip(); void check_host_log(); SDL_Rect image_section_rect; void turn_on_action(int a) { actions |= a; } void turn_off_action(int a) { actions &= ~a; } int test_action(int a) const { return (actions & a); } // Albert landed in the water/got zapped and splashing/zapping // animation is over. bool splashed_zapped_out; bool left; bool next_jump_double; StarParticleSystem stars; public: Albert(); ~Albert(); void reset(); void update(int t, KeyboardEvent * events, int n, PlayDisplay * pd, bool running); int upper_y() const { return y + coll_box_y_offsets[my_orientation]; } int lower_y() const { return y + coll_box_y_offsets[my_orientation] + my_coll_boxes[my_orientation].h; } bool is_airborne() const { return airborne; } bool is_on_log() const { return (test_action(FLOATING) > 0); } int is_in_water_or_being_zapped() const; void set_new_host_log(Log * l); int get_host_log_row() const { return host_log->get_row(); } void start_splash(int t); void start_zap(int t); void start_leave_with_fish(int t); void start_leave_in_a_huff(int t); bool is_splashed_zapped_out() const { return splashed_zapped_out; } bool has_left() const { return left; } // Redefinition of Sprite::get_coll_box(). No dynamic binding. const SDL_Rect & get_coll_box(); // Redefinition of Sprite::get_bounding_box(). This is so we can make // Albert's bounding box a little bigger than image size. const SDL_Rect & get_bounding_box(); void set_next_jump_double() { next_jump_double = true; } }; // class Albert } // namespace FS #endif