1 /**
2  * @file tiles_background.h
3  * @brief Draw tiles background in bricks levels
4  * @date 2012-09-02
5  * @copyright 1991-2014 TLK Games
6  * @author Bruno Ethvignot
7  * @version $Revision: 24 $
8  */
9 /*
10  * copyright (c) 1991-2014 TLK Games all rights reserved
11  * $Id: tiles_background.h 24 2014-09-28 15:30:04Z bruno.ethvignot@gmail.com $
12  *
13  * TecnoballZ is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * TecnoballZ is distributed in the hope that it will be useful, but
19  * WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26  * MA  02110-1301, USA.
27  */
28 #ifndef __TILES_BACKGROUND__
29 #define __TILES_BACKGROUND__
30 class tiles_background;
31 #include "../include/tecnoballz.h"
32 
33 class tiles_background:public virtual tecnoballz
34   {
35   public:
36     typedef enum
37     {
38       TILES_NO_SCROLL,
39       TILES_SCROLL_BEGIN,
40       TILES_SCROLL_LOST,
41       TILES_SCROLL_WIN,
42       TILES_SCROLL_GAMEOVER
43     }
44     TYPES_OF_SCROLL;
45 
46   private:
47     static tiles_background* tiles_background_singleton;
48     static Sint32 table_pos1[16];
49     static Sint32 table_pos2[16];
50     static unsigned char couleurs[448];
51     static const Sint32 TILES_32_WIDTH = 32;
52     static const Sint32 TILES_32_HEIGHT = 32;
53     static const Sint32 TILES_64_WIDTH = 64;
54     static const Sint32 TILES_64_HEIGHT = 64;
55 
56     typedef enum
57     {
58       TILES_32x32_WITH_4_COLORS,
59       TILES_64x64_WITH_16_COLORS
60     }
61     TYPES_OF_TILES;
62     /** Type of tiles TILES_64x64_WITH_16_COLORS
63      * or TILES_32x32_WITH_4_COLORS */
64     Uint32 type_of_tiles;
65     /** 4 color palette index */
66     Sint32 palette_index;
67 
68     bitmap_data *current_tiles;
69     Uint32 *map_tiles;
70     Uint32 map_height;
71     Uint32 map_width;
72     Uint32 map_row_size;
73     Uint32 map_xcoord;
74     Uint32 map_ycoord;
75     Uint32 map_xmax;
76     Uint32 map_ymax;
77     Uint32 tiles_width;
78     Uint32 tiles_height;
79     /** Type of scrolling TILES_NO_SCROLL, TILES_SCROLL_BEGIN, ... */
80     Uint32 map_scroll_num;
81     double map_angle_direction;
82     double map_angle_speed;
83     /** Velocity of the tiles background */
84     double map_velocity;
85     Sint32 map_scroll_delay;
86 
87 
88   private:
89     tiles_background ();
90     void draw_shadows ();
91     void generate_map ();
92     void set_palette ();
93     void set_4_color_palette (Uint32 pal_index);
94 
95   public:
96     ~tiles_background ();
97     static tiles_background *get_instance ();
98     void setup (Uint32 titles_num);
99     void set_scroll_type(Uint32 type);
100     void draw ();
101     void draw (offscreen_surface * offscreen);
102     void set_4_color_palette ();
103     void next_4_color_palette ();
104     void prev_4_color_palette ();
105   };
106 #endif
107