// $Id: spritemanager.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 _SPRITEMANAGER_H_ #define _SPRITEMANAGER_H_ #include "enums.h" #include "SDL.h" #include "log.h" #include "crystal.h" #include "constants.h" #include "albert.h" #include "playdisplay.h" #include "playerdata.h" #include "fish.h" #include "soundengine.h" #include "bonus.h" #include #include "collectablesprite.h" #include "collisions.h" #include #include #include #include #include "mapengine.h" // for change_direction() namespace FS { class SpriteManager { public: enum State { PLAYING_GAME, REQUEST_LEVEL_RESTART, RUNNING_LEVEL_COMPLETED_ROUTINE, LEVEL_COMPLETED, RUNNING_GAME_OVER_ROUTINE, GAME_OVER }; // enum SpriteMngrState enum CatLogCollisionType { ALLOWED, DISALLOWED, MISSED }; private: PlayDisplay * my_play_display; // from GameManager PlayerData * my_player_data; // from PlayModel SoundEngine * my_snd_engine; // from GameManager MapEngine * my_map_engine; // from PlayModel std::vector my_logs; std::vector::iterator logs_iter; std::vector my_collectables; std::vector::iterator collectables_iter; bool my_map_sprites_allocated; bool is_first_pass; bool redraw_crystals; bool redraw_fish; Albert the_cat; Fish the_fish; // Use these to help with collision detection. int rows_min_ys[NUM_ROWS]; int rows_max_ys[NUM_ROWS]; RowDescription calc_alberts_row(); CatLogCollisionType check_cat_log_collision(int row); void check_cat_collectable_collision(int row); // These two variables work together to prevent Albert // from picking up a swapped crystal over and over... bool cat_crystal_collisions_disabled; Crystal * disabled_crystal; void check_collisions(); State current_state; // For Your Convenience: reset on each call to update(). int time_passed; void create_logs(const int * row_lengths, const Block * const * my_blocks, const int * row_lengths_pixels, const Direction * directions); void create_collectables(const int * row_lengths, const Block * const * my_blocks, const int * row_lengths_pixels, const Direction * directions); void handle_crystal_collision(Crystal * c); void handle_bonus_collision(Bonus * b); void set_logs_to_brown(int row); public: SpriteManager(); ~SpriteManager(); void set_play_display(PlayDisplay * pd) { my_play_display = pd; } void set_player_data(PlayerData * plyr_data) { my_player_data = plyr_data; } void set_sound_engine(SoundEngine * se) { my_snd_engine = se; } void set_map_engine(MapEngine * me) { my_map_engine = me; } void create_map_sprites(const int * row_lengths, const Block * const * my_blocks, const int * row_lengths_pixels, const Direction * directions); void reset(); void restart_level(); State update(int t, KeyboardEvent * events, int n, bool running, const int * current_start_pixels, const int * pixels_to_move, const int * old_pixels_to_move, const Direction * directions); }; // class SpriteManager } // namespace FS #endif